Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Jan 25, 2012 2:41 pm 
Offline

Joined: Wed Jan 25, 2012 2:27 pm
Posts: 7
I chose to use Ogre+Bullet.
I can create a box but I don't know how to create an object by mesh and skeleton files made from blender?
And, how to detect collision in this case?


Top
 Profile  
 
PostPosted: Wed Jan 25, 2012 3:38 pm 
Offline

Joined: Sun Jan 01, 2012 7:37 pm
Posts: 55
you take your points, and you shove it into a trimesh, then create a convex or concave object depending on your mesh.
viewtopic.php?t=4513


Top
 Profile  
 
PostPosted: Wed Jan 25, 2012 3:44 pm 
Offline

Joined: Thu Nov 26, 2009 6:32 pm
Posts: 76
Meshes can be displayed as concave dynamic, static and convex-decomposed bodies in Bullet.
For "dynamic Concave meshes" look at btGImpactMeshShape.
For "static mesh objects" , create the mesh using btBvhTriangleMeshShape and use the btCollisionShape to create the btRigidBody. Finally assign zero mass to the btRigidBody.

For dynamic convex-decomposed meshes, you have to decompose the mesh in to convex hulls and then form a compound shape out of all the hulls and use it for collision detection. See example "AppConvexDecompositionDemo" for details.


Top
 Profile  
 
PostPosted: Thu Jan 26, 2012 10:45 am 
Offline

Joined: Wed Jan 25, 2012 2:27 pm
Posts: 7
Actually I want to create a Kinematic body which takes a joystick or other input devices as input and I also want to check this Kinematic body whether collides with other dynamic bodys.
So far, I have been able to check the collision between boxes. My task now is to learn how to use my parter's mesh and skeleton in my physics world. Should I ask him to export a .bullet file for me? Does the .bullet file include both mesh and skeleton or What's the relationship between them?
Would you give some suggestions to my problem? Or tell me how to achieve my aim.
Thanks a lot.


Top
 Profile  
 
PostPosted: Wed Feb 01, 2012 3:50 pm 
Offline

Joined: Thu Nov 26, 2009 6:32 pm
Posts: 76
Here is how you load a tri mesh in bullet regardless of the format..

Code:
btRigidBody* BulletWrap::addTriangleMesh( btVector3 &p0, btVector3 &p1, btVector3 &p2,btVector3 &position,
                           bool useQuantizedBvhTree,btVector3 &inertia, btScalar mass,
                           btScalar restitution, bool collision )
{
   btTriangleMesh* trimesh = new btTriangleMesh();
   trimesh->addTriangle( p0, p1, p2 );
   
   btTransform   trans;
   trans.setIdentity();
   trans.setOrigin( position );

   btCollisionShape* trimeshShape  = new btBvhTriangleMeshShape( trimesh, useQuantizedBvhTree );
   trimeshShape->calculateLocalInertia( mass, inertia ); //gives error
   
   btDefaultMotionState* motionstate = new btDefaultMotionState( trans );

   btRigidBody* body= new btRigidBody( mass, motionstate, trimeshShape, inertia );
   body->setRestitution( restitution );
   
   m_trianglemeshs.push_back( trimesh );
   m_triangleMeshBodies.push_back( body );
   m_world->addRigidBody( body );
   
   std::vector< btVector3* > tmp;
   m_vertices.push_back(tmp);
   m_vertices[ m_triangleMeshBodies.size() - 1 ].push_back( &p0 );
   m_vertices[ m_triangleMeshBodies.size() - 1 ].push_back( &p1 );
   m_vertices[ m_triangleMeshBodies.size() - 1 ].push_back( &p2 );
   
   if( collision )
      m_collisionShapes.push_back(trimeshShape);
   
   //return m_triangleMeshBodies.size() - 1;
   return body;
}

void BulletWrap::addTriangleToMesh( int mesh, btVector3 &p0, btVector3 &p1, btVector3 &p2 ){
   if( m_trianglemeshs[mesh] ){
      m_trianglemeshs[mesh]->addTriangle( p0, p1, p2 );
      
      m_vertices[mesh].push_back( &p0 );
      m_vertices[mesh].push_back( &p1 );
      m_vertices[mesh].push_back( &p2 );
   }
   ///TODO: error codes...
}



p0 , p1, p2 are the vertices of every triangle.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: Exabot [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group