ODE Ray contact position wrong

blackgun

19-08-2007 09:35:09

hi, i want to do same thing like the OgreNewton Demo04_RayCasting --- click and drag some body. but i use ODE not newton. i cast a ray and collect the collision data,but its position is wrong.

i setup a ray test for selecting body ( code in python, easy to read):

#------A Ray code :
start = (-1,1,2)
end = (-1,1,-2)
ray = ode.GeomRay(space, 10)
ray.set(start,end)



#------Ray collision detecting code:

for i in range(space.getNumGeoms()):
geom1 = ray
geom2 = space.getGeom(i)
contacts = ode.collide(geom1, geom2)
if contacts and geom2.placeable():
#print contacts
gpos = geom2.getBody().getPosition()
print "Gpos=", gpos
cpos, normal, depth, geom1, geom2 = contacts[0].getContactGeomParams()
print "Cpos=",cpos, normal
break


but the displayed contact position is wired, this is the output on console:
#-------Cpos is contact position

Cpos= (-1.7109856605529785, 1.7109856605529785, 0.57802879810333252)
Cpos= (-1.7049093246459961, 1.7049093246459961, 0.59018146991729736)
Cpos= (-1.6461362838745117, 1.6461362838745117, 0.70772731304168701)


you know the ray is fixed from start = (-1,1,2) to end = (-1,1,-2), y =1, so all of
Cpos.y should be 1.0
but all Cpos.y are more than 1! :!: :?:

please help me. thanks