I have a mesh...

dehseth
Posts: 5
Joined: Mon Dec 28, 2009 9:48 am

I have a mesh...

Post by dehseth »

I am using Irrlicht game engine and I have a mesh, this mesh is a burrowed wood. What should I use to convert my mesh into bullet physics? Should I use btConvexHullShape, or btConcaveShape? or smt else?

e.g: you have a city, and you loaded this city into your game engine, what do you use for collision detection in bullet?

this is what I did in Irrlicht game engine, but not sure if it works:

Code: Select all

btConvexHullShape* chs = new btConvexHullShape();
	
	int count = meshTahta->getMeshBufferCount();
	scene::IMeshBuffer* mb = meshTahta->getMeshBuffer(0);
	
	int vcount = mb->getVertexCount();
	float* vertices = (float*)mb->getVertices();
	
	for (int i = 0; i < vcount; i+= 3)
	{
		chs->addPoint(btVector3(vertices[0], vertices[1], vertices[2]));
	}
THank you all.
spy32
Posts: 19
Joined: Fri Aug 01, 2008 1:12 pm

Re: I have a mesh...

Post by spy32 »

1. Your counting variable i is never used. You're just adding the 3 first vertices of the mesh buffer to bullet's mesh.
2. You will need the mesh's indices in order to add the vertices "in the right order". Use IMeshBuffer::getIndices().

-

Have a look at the code I've posted here. I am pretty sure it'll help you, too. For your piece of wood a convex hull mesh is just right, but why aren't you using a box to approximate the wood's shape?
dehseth
Posts: 5
Joined: Mon Dec 28, 2009 9:48 am

Re: I have a mesh...

Post by dehseth »

I used btTriangleMesh. I do not use a box cause, I have a metal ball and I put this ball into this wood.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: I have a mesh...

Post by Erwin Coumans »

For static (non-moving) world environment (usually triangle meshes) it is best to use the btBvhTriangleMeshShape.

For dynamic moving objects (mass > 0) it is best to use either primitives (box, sphere etc), convex hulls (btConvexHullShape) or compounds of convex shapes (btCompoundShape).
See also the Bullet User Manual.

Cheers,
Erwin