Why is this variable a Radian?


10-04-2011 01:37:29

I've worked a little bit to convert the Sindbad character sample that ships with OGRE into Python-OGRE; let me know if you would like me to upload the full source that I have come out with. I have been having some problems with the program, namely an error in the terminal saying, "*** glibc detected *** python: malloc(): memory corruption: 0x0ace6538 ***", and by commenting calls to updateCameraGoal and updateCamera, at least the program will run, albeit with other problems.

I really think that the first error is some flaw in the way I did the cameras, (I just pick and chose what I thought would work from SdkSample.h because I didn't deem all 500+ lines of that necessary just for the Character sample)

For now, however, I get the following when I try to press W:
line 537, in _updateBody
yawToGoal = OGRE.Math.Clamp(yawToGoal, 0.0, yawAtSpeed)
Boost.Python.ArgumentError: Python argument types in
Math.Clamp(float, float, Radian)
did not match C++ signature:
Clamp(float val, float minval, float maxval)

I do not understand how yawAtSpeed is a Radian though, yawAtSpeed = yawToGoal / OGRE.Math.Abs(yawToGoal) * timeSinceLastUpdate * self.TURN_SPEED


10-04-2011 17:53:32

This is a long standing issue with python-ogre and the Ogre.Math functions, in this instance Ogre.Math.Abs returns a radian:

>>> yawgoal = 10.0
>>> x = ogre.Math.Abs(yawgoal)
>>> type(x)
<class 'ogre.renderer.OGRE._ogre_.Radian'>
>>> type(x.valueRadians())
<type 'float'>
>>> x.valueRadians()

So you can either use the valueRadians() to return a float or even easier just import the math module and use abs().