pyODE integration (ball joints example)

For all you people who wanted physics integrated:




import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.interval.IntervalGlobal import *
from direct.gui.DirectGui import *
from direct.showbase.DirectObject import *

import sys, os, random, time
from math import *


import direct.ode as ode

world = ode.World()
world.setGravity((0, 9.81, 0))

#1st obj
body1 = ode.Body(world)
M = ode.Mass()
M.setSphere(2500, 0.05)
body1.setMass(M)
body1.setPosition((1,2,0))

#2nd obj
body2 = ode.Body(world)
M = ode.Mass()
M.setSphere(500, 0.05)
body2.setMass(M)
body2.setPosition((2,2,0))

#joint1 (static)
j1 = ode.BallJoint(world)
j1.attach(body1, ode.environment)
j1.setAnchor((0,2,0))

#joint2 (body1, body2)
j2 = ode.BallJoint(world)
j2.attach(body1, body2)
j2.setAnchor((1,2,0))

fps = 50
dt = 1.0 / fps
loopFlag = True


#create the sphere
sphere1 = loader.loadModel("misc/sphere")
sphere1.setScale(.1)
sphere1.reparentTo(render)
#and the second sphere
sphere2 = loader.loadModel("misc/sphere")
sphere2.setScale(.1)
sphere2.reparentTo(render)





def simulate(task):
    sphere1.setPos(body1.getPosition()[0], body1.getPosition()[1], body1.getPosition()[2])
    sphere2.setPos(body2.getPosition()[0], body2.getPosition()[1], body2.getPosition()[2])
    print sphere1.getPos()
    world.step(dt)
    return Task.cont

taskMgr.add(simulate, "runSim")
run()

*copy pyODE to the src/direct folder

pyode.sourceforge.net

enjoy!

miel

OK, Im stumped…

I very much want to use PyODE in my projects. Unfortunately, I have no idea how to install and configure it?

Can someone please give me a boost?

never mind, I figured it out…

You have to download both Python 2.4.3 and PyODE and Install Python first

Can someone please give me a boost?