I read this a while ago and implemented my own version, as part of a model class. It's a really useful thread!
http://www.gamedev.n...ding-in-detail/
However, as someone in the thread points out: 'How do I go about drawing all this sh*t in OpenGL?'
I have learned that .obj indices start at 1, not 0. Can anybody help me apply this nugget of information to the following render method, which draws triangles from memory (stored in memory as in the thread linked above).
Many thanks in advance, I've been stuck on this forever and can't seem to find anything online about it.
Once I/we figure this out, I can get on with my project.
As Turvold said, 'talk is cheap, show me the code'.
void GLModel::RenderMesh( Colour3 c ) {
glPushMatrix();
glTranslatef(pos.x, pos.y, pos.z);
glColor3f( c.r, c.g, c.b );
glLineWidth(1.0);
glBegin(GL_TRIANGLES);
for ( int i = 0; i < mesh.noTriangles; i++ ) { //for each triangle in the list
Vector3D vpos; Normal3D npos;
// this vertex is the said triangle, verts attached
vpos.x = mesh.vertices[ mesh.triangleList.Vertex[0] ].x;
vpos.y = mesh.vertices[ mesh.triangleList.Vertex[1] ].y;
vpos.z = mesh.vertices[ mesh.triangleList.Vertex[2] ].z;
// this vertex is the said triangle, normals attached
npos.x = mesh.normals[ mesh.triangleList.Normal[0] ].x;
npos.y = mesh.normals[ mesh.triangleList.Normal[1] ].y;
npos.z = mesh.normals[ mesh.triangleList.Normal[2] ].z;
glVertex3f(vpos.x, vpos.y, vpos.z);
//glNormal3f(npos.x, npos.y, npos.z);
} // i++
glEnd();
glPopMatrix();
}
Please help me! - Apparently I can't upload .cpp files, if anyone wants to see the whole class, leave a comment and I'll post it