ODE understanding help

Hey everyone… I’m trying to understand ODE… I have this so far:


    #Setup our physics world 
#    self.World = OdeWorld() 
#    self.World.setGravity(0, 0, -9.81)

    #Nexts add our Environment model
#    self.EnvironmentBody = OdeBody(self.World)
#    M = OdeMass()
#    M.setSphere(5000, 1.0)
#    self.EnvironmentBody.setMass(M)
#    self.EnvironmentBody.setPosition(self.Environment.getPos(render))
#    self.EnvironmentBody.setQuaternion(self.Environment.getQuat(render))

    #Nexts add our player model
#     self.PlayerBody = OdeBody(self.World)
#     M = OdeMass()
#     M.setSphere(1000, 1.0)
#     self.PlayerBody.setMass(M)
#     self.PlayerBody.setPosition(self.Player().getPos(render))
#     self.PlayerBody.setQuaternion(self.Player().getQuat(render))

Not sure if it’s right or not due to that I can’t really test it just yet, and plus I know it can’t be right:)

Anyways… I’m using panda collision atm, so not sure what I have to change to what to actully get the same results (or better I’m hopping) or what code I can reuse from both of them…

    #Setup the collision manager.
    base.cTrav = CollisionTraverser()
    base.cTrav.setRespectPrevTransform(True)
    #Pusher.
    base.pusher = PhysicsCollisionHandler()
    #Collision queue, this is for collision even.
    base.handlerQueue = CollisionHandlerQueue()
    #Setup the collision event handler.
    base.handler = CollisionHandlerEvent()
    base.handler.addInPattern('into-%in')
    base.handler.addOutPattern('outof-%in')
    #Enable built in physics.
    base.enableParticles()

    #Set up the gravity force.
    self.gravityFN=ForceNode('world-forces')
    self.gravityFNP=render.attachNewNode(self.gravityFN)
    self.gravityForce=LinearVectorForce(0,0,-9.81)
    self.gravityFN.addForce(self.gravityForce)

    #Attach it to the global physics manager.
    base.physicsMgr.addLinearForce(self.gravityForce)

    #Add the actor node and or collision node to the pusher and to the collision manager.
    base.pusher.addCollider(self.Player.CnodePath(), self.Player(), base.drive.node())
    base.cTrav.addCollider(self.Player.CnodePath(), base.pusher)

    #Attach it to the global physics manager.
    base.physicsMgr.attachPhysicalNode(self.Player().node())

    #Collision ray for our Weapon.
    self.pickerNode=CollisionNode('mouseRay')
    self.pickerNP=self.Player().attachNewNode(self.pickerNode)
    self.pickerNode.setFromCollideMask(BitMask32.bit(8))
    self.pickerNode.setIntoCollideMask(BitMask32.allOff())
    self.pickerRay=CollisionRay(0,0,0,0,1,0)
    base.cTrav.addCollider(self.pickerNP, base.handler)
    base.cTrav.addCollider(self.pickerNP, base.handlerQueue)
    self.pickerNode.addSolid(self.pickerRay)

  def CleanUpCollision(self):
    self.gravityFNP.removeNode()
    base.physicsMgr.removeLinearForce(self.gravityForce)
    base.pusher.removeCollider(self.Player.CnodePath())
    base.cTrav.removeCollider(self.Player.CnodePath())
    base.cTrav.removeCollider(self.pickerNP)

My models have their collision, so this whole “.setCollisionX” seems a bit strange to me…

This is not that hard but we will not do it for you. Basically how ODE and internal panda3d Collision setup is very different. I recommend you read how you do stuff in both. For my game i use both. I use ODE for every frame things and panda3d picking ray for selection objects it seems to be eiser to setup then ODE.