hi
just trying to make something simple with ode, a ball dropping onto a
plane.
Any hints?
Ive pasted the code at the end but the obj seems to move on both the z
and y axis. printing x,y,z of by obj i get:
0.0 10.0 0.0
0.0 9.99871444702 0.199933379889
0.0 9.99614334106 0.399866759777
0.0 9.99228572845 0.599800169468
0.0 9.98714256287 0.799733579159
0.0 9.9807138443 0.99966698885
0.0 9.97299957275 1.19960033894
0.0 9.9634847641 1.39953374863
0.0 9.95217037201 1.59946715832
0.0 9.93905639648 1.79940056801
0.0 9.92414188385 1.9993339777
0.0 9.90742778778 2.19926738739
import soya
from soya import ode
soya.init()
soya.path.append('data')
scene = ode.World()
scene.gravity = (0., -2., 0.)
space = ode.HashSpace(scene)
floor = ode.GeomPlane(scene, space)
shape = soya.Shape.get('caterpillar_head')
obj = ode.Body(scene, shape = shape)
mass = ode.Mass()
mass.setSphere(1., 1.)
mass.adjust(1.)
obj.mass = mass
geom = ode.GeomSphere(obj, space, 1.)
obj.set_xyz(0, 10, 0)
camera = soya.Camera(scene)
camera.z = 10
camera.y = 1
camera.look_at(obj)
soya.set_root_widget(camera)
cg = ode.JointGroup()
def near_callback(g1, g2):
contacts = ode.collide(g1, g2, 20)
for contact in contacts:
joint = ode.ContactJoint(scene, cg, contact)
joint.attach(g1.body, g2.body)
class Idler(soya.Idler):
def begin_round(self):
cg.empty()
space.collide(near_callback)
soya.Idler.begin_round(self)
print obj.x, obj.y, obj.z
Idler(scene).idle()
dunk