darkhog wrote:but using ZGEBullet from game/app developer's standpoint is royal PITA. I've downloaded demo app available on Google Code, but it is so complicated that I wasn't able to comprehend true form of it.
... hmmm... using of ZGEBullet is relatively simple if you understand principles of Bullet. The demo you tried to understand provides a generic framework for Bullet simulations/demos in ZGE, so it is complicated for newcomers.
If you want to use ZGEBullet, in your application, follow these quite straightforward rules:
OnLoaded section:
1. Include ZGEBullet external library in your project.
2. Initialize the bullet world by zbtCreateWorld() and optionally also set gravity with zbtSetWorldGravity().
3. Create and remember collision shapes you will use in your application by means of zbtCreate*Shape functions. It is recommended to create shapes shared by several physical objects (called rigid bodies) just once; e.g., to create a shape of cube used by many cubes placed to a simulated scene.
OnClose section: just destroy the physical world and all defined collision shapes by zbtDestroyWorld() and zbtDeleteAllShapes().
OnUpdate section: perform the Bullet simulation step (ZGEBullet uses discrete simulation) by delta time from the last rendering (ZApplication.DeltaTime), use zbtStepSimulation(). This will update positions and rotations of all objects in the scene based on their physical properties and current state.
To put physics-aware objects to the scene, you must create rigid bodies by means of zbtAddRigidBody() function. They correspond either to objects in environment (usually static, such as walls, ground) or objects represented by ZGE models (usually used for dynamically moving objects). Statical objects have mass 0, for dynamic objects mass is more than 0. Each rigid body specifies its shape by a reference to one of the previously created collision shapes.
Scene initialization (can be, e.g., part of OnLoaded section or OnStart section of an AppState component):
1. create rigid bodies corresponding to the scene's statical objects.
2. Spawn models used to represent dynamic objects. BTW they can be spawn any time during simulation.
Physics-aware model:
1. Define as local variable used to remember the model's rigid body.
2. OnSpawn section: create rigid body and optionally also set some additional (advanced) physical properties, such as damping or deactivation threshold.
3. OnUpdate section: update position and rotationof the model by: zbtGetPosition(BrickId, CurrentModel.Position.X, CurrentModel.Position.Y, CurrentModel.Position.Z); zbtGetRotation(BrickId, CurrentModel.Rotation.X, CurrentModel.Rotation.Y, CurrentModel.Rotation.Z);
4. OnRemove section: remove rigid body by zbtDeleteRigidBody().
Remark: The rendered shape of the model should of course correspond to the used collision shape.
And that's all. Can look complicated at the first look, but actually it is not when you try it in your own example(s). And of course, I could answer you any questions if you decided to use/try ZGEBullet.
Attached you will find a much simpler example I used for initial testing of ZGEBullet for Android.