encapsulating class and shapes

ChrisC
Posts: 12
Joined: Wed Nov 29, 2006 9:27 am

encapsulating class and shapes

Post by ChrisC »

I'm wanting to make a class to encapsulate a physics "object" (body and shape) and visual (irrlicht scene node)

When creating my object with ODE I pass a flag which identifies the "type" of object and from the other parameters, scale and so forth I can create my new object.
Now I'm using bullet I'm having to rewrite sections of the class

Do I need a separate shape per object if they are different sizes?

or is there some way the body can apply different scales to the same
shape object?

Is there a general purpose shape pointer or should I just use a void pointer for the objects shape and cast to btConeShape or whatever my object type flag indicates, if I need it later...

btw wheres the common code for the demos hide...
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: encapsulating class and shapes

Post by Erwin Coumans »

ChrisC wrote:I'm wanting to make a class to encapsulate a physics "object" (body and shape) and visual (irrlicht scene node)
When creating my object with ODE I pass a flag which identifies the "type" of object and from the other parameters, scale and so forth I can create my new object.
Now I'm using bullet I'm having to rewrite sections of the class
Do I need a separate shape per object if they are different sizes?
or is there some way the body can apply different scales to the same
shape object?
All collision shapes in Bullet are derived from one base class, btCollisionShapes. You can get the type using getShapeType(). The local scaling is stored in the collision shapes, so for primitive shapes like box, sphere, cone, cylinder, capsule (= btMultisphereShape with 2 spheres) you need the same scaling to share.

For convex and concave triangle meshes, Bullet allows to share the mesh data among different collision shapes. Also, you can share the graphics mesh data for collision detection by indexing.

You can find more info by studying the demos, and Bullet_User_Manual.pdf. See also the Bullet/Demos/OpenGL/DemoApplication.cpp.
Erwin
ChrisC
Posts: 12
Joined: Wed Nov 29, 2006 9:27 am

Post by ChrisC »

Thanks thats a little clearer!

The manual is a little slim and bereft of description about basic concepts, the api docs are good but theres little discussion about correct use of the api

many things like a discussion of the last parameter of btStaticPlaneShape for example are missing

The manual could really do with expanding with extra advice about how the api is intended to be used and what things to avoid.

This from the perspective of a new user is the only thing missing from this fantastic piece of work.

Please keep up the good work and take this in the spirit it was intended!