Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About JohnOram

  • Rank
  1. hello djdduty,
    I'd be happy to share with you my code, although I'm not sure how much help it'd be.
    What you're asking for is scattered throughout my code, but the core of it is in two functions:
    btConvexShape* objToCollisionShape(GLMmodel *model);
    void createBulletPhysicsBody(GameObject *);
    How would it be best for me to share these functions ...
  2. I was able to get it to work. I didn't realise that the vertex array was offset by three, for their x,y&z values. btConvexShape* objToCollissionShape(GLMmodel *model){ btTriangleMesh *trimesh = new btTriangleMesh(); // populate triangle mesh for (int i=0; i<model->numtriangles; i++){ GLMtriangle *triangle = &model->triangles; float *vertexA =&model->vertices[3*triangle->vindices[0]]; float *vertexB =&model->vertices[3*triangle->vindices[1]]; float *vertexC =&model->vertices[3*triangle->vindices[2]]; btVector3 btVertexA(vertexA[0],vertexA[1],vertexA[2]); btVector3 btVertexB(vertexB[0],vertexB[1],vertexB[2]); btVector3 btVertexC(vertexC[0],vertexC[1],vertexC[2]); trimesh->addTriangle(btVertexA, btVertexB, btVertexC); } // convert triangle mesh into convex shape btConvexShape *tmpshape = new btConvexTriangleMeshShape(trimesh); btShapeHull *hull = new btShapeHull(tmpshape); btScalar margin = tmpshape->getMargin(); hull->buildHull(margin); tmpshape->setUserPointer(hull); return tmpshape; } hopefully this will be helpful to someone.
  3. Hey, So I'm working on creating a physics model from an obj file. I'm using the bullet physics engine, 2.77 and a GLMmodel to load the file. I walk through the triangles in the GLMModel, and add them to the btTriangleMesh. I'm pretty sure I need to do something else to the mesh, but can't figure out what. btConvexTriangleMeshShape* objToCollissionShape(GLMmodel *model){ btTriangleMesh *trimesh = new btTriangleMesh(); for( GLuint i = 0; i <model->numtriangles; i++ ){ std::cout << "triangle " << i << ":\n"; GLMtriangle triangle = model->triangles; GLuint index0 =triangle.vindices[0]; GLuint index1 =triangle.vindices[1]; GLuint index2 =triangle.vindices[2]; printf( "indeices: %i %i %i\n", index0, index1, index2 ); GLfloat* p0 = &model->vertices[index0]; GLfloat* p1 = &model->vertices[index1]; GLfloat* p2 = &model->vertices[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] ); std::cout << "vertex("<<index0<<"):"<<v0->x()<<", "<<v0->y()<<", "<<v0->z()<<"\n"; std::cout << "vertex("<<index1<<"):"<<v1->x()<<", "<<v1->y()<<", "<<v1->z()<<"\n"; std::cout << "vertex("<<index2<<"):"<<v2->x()<<", "<<v2->y()<<", "<<v2->z()<<"\n"; trimesh->addTriangle(*v0,*v1,*v2); } return new btConvexTriangleMeshShape(trimesh); } I get this error: Overflow in AABB, object removed from simulation If you can reproduce this, please email bugs@continuousphysics.com Please include above information, your Platform, version of OS. Thanks. [/quote] Any thoughts would be appreciated.
  • 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!