Panda3D and Bullet physics

Hi I Hope you are having a good day.

  1. How does one use a 3d model imported from a modeling package(blender) as a Bullet physics collision solid?

  2. How does one use a model as both visual geometry and a collision solid?

  3. How to add an imported model to the Geom node?

(The manual describes how to use Bullet’s primitive collision solids but the use of complex collision solids is not described well.)

Thanks Any Help will be greatly appreciated.

Hi! I think that some of these topics are already covered in Bullet’s samples (you can find the link at the beginning of the page). I found these samples very useful for starting with Bullet, they are very good for learning imho.

The bullet samples do not work I have already tried running them they have quite a few errors.
Is it possible to use the animated mesh as its own collision mesh.
so the bullet physics wireframe(the debugging frame) must follow the animation.
Basically physics on an against an actor.
If the above is possible, how is it done?

In fact, this is done differently, create a simplified model of physics.


These hitboxes are tied to the position of the bones.

@serega-kkz
Thanks .
I am aware of the hit_box method but I was wondering it is possible to physics on the animated geometry it self.
it would be better for prototyping.

Hmm, updating physics for an animated model is expensive for resources. Although, maybe, I did not understand what you were talking about.

An example that answers your questions in the topic.

from direct.showbase.DirectObject import DirectObject   
import direct.directbase.DirectStart
from direct.actor.Actor import Actor
from pandac.PandaModules import *
from panda3d.bullet import BulletRigidBodyNode  
from panda3d.bullet import BulletTriangleMesh
from panda3d.bullet import BulletTriangleMeshShape
from panda3d.bullet import BulletDebugNode 
from panda3d.bullet import BulletWorld

base.cam.setPos(0, -3000, 0)

debugNode = BulletDebugNode('Debug')   
debugNP = render.attachNewNode(debugNode)   
debugNP.show()

world = BulletWorld()     
world.setDebugNode(debugNP.node())
world.setGravity(Vec3(0, 0, -9.81))

pandaActor = Actor("models/panda-model", {"walk": "models/panda-walk4"})
pandaActor.reparentTo(render)
pandaActor.loop("walk")

geom = pandaActor.findAllMatches('**/+GeomNode')[0].node().getGeom(0)

mesh = BulletTriangleMesh()
mesh.addGeom(geom)
shape = BulletTriangleMeshShape(mesh, dynamic = False)
nodeBox = BulletRigidBodyNode('Panda')
nodeBox.addShape(shape)
nodeBox.setMass(0)
nodeControlBox = render.attachNewNode(nodeBox)
world.attachRigidBody(nodeBox)

def update(task):
  world.doPhysics(globalClock.getDt())
  return task.cont
taskMgr.add(update, 'update')

base.run()

I agree that the documentation is terse on this issue.

@serega-kkz
Thanks a lot.
The above code creates a physics objects from the animated mesh but the physics object isn’t updated as the mesh is animated i.e the physics object remains static while the mesh moves its legs.
So if for example the panda was suppose to kick a ball, the panda’s leg would still go through the ball.

I appreciate the help.

Oh, hell, you really need a collision with the animation grid … I tried to convince myself that it seems, but it turned out to be true. :slight_smile:

You actually have to rebuild the collision grid, every frame. But the problem is that the geometry data is taken from the stored vertices in the file. You need to get the vertex of the actual actor and recreate the collision of the grid. The problem is that I do not know how to get the actual vertices of the actor during the animation.

As I said, it’s very expensive, and ridiculous. Therefore hitboxes as a solution.

Thanks for the Help.
I guess I am stuck with hit _box system, please let me know if you ever come across a solution.
Thanks and cheers!

one question is panda work great with any 3d model app?i find some android app to make 3d ,this panda accept any 3d format?thanks

https://www.panda3d.org/manual/index.php/Supported_Model_Formats

https://www.panda3d.org/manual/index.php/Features

1 Like

thanks for help, sorry the english not my native language but for example the format .obj work direct or need to be convertef?

There are multiple ways to load .obj files, but the way with most control over the process is to import the .obj file into Blender and then exporting it to .egg via YABEE.

1 Like

but without pc you not know any apk app to convert?thanks because not have pc