Mesh Collider

Hi everybody.

I’m developing my first project using Panda3D. I’d like to know if there is a way to implement collisions using the whole mesh of my 3D model instead of collision solids.

thank you

Using Panda’s built-in collision system, you can make any visible mesh be an “into” collision solid by setting the appropriate collide mask on it. This is usually a terrible idea, because visible geometry is not optimized for collisions, and is usually much more dense than you really want for collisions on top of that, so it runs really really slowly.

A better choice may be to copy the mesh to collision solids and test with that. This will be much faster than colliding with visible geometry directly. You can do this by simply setting the appropriate flags in your egg file. Of course, it’s still probably too dense, so it will still run slowly.

You cannot make a visible mesh be a “from” collision solid; you still have to use a CollisionRay or CollisionSphere for this purpose.

Using bullet or ODE, you can copy the mesh into the native bullet or ODE structures, but you’d have to do this anyway. I don’t have the details on this.


thank you for your answer

How can I set flag in my egg file? I tried to put collider (or collision, I don’t remember) flag in my egg file but nothig happened.

Additional information about my project.

I don’t need pyhsic, I need only to check if collisions between two 3D model occur

Can you generate a collision mesh from a nodepath, like after loading from the egg file? Sounds like you can for Bullet, but what about Panda’s collision system?

Usually, the way to make polygons into collision polygons is to put " { polyset keep descend }" within each that contains polygons you want to do this for, as described in (for instance) this thread. Note that this works only for static models, it doesn’t work for animated actors models.

You can press shift-C when viewing your egg file in pview to confirm that the change had the desired effect. Shift-C in pview will reveal hidden collision polygons.

You can iterate through the triangles in the GeomNodes and do this yourself, but there’s nothing built-in to do it for you.


Edit: the model is not static. I could create a collision solid from a static version of the model and parent it to the Actor

I’m trying to use ODE collision, it works with the static model
Is there a way to make Ode Collision Geometry visible? How can I understand if the Geom is correct without seeing it?

Anyway my question is: my model is not static, so if I parent the actor (non-static model) and the collision solid what happen when I move my model? If I move the leg of the model the collision solid follow the moved leg or I should create different collision solid for each movable joint of the Actor?

thank you

I’m not that familiar with the Ode integration, but I don’t think there’s a debug visualizer. I guess you could write your own such thing by iterating through the vertices and creating corresponding geometry in Panda.

You will have to expose the relevant joints (for instance, the leg joint) and parent the collision solid to that exposed joint, as demonstrated in (for example) the "Looking and Gripping) sample program. You will need to repeat this for each individually movable piece that you want to test for collisions.

This is not a particularly efficient way to do collision testing, though–many games get by with just a single sphere or capsule around the whole model–but if you really do need individual joint-based testing, it’s probably the only way.


Yes, I need joint-based testing. It’s not efficient but I have only one complex model and few simple models in the scene a very simple environment, so I hope it will work :slight_smile:

Last question:
I created the collision solid from the egg file, and it works because I can see it on pview (c-shift). Now I’d like to load it into the scene and make it visible, this is my code:

self.robotCollision = loader.loadModel("models/eggcompleterobotCollisionStatic")
self.robotCollision.setPos(Point3(self.cameraInitPos.getX(), self.cameraInitPos.getY() + 25, self.cameraInitPos.getZ()))
		self.c = self.robotCollision.find("**/character")
		print self.c

it doesn’t work, I cannot see the collision solid, any suggestion?

thank you

You can’t just show the root node. You have to find the individual CollisionNodes and show them if you really want to see them.




Thank you for all your useful suggests.
I solved my problem.
Here is the correct code:

# Load Collision Solid
		self.robotCollision = loader.loadModel("models/eggcompleterobotCollisionStatic")
		# show collision solid
		self.collisionNode = self.robotCollision.find('**/+CollisionNode')
		print self.collisionNode