OgreNewt setCustomForceAndTorqueCallback

MacMan45

05-02-2008 04:29:52

Can someone please help me try to understand how to use this?

I haven't been able to find any python examples that use this, and the docs only show the c++ signature.

Before I go too far, this is the correct way to apply a force / torque to a body in OgreNewt, right?

What I have so far is something like this:

self.mBody.setCustomForceAndTorqueCallback(self, 'forceCallback()')


I have tried it a few different ways, but it just keeps crashing.
The current error is:

'testClass' object has no attribute 'forceCallback()'

I have however defined a "forceCallback" method in the "testClass".

Ultimately I want to make an articulated limb and move it about (like a robotic arm).
if there are better ways to do this, I would really like to know!

illume

05-02-2008 05:06:50

have you tried it without the ()?

Just 'forceCallback'

?

just a guess

MacMan45

05-02-2008 05:12:54

Yeah, that was actually my first test!

I tried the () in desperation!

MacMan45

05-02-2008 05:27:42

I have made some progress.

I have made a callback in my 'physics' class, and called:

self.mBody.setCustomForceAndTorqueCallback(self.mPhysics, 'forceCallback')

with the callback function being:

def forceCallback(self, body):
codehere()



That seems to work for me.

I'm not sure why it can't work across classes, but I guess I can deal with this work around!

EDIT

I figured it out on the train home, I wasn't paying attention to the indentation, the method was defined in the scope of another method! :oops:

All fixed and working fully now!