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
Not rounded shapes (using DemoApplication class)
Not rounded shapes (using DemoApplication class)
- Attachments
-
- Cylinder¿¿¿.jpg (73.06 KiB) Viewed 3366 times
Re: Not rounded shapes (using DemoApplication class)
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.
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.
- Erwin Coumans
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
- Contact:
Re: Not rounded shapes (using DemoApplication class)
This is just some basic approximation for demo rendering purposes, the collision detection uses the actual rounded shape for btCylinderShape.
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
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);
Thanks,
Erwin