Bullet Terrain Collision
Posted: Thu Jul 16, 2015 6:03 pm
Hello i recently implemented bullet in my engine and started playing around with it. Today i implemented some basic collisions. I also loaded my terrain's vertices and created triangle mesh shape ->addTriangle. From there standart rigid body. It's all working fine and cool but the models i loaded as convex hull do go thru' the terrain , note that basic primitive collision shapes do not , i tested with box shape and it does respond correctly with the terrain.
Here is how i generate the convex hull.
Outside note. I have a Player and a camera. The Player has Model Matrix and it is controlled by standart keyboard controlls. I want the player to move but also be responsive to the simulation. Should i instead transform the rigid body and use rigid's body feed back matrix to translate the Player?
Another Note: When i start the program i get slow (not laggy) performance, after 3-4 seconds it goes away and no performance drops are present, is this normal ?
Here is how i generate the convex hull.
Code: Select all
btConvexHullShape *hullShape = new btConvexHullShape;
hullShape->calculateLocalInertia(mass, inertia);
for (int i = 0; i < indices.size(); i++) {
int index = indices[i];
btVector3 point = btVector3(vertices[index].x, vertices[index].y, vertices[index].z);
hullShape->addPoint(point);
}
btShapeHull* hull = new btShapeHull(hullShape);
btScalar margin = hullShape->getMargin();
hull->buildHull(margin);
btConvexHullShape* simplifiedConvexShape = new btConvexHullShape((btScalar*)hull->getVertexPointer(), hull->numVertices());
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(mass, motionstate, simplifiedConvexShape, inertia);
btRigidBody *RigidBody = new btRigidBody(rigidBodyCI);
return RigidBody;
Another Note: When i start the program i get slow (not laggy) performance, after 3-4 seconds it goes away and no performance drops are present, is this normal ?