Convex Hull shape questions.

prasoc
Posts: 3
Joined: Mon Aug 29, 2011 9:24 pm

Convex Hull shape questions.

Post by prasoc »

There is little to no documentation on how to use btConvexHullShape, but I assume you use it as a shape and add vertices using ->AddPoint() right? This code doesn't seem to work at ALL, the objects meet the ground plane, and collide successfully, but its like the collision area is a tiny sphere in the middle of the object, which means the object itself (mesh) clips the plane quite a bit

Code: Select all

	btConvexHullShape* fallShape = new btConvexHullShape();

	dbPerformCheckListForObjectLimbs(1001);
	int limbCount = dbChecklistQuantity();
	int totalVertexCount = 0;
	for(int i = 0; i < limbCount; i++) {

		int vertexCount = GetVertexCountForLimb(i);

		for(int j = 0; i < vertexCount; i++) { 
			btVector3 position(dbGetVertexDataPositionX(j),dbGetVertexDataPositionY(j),dbGetVertexDataPositionZ(j));
			fallShape->addPoint(position);
			totalVertexCount++;
		}
	}
It has some of my own engine and DarkGDK code library implemented, but the code is pretty self-explanitory. Any reason the collision just isn't working? The "totalVertexCount" reaches like 2900, so I know vertices are actually being added.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Convex Hull shape questions.

Post by Erwin Coumans »

convexHull->addPoint should work as expected.

If you can reproduce the problem in a standalone Bullet demo, someone might be able to help out with the issue.
Thanks,
Erwin

By the way, 2900 vertices in a convex hull sounds extreme, usually there are only a handful of vertices in a convex hull shape.
prasoc
Posts: 3
Joined: Mon Aug 29, 2011 9:24 pm

Re: Convex Hull shape questions.

Post by prasoc »

I imported a shape that has a smaller number of vertices (like 150 or so), it still does exactly the same thing. Attached is a simple demo showing my problem. Maybe I'm using the wrong shape for the object? a btConvexHullShape should bound the object, is that the "easiest" shape for polygonal collision? I was playing around with sphereical and box collisions and they worked fine. Also, if you click the objects in the demo, it moves the objects using setLinearVelocity()
You do not have the required permissions to view the files attached to this post.
Mako_energy02
Posts: 171
Joined: Sun Jan 17, 2010 4:47 am

Re: Convex Hull shape questions.

Post by Mako_energy02 »

In your second for loop there, you appear to initialize a new variable "j", but only check and increment "i" from the previous for loop. Is that intended?