Search code examples
panda3d

How to use loaded model as collide solid in Panda3D?


I am new to panda3d, and I'm currently working on a small project which needs to make collision detection on customized models. In panda3d manual and sample projects, I can only find instructions on how to attach panda3d predefined collide solid(such as CollisionSphere). But what I am considering is how to use the loaded model(such as egg file) as an into object, is there any sample code on that?


Solution

  • The best way to do this is to tag the .egg model such as to let the .egg loader automatically generate "into" collision polygons. If you exported your model from Blender, this can be done by adding a string Game property in the Logic panel called "Collide" and setting it to Polyset keep descend for the models in question. Otherwise, you can edit the .egg file in a text editor and add the tag <Collide> { Polyset keep descend } under the desired <Group> entry. This method is being used by the Roaming Ralph sample program.

    Instead of having the .egg loader construct these specialised collision polygons, you can alternatively tell Panda3D to treat the visible geometry as "into" collision geometry. This will be slower than the above method. You can enable this by calling setCollideMask(...) with the desired "into" collision mask on the model in question.

    You cannot use arbitrary geometry as "from" solid, I'm afraid.