[Solved] unexpected addForce behavior

Stoo

11-09-2007 18:03:09

I'm still new to Ogre, so I may be missing something obvious -

I've got the following callback defined (Python, sorry guys!):

def thrustCallback( self, body ):
body.addForce(body.getVelocity())
bodpos, bodorient = body.getPositionOrientation()
print bodpos, 'vel = ', body.getVelocity(),
if bodpos[0] > bodpos[1]:
body.addForce(bodorient * Ogre.Vector3(-2,0,0))
print ', left'
elif bodpos[0] <= bodpos[1]:
body.addForce(bodorient * Ogre.Vector3(2,0,0))
print ', right'


So the boxes start moving along the x-axis until they reach the point where they're as far along the x-axis as they are on the y-axis, and then should start trying to reverse direction.

This callback is used for a series of boxes set vertically at 0,0,0; 0,1,0; ... 0,7,0. The bottom box moves very little, and the box above it moves out a bit, then bounces back - as expected. But the boxes above move, start to slow down, and continuously print 'left' ... but never reverse direction.

Am I bumping into a damping mechanism of some sort? Or misusing a command? Or did I perhaps just misunderstand a function?

chuddle

11-09-2007 18:16:11

The line


body.addForce(body.getVelocity())


is throwing me for a loop. Have you tried without it?

How big is your newton world? Are you leaving the space?

Stoo

12-09-2007 00:33:18

...wow, that was obvious.

Thanks chuddle, that fixed it! I'd been experimenting with something else and didn't get that line deleted; guess I stopped seeing it.