Loading Models
After completing our efficient queryable structure (and a lot of debugging!), we wanted to test our program on more complex scenes. One of our goals was to load arbitrary models from a file. A common file format that very simply describes a 3D model STL. The model does not contain any color information and the description is merely just a triangle mesh: precisely what we can process.
The informations are encoded in binary in the following way:
Data Type | Comment |
---|---|
char[80] |
Textual header |
uint32 |
The number of triangles |
Triangle[] |
The triangles |
The Triangle
structure is defined as follows:
Data Type | Comment |
---|---|
Vector |
The normal vector |
Vector[3] |
The vertices , and |
uint16 |
A checksum |
And finally Vector
is defined as:
Data Type | Comment |
---|---|
float32[3] |
The , and coordinates |
Here are the results of some of our tests with some STL models that are in the public domain:
As you can see the complexity of the scene now barely affects the rendering time, which is an excellent news.