I am using GLM to load a obj file into my application and am using (well trying to) bullet for the collision detection. The only problem is that when I try and load the data itno bullet for some reason it comes out all messed up, including indices being larger then the allowed amount. Below is relevant code, with some notes, first group has over 5k triangles, the hard coded 100 is just so my screen doesnt get filled completely. Anyways heres the code
Code: Select all
for( GLuint i = 0; i < 100; i++ ){//group->numtriangles; i++ ){
printf( "tri %i\n", group->triangles[i] );
triangle = mesh->triangles[(group->triangles[i])];
GLuint index0 =3*triangle.vindices[0];
GLuint index1 =3*triangle.vindices[1];
GLuint index2 =3*triangle.vindices[2];
GLfloat* p0 = &mesh->vertices[index0];
GLfloat* p1 = &mesh->vertices[index1];
GLfloat* p2 = &mesh->vertices[index2];
printf( "indeice %i, %i %i %i\n", mesh->numvertices*3, index0, index1, index2 );
btVector3* v0 = new btVector3( p0[0], p0[1], p0[2] );
btVector3* v1 = new btVector3( p1[0], p1[1], p1[2] );
btVector3* v2 = new btVector3( p2[0], p2[1], p2[2] );
//*v0 *= scale;
//*v1 *= scale;
//*v2 *= scale;
printf( "value %f %f %f\n", v0->x(), v0->y(), v0->z() );
trimesh->addTriangle( *v0, *v1, *v2 );
verts.push_back( v0 );
verts.push_back( v1 );
verts.push_back( v2 );
}
also in case anyone asked, I can use the built in method for drawing in GLM and the scene will render fine. ( also incase you cant figure it out, mesh is the GLMmodel)
SOLUTION:
Forgot I posted this on here but if anyone else runs into the same trouble I did, it was caused due to the fact that glm.c defines METERAL_BY_FACE, so everything was being offset, I threw the define into the .h (why they didnt do it like that i dont know) and it works fine..