Sign in to follow this  

glm .obj with bullet physics

Recommended Posts

Hi, This might not be the best place to post this but I cant, for the life of me, figure out this error. I am trying to use a model that I'ved loaded in with GLM with bullet physics. The only issue is that when I load in the model all the vertexs are messed up. I have found that the indices are coming out to be larger then the total number of vertices, but cant figure out why as I based my loading code from the code that GLM uses to draw it's meshes. Anyways here the relevent code, any help would be GREALY apprenticed. NOTE: the group has some 9000 triangles, and the hard coded 100 is just so it doesnt fill my screen with usless things.
                 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 );


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this