egg model can support destructible environments with bulltet

Hello everybody, i have question it’s possible to have destructible environments with panda3d and bullet physics engine ? with use egg 3d model ?

Actualy only solution i have found is to create “3D model” by assembling several cube…

Bullet has no built in “destruction” capabilities that I know of. If you just need simple destruction for effects (e.g., a crate exploding), you can swap out your solid object with a collection of pre-created, fractured sub-objects.

As far as I know, EGG can contain information for Panda’s builtin physics engine, but not Bullet. BAM files are capable of storing Bullet information, but may require Panda 1.10 (the version in development) to work properly.

One simpler and more high-performance approach is to pre-fracture your meshes using bones to represent each part, simulate the animation of the parts falling to the ground, and then baking that into an armature animation. I think this should be possible to do in Blender, and would not require a physics engine.

Otherwise, the approach of pre-fracturing and using bullet trimeshes for the subparts is still possible, but as Moguri said .egg doesn’t encode Bullet objects directly. You can, however, write some code to create a trimesh for each piece of geometry in an .egg file without too much difficulty.

yes i confirm that bam maybe can we do this

If I have understood correctly, with bam may be it’s possible ?
would there be an example ?

I don’t want use pre-calculating with blender, i prefer real time in engine.

A performant compromise solution is to pre-model the fragment models for your destructible entity in blender and then pre-load both their render geometry and bullet collision geometry and attach them to dormant bullet rigid bodies (either on startup or when you load a new scene if you game is too big to fit into memory altogether). When the original entity is “destroyed”, the render and collision geometry (and rigid body) that represents the intact entity are removed from the scene and at the exact same frame the pre-loaded but dormant fragments are placed where the intact entity used to be and they are activated. You can also give the rigid bodies of the new fragment entities impulses to scatter them away from each other (to simulate weak or violent explosions) plus the momentum vector of the original intact entity (if it was moving to begin with) plus some of the velocity vector of any projectile or force that hit the original entity to cause it to be destroyed. And because each fragment is represented by a full bullet rigid body, it will continue to be influence-able by any environmental forces you want to simulate, like wind or the fragment hitting the ground or hitting nearby objects.

So it is much more dynamic than importing a destruction animation, but how the fragmentation occurs is still predetermined.

ok thanks for your explanation but i can not find anything in panda3d documentation to be able to do this.
Can you help me please ?

The panda documentation won’t tell you how to do exactly this, but it is trivial to do yourself with your own code once you know the basics that indeed are covered by the panda documentation. These are:

How to load a model and its textures while storing the returned NodePath in your code.
How to get/set the position/orientation of an instance of a model or rigid body by its NodePath.
How to attach and detach NodePaths.
How to create/combine a bullet rigid body and collision shape and get its NodePath.
How to apply impulses to a rigid body.
How to add and remove rigid bodies.

You will need to know how to do all these things to use panda and bullet together at all in the first place, but then once you know that much you can easily create dynamic destructible objects. Because destruction is no more complicated than removing one big thing and adding several smaller things of the same kind to replace it.