Bullet Terrain Collision

Post Reply
Asmodeus
Posts: 2
Joined: Thu Jul 16, 2015 5:54 pm

Bullet Terrain Collision

Post by Asmodeus »

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.

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;
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 ?
Asmodeus
Posts: 2
Joined: Thu Jul 16, 2015 5:54 pm

Re: Bullet Terrain Collision

Post by Asmodeus »

Are there any people around ?????

HELLO! I have found a solution to my last Question , but i would like to address a new one.

I am creating a simplified convex hull from a mesh(using the minimal vertices allowed to create the hull) and a btTriangleMesh for a terrain mesh. But if i use the convex hull to detect a collision between the mesh and the terrain i get strange glitching it looks like maybe wrong center of mass. I will include code if requested.

Also how would one, implement human "like" reactive body in the physics world
Post Reply