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)'
walls.setCollideMask(arenaCollideMask)

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)'
walls.show()

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

render.find('**/+CollisionNode').show()

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


base.cTrav.showCollisions(render)

David

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:


render.findAllMatches('**/+CollisionNode').show()

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:


base.cTrav.hideCollisions()

David

Hello,
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')
        self.arenaCollNode.addSolid(self.arenaGeom.getNode(0))
        self.fullArenaPath=self.environ.attachNewNode(self.arenaCollNode)
        #self.fullArenaPath=self.environ.attachNewNode(self.arenaGeom)
        self.fullArenaPath.show()
        self.fullArenaPath.getNode(0).setIntoCollideMask(self.floorMask)

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…
[/code]

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')
self.arenaGeom.setCollideMask(self.floorMask)

David