I have two objects made in Maya with collision cubes created around the existing model and barrier flags set on them.
I want to create a pusher with events as I’ve done below, but I’m not getting collisions. Do I need to bitmask the invisible collision cubes that I’ve set?
fromObject = objectNode.attachNewNode(CollisionNode('colNode'))
# sphere to test collision, but now I want my collision geometry from my egg insetad
#sphere = CollisionSphere(-27,0,-3, 2.5) #not used
#fromObject.node().addSolid(sphere) #not used
base.cTrav = CollisionTraverser()
base.cTrav.showCollisions(render)
base.pusher = CollisionHandlerPusher()
base.pusher.addInPattern('into-fromObject')
base.pusher.addAgainPattern('again-fromObject')
base.pusher.addOutPattern('outof-fromObject')
base.cTrav.addCollider(fromObject, base.pusher)
base.pusher.addCollider(fromObject, objectNode)
base.pusher.setHorizontal(False)
o = DirectObject()
o.accept('into-fromObject', collideInto) #func calls
o.accept('outof-fromObject', collideOutof)
o.accept('again-fromObject', collideAgain)
My next question is if I were to switch to ODE based collisions, does it support the barrier flags that I setup or do I just have to create my own collision geometry within Panda / ODE?
I don’t see you adding the collision geometry from your egg file to your fromObject. Are you sure you’re doing this somewhere in your code?
Also, note that if you use the ‘barrier’ flag in Maya, you will get a CollisionPolygon mesh. This kind of mesh cannot be used as a “from” object anyway. Neither, I think, can a CollisionBox object. You pretty much have to have a CollisionSphere for a “from” object, unless you want to go with segments or lines.
No, all that does is set the into mask on your geometry, which is appropriate when detecting collisions into your geometry (that is, using it as a “to” object). To use your geometry as a “from” object, you have to actively add it to your fromObject CollisionNode that you are using with your traverser, something like this:
colGeom = myNode.find("**/myCollision")
for solid in colGeom.node().getSolids():
fromObject.addSolid(solid)
But this won’t work anyway unless it is already a CollisionSphere.
Nope, but anyone who wants to write the intersection test needed to make them work is more than welcome to.
Yes, but you need to use the “sphere” tag in Maya, rather than the “barrier” tag, to make a CollisionSphere. Otherwise you will make a bunch of CollisionPolygons that happen to be arranged in the shape of a sphere.