Skip to content
davido262 edited this page Nov 11, 2012 · 6 revisions

Description of the optimized binary model format.

There is a specialized and optimized binary file format to store models. The format includes the vertices, indices, normals, UV coordinates, material and texture names. Whenever a model is loaded, it first tries to find the optimized model file and if it is not found it imports the original file and creates an optimized file.

The Shoggoth Engine uses ASSIMP (Open Asset Import Library) to import almost any format of 3D models. For more information check the official ASSIMP site. Once the model is imported, the important information is copied into a Model object which stores all the needed information and then writes the optimized binary model file. ASSIMP is used to open many model formats, and import speed is not as important. The optimized binary model file is designed with import performance in mind.

Model

In the Shoggoth Engine, a Model is a collection of one or more meshes with materials and textures. A Model is completely described in a file, so every file should describe only one model and never a complete scene. A Model can consist of one or more meshes, each one with a material. A RenderableMesh and a RigidBody's convex and concave hulls use a Model by giving the path to a model file. It then reads the model and stores it a resource pool with only one instance of each in memory. Internally a Model has an identifier (which is the file name) and has a vector of meshes.

Mesh

A Mesh is the smallest renderable component. And a Model can consist of one or more meshes. An important characteristic of a Mesh is that it can only store one material. If a given model needs more than one material, then it needs to be broken into more meshes. The ASSIMP importer breaks the model down automatically.

Internally it consists of four vectors and a Material. The vectors describe: vertices, normals, UV coordinates and indices. The vertices and normals vectors contain float values and are a collection of groups of three which represent the X, Y and Z values. This means that the size of these vectors is of totalVertices * 3. The UV coordinates vector contains float values which are in pairs representing the U and V values making it of size totalVertices * 2. The indices vector contains unsigned int values and they describe the triangles which form the mesh. They come in collections of three which represent the three points of a triangle by telling the index in the vertices vector. The indices vector is of size totalTriangles * 3.

Material

The Material describes how the mesh will be rendered. It contains the lighting properties as well as the textures. Internally it stores a diffuse color, a specular color, an ambient color, an emissive color, a shininess factor and a vector of Texture maps. The colors are only arrays of three floats which store an RGB (Red Green Blue) component, each of which can be a value from 0.0f to 1.0f.

Clone this wiki locally