A short entry today. I’ve created a new plg text file that defines a tetrahedron. I found some files on the net that defined this shape and adapted them to the plg format; easily done actually. A tetrahedron is a four vertex, four triangle faced geometric model. Be sure and watch for the winding order of the defined polygon list. If they are not left-handed, counterclockwise like our engine is designed for, you may have to switch around the order of the defined face, vertex order. Why? The back face routine will not work properly, review the RemoveBackface Method if this is not clear. I just used it as I found it, ran it through this demo app and observed if the back faces are properly rendered, if not, switch them.
Here’s an example line from our text file defines a polygon list,
0xd0f0 3 0 2 1
The first hex digit is a color, in this case, green. The 3 means this is a three vertex polygon, a triangle and the 0, 2, 1 defines the vertex order. If this were a clockwise designed model, all you do is switch the last two to give you a winding order of, 0, 1, 2.
The example project is just like the previous project, substituting the tetrahedron.plg file that our program loads up during initialization. If you run it right after changing the model file, the model will be barely visible because of the way the model is defined, scale wise that is. So, I just scaled it up 50 units and was good to go.
**************************************************************************************************
This is this installments link. It’s an online book (free) that’s for the iPhone, but it has a lot of very cool chapters on OpenGL that may help you understand some concepts, I know it helps me.
One thing that Chapter 4 discusses is using a simple file format called ‘.obj’. I’m thinking I might write a parser to use this file format too. As I’ve mentioned, parsers and me don’t have much fun together, but it doesn’t look too hard and there are some nice .obj files in the public domain we could use.
