ODE Middleware

Ok, here’s a working version:

""" 
Create a box 
""" 

box = loader.loadModel("box") 
box.setPos(0,-6.0,2.0) 
box.reparentTo(render) 
#box.flattenLight() -- don't use.
    
boxBody = OdeBody(self.worldManager.world) 
M = OdeMass()
M.setBoxTotal(5.0, 1.0, 1.0, 1.0)
boxBody.setMass(M) 
boxBody.setPosition(box.getPos(render)) 
boxBody.setQuaternion(box.getQuat(render)) 

# Create a BoxGeom 
boxGeom = OdeBoxGeom(self.worldManager.space, Vec3(1.0, 1.0, 1.0))
boxGeom.setCollideBits(BitMask32(0x00000122)) 
boxGeom.setCategoryBits(BitMask32(0x0000111)) 
boxGeom.setBody(boxBody) 

boxData = odeGeomData()
boxData.name = "box"
boxData.isTrigger = False
boxData.surfaceFriction = 0.1

self.worldManager.setGeomData(boxGeom, boxData, box)

And a little bit of explanation.

I use setBoxTotal because it feels better for me, but I’ve tried setBox and it should work as well (with correct values).

Don’t use flattenLight. I don’t know why, and I don’t know if it’s the fault of my code of whatever else, but it seems to produce completely unstable results.

Also, for dynamic stuff try to use meshes that have centers in the middle. The “box” mesh that comes with Panda (with that colorful texture) doesn’t, so to see the difference you can use this: dl.dropbox.com/u/196274/companion_cube.egg

And try to use built in shapes for dynamic stuff. In some cases it might not make any difference, but trimesh is not the best (not the most stable) choice here.

Check it and inform me of the result.