(C++) Bullet - Shortest code snippet ever!

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

(C++) Bullet - Shortest code snippet ever!

Post by BlindSide »

Just thought I'd share this:

Code: Select all

btCompoundShape* cShape = new btCompoundShape();

for(u32 i = 0;i < meshBufferCount;++i)
{
		IMeshBuffer* mb = mesh->getMeshBuffer(i);
		cShape->addChildShape(btTransform::getIdentity(), 
			new btConvexHullShape(&((S3DVertex*)mb->getVertices())->Pos.X,
			mb->getVertexCount(), getVertexPitchFromType(mb->getVertexType())));	
}	
This short snippet will turn any Irrlicht IMesh (Referred to as "mesh" here) into a Bullet Multiple Convex Hull shape (cShape). Works with any vertex type too.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Nice.

Would be nice to know how to bind the TerrainSceneNode, tho. I can't seem to get it working using a 512x512 bitmap.
Image
Masterhawk
Posts: 299
Joined: Mon Nov 27, 2006 6:52 pm
Location: GERMANY
Contact:

Post by Masterhawk »

dlangdev wrote:Would be nice to know how to bind the TerrainSceneNode, tho. I can't seem to get it working using a 512x512 bitmap.
Well, I guess that won't work since blindside creates a convex hull and a terrain definitely has a concave shape. I currently also have this problem with my Userdefined Newton bodies.

That's what come out if you try to make a convexhull of a hut in Newton. (Collision is represented by lines)
Image
Last edited by Masterhawk on Mon Nov 10, 2008 11:57 am, edited 1 time in total.
Image
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

BSP is another thing as well. I created a tunnel demo game and the balls just passed through the walls and floors.
Image
Post Reply