How to render convex shape?

icek
Posts: 14
Joined: Thu May 15, 2008 6:09 pm

How to render convex shape?

Post by icek »

Hi, simple question, is there an easy way to render convex shape defined by list of points? I'm using btIDebugDraw from bullet, but shape is hard to recognise, i see only some strange lines and bounding box...
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: How to render convex shape?

Post by sparkprime »

One possible method is to generate every possible triangle. This is obviously a lot of triangles, though. For n convex hull points I believe it is n(n-1)(n-2)/3 triangles. Maybe there is some method for filtering down the triangles afterwards.
icek
Posts: 14
Joined: Thu May 15, 2008 6:09 pm

Re: How to render convex shape?

Post by icek »

yes, I thought about this already, but can bullet help me with it? I belive that creating triangle mesh from points is not easy task..
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: How to render convex shape?

Post by sparkprime »

It sounds like you have a bug or you're using bullet wrong. A screenshot and/or reproduction case would probably help.
icek
Posts: 14
Joined: Thu May 15, 2008 6:09 pm

Re: How to render convex shape?

Post by icek »

Image
this is btConvexShape created from points which represents box, debug draw is setted to draw AABB and lines... AABB is fine, but LINES are surely wrong...

this is how it looks with only btIDebugDrwaw::DBG_DrawWireframe
Image
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: How to render convex shape?

Post by Erwin Coumans »

is there an easy way to render convex shape defined by list of points
The btShapeHull utility generates the triangles from a convex point cloud. The debug drawer should use this utility in the future.

See Bullet/Demos/ConvexDecompositionDemo for an example how to use the btShapeHull utility:

Code: Select all

		btShapeHull* hull = new btShapeHull(tmpConvexShape);
		btScalar margin = tmpConvexShape->getMargin();
		hull->buildHull(margin);
		
		printf("new numTriangles = %d\n", hull->numTriangles ());
		printf("new numIndices = %d\n", hull->numIndices ());
		printf("new numVertices = %d\n", hull->numVertices ());
Hope this helps,
Erwin
icek
Posts: 14
Joined: Thu May 15, 2008 6:09 pm

Re: How to render convex shape?

Post by icek »

Great :wink: Thank you
Verbo
Posts: 39
Joined: Fri May 08, 2009 9:27 pm

Re: How to render convex shape?

Post by Verbo »

Hi,

I did try to use the btShapeHull utility to draw my convex hull shapes, but it makes the whole drawing uber slow, and apart the speed problem, I still see the convex shape being drawn erratically as icek was mentioning.

Has anyone found a better way to draw convex hull shape in a better way?

Verbo