Help those suffering in the Horn of Africa

VSResModel Lib – Very Simple Resource Model Lib

This lib is a subclass of VSResourceLib, and it provides an interface to the Open Asset Import Library (Assimp).

Assimp is able to load a rich set of file formats. This lib interfaces with the Assimp lib to be able to provide those same loading abilities and render the models with core OpenGL .

Not all of Assimp’s features are made available yet, but, as is, the lib is able to import and render all models using texture coordinates, normals, tangents and bitangents.

Requirements

This class requires the following classes from VSL:

  • VSResourceLib - the superclass
  • VSMathLib - although this class does not use any math, all subclasses implemented so far do, so its included in here to.
  • VSLogLib - Logs are used to keep track of loading errors and resource info
  • VSShaderLib – To be able to work with uniform variables

VSResourceLib also has the following external dependencies:

  • GLEW - to access OpenGL functions
  • Assimp - for model loading

Methods and usage

This class implements the abstract methods in VSResourceLib.

Assume that the shader has the following block:

layout (std140) uniform Material {
	vec4 diffuse;
	vec4 ambient;
	vec4 specular;
	vec4 emissive;
	float shininess;
	int texCount;
};

The following snippet of code shows how a model can be loaded and its uniforms initialized:

VSResModelLib myModel;

// load the model
if (myModel1.load("models/spider.obj"))
    printf("%s\n", myModel.getInfo().c_str());
else {
    printf("%s\n", myModel.getErrors().c_str());
    return;
}

// setting the semantics of the uniform block
myModel.setMaterialBlockName("Material");

This next example shows how to replace/add the texture settings for a given texture unit, for ALL meshes of a model.

myModel.addTexture(0, "Textures/tile2.tga");

To render the model just call render after glUseProgram.

History

version 0.2.0

  • Added cubemap textures
  • Added the possibility to reuse textures
  • Loader gets tangent and bitangent attributes

Version 0.1.0

  • Initial Release

Download

To download go to VSL Downloads page.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

84,518 Spam Comments Blocked so far by Spam Free Wordpress

HTML tags are not allowed.

© 2013 Lighthouse3d.com Suffusion theme by Sayontan Sinha