Jump to content
  • Advertisement
Sign in to follow this  

glm .obj with bullet physics

This topic is 3679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 );
                        triangle = mesh->triangles[(group->triangles)];

                        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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!