Page 1 of 1

Not rounded shapes (using DemoApplication class)

Posted: Sat Dec 26, 2009 5:00 am
by PORRAS
Hi, all.

I'm trying to modify one of the supplied demos to create a simple application.

For now, I only want to detect collisions, so I'm using the CollisionInterfaceDemo example.

I know that shapes are drawn using OpenGL through DemoApplication member functions. But, went I try to use a simple sphere or cylinder, I get an irregular one, I mean, without rounded shapes, very polygonal, with insufficient vertices. The result is similar when I use a convex hull with rounded edges.

Could you tell me how to change this setting or behaviour?

Does the collision detection algorithm takes into account this irregular drawn shape, or performs its calculations with a more rounded one?

Attached you can see a sample picture.

Thank you very much,
Francisco

Re: Not rounded shapes (using DemoApplication class)

Posted: Mon Jan 18, 2010 1:14 pm
by mako90
Hi,
where did you get that mesh? Looks like it's been imported from some 3D program or created by points.
Have you used btCylinderShape for creating the shape?

BR.

Re: Not rounded shapes (using DemoApplication class)

Posted: Tue Jan 19, 2010 6:56 am
by Erwin Coumans
This is just some basic approximation for demo rendering purposes, the collision detection uses the actual rounded shape for btCylinderShape.

Code: Select all

GL_ShapeDrawer::ShapeCache*		GL_ShapeDrawer::cache(btConvexShape* shape)
{
	ShapeCache*		sc=(ShapeCache*)shape->getUserPointer();
	if(!sc)
	{
		sc=new(btAlignedAlloc(sizeof(ShapeCache),16)) ShapeCache(shape);
		sc->m_shapehull.buildHull(shape->getMargin());
		m_shapecaches.push_back(sc);
The btShapeHull utility uses a rough approximation based on NUM_UNITSPHERE_POINTS, 42. You can add additional direction for better approximation, or add your own better rendering.
Thanks,
Erwin