How to define Arbitrary Collision Node?

Hello All,

I 'm wondering if it’s possible to set an arbitrary geometry as a collision node.

My need is the following:

I’ve got my arena full_arena.egg (detailled and so on)
i’ve got a simplyfied arena arena_collide.egg (which is less detailled but cannot be resume to
one sphere or one cube).
I would like to inform the collision system that arena_collide is the collision node for full_arena.

Is it possible in Panda on python side?
or is it to be done in eggfile?

I’m rather stuck with this right now :frowning:

Ok i 've done the "ObjectType Barrier " trick in my egg file.
So now i’ve got one egg file that contains a full_arena group and a arena_collide group which is a “Barrier”.
But how do i access from python the arena_collide group to set it’s collision mask for example?
and how do i show the collisionnodes that have been created from my arena_collide model?

You can set the collide mask in the egg file, something like this:

<Group> arena_collide {
  <Scalar> collide-mask { 0x01 }
  <ObjectType> { barrier }

You can even define your own object types that have a particular collide-mask built into them. You can do this in your Config.prc file, like this:

egg-object-type-arena      <Scalar> collide-mask { 0x04 } <ObjectType> { barrier }

Then when you put an object type of “arena” in your egg file, it means a barrier with collide mask 0x04.

Or, you can also set the collide mask in Python code, something like this:

arena = loader.loadModel('arena.egg')
walls = arena.find('**/arena_collide)'

If you want to show the collision nodes, you just find them like any other node and use the show() method (collision nodes are hidden by default):

walls = arena.find('**/arena_collide)'

There’s a clever trick we use sometimes to show all the collision nodes under render at once:


You can also show just the nodes that are actively being tested for collisions:



Wow i’ll test all at once :slight_smile:

I realized I had the wrong method call for this one. To show all collision nodes, not just the first CollisionNode found, you need to do this:


All of the show() calls have a corresponding hide() call to go back to the normal hidden state. To turn off the result of base.cTrav.showCollisions(render), use:



I’ve tested now i see my “barrier” in pview hierarchy list and also if i ask pview to report collision surface.
Also the barrier is non visible by default, This is perfect.
However i’m still not able to attach the Collision node and to set flag on it.
I’ve tried:

 self.arenaGeom = self.environ.find('**/Scene_Root/ArenaCollide')
        self.arenaCollNode = CollisionNode('Arena_Collide')

and i’ve got the following error message:

TypeError: Invalid argument 0, expected

So i’m still confused.

I know i’m pretty dumb on this case but…

You are doing more code than you need to do. You are perhaps following examples that show how to set the collide mask for geometry that is created completely on-the-fly, but for geometry that you load from a file, you don’t need to do all that stuff.

Just do this:

self.arenaGeom = self.environ.find('**/Scene_Root/ArenaCollide')