NxOgre crash?

Megaton

24-10-2007 22:56:08

I'm having a strange problem with NxOgre.

I'm trying build a simple application just to learn the basics and I need to perform rotation on two axis'. I should be able to do this with Quaternions, by just multiplying them, correct?

Every time I do this, Python crashes. I tried to narrow the problem down and discovered that the Quaternion multiplication crashes Python if I have NxOgre imported.

The program below runs and 'rot' is the resulting Quaternion of both rotations.

import ogre.renderer.OGRE as ogre
import ogre.physics.PhysX as PhysX

q1 = ogre.Quaternion(ogre.Degree(15), ogre.Vector3.UNIT_Y)
q2 = ogre.Quaternion(ogre.Degree(15), ogre.Vector3.UNIT_X)
rot = q1 * q2

print rot


The problem is, when I import NxOgre and run the same program Python crashes. Here is the program for comparison:

import ogre.renderer.OGRE as ogre
import ogre.physics.PhysX as PhysX
import ogre.physics.NxOgre as nxogre

q1 = ogre.Quaternion(ogre.Degree(15), ogre.Vector3.UNIT_Y)
q2 = ogre.Quaternion(ogre.Degree(15), ogre.Vector3.UNIT_X)
rot = q1 * q2

print rot


Can anyone else confirm the same problem? I'm using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on
win32 and installed PythonOgre_1.1.exe

The error I get is an Unhandled exception in python.exe: Stack overflow

I can run the other python nxogre demos just fine and my program (a pinball simulator) was working correctly up to the point where I tried to perform Quaternion multiplication.

andy

25-10-2007 01:20:19

I suspect it's related to some implicit conversions I implemented in NxOgre (and shouldn't have) and I'll look into it further

Andy

Megaton

25-10-2007 10:08:24

Thanks for looking into it Andy.

In the meantime, do you (or anyone else) know perhaps of a workaround I can use to get this working?

Basically, what I need is pose an nxogre body. For this I need both a vector for the position and a quaternion for the orientation. I want the body to be first rotated around the Y axis and then around the X axis. I'm new to all this 3D math and just saw that with Quaternions you should be able to multiply them to get a new quaternion that has both rotations applied, in order.

Any help would be appreciated :)

andy

25-10-2007 11:42:26

Here's an ugly work around until I release 1.1.d
def QuaternionMulti (q1,q2):
return Ogre.Quaternion(\
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z,
q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y,
q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z,
q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x )

Cheers
Andy

Megaton

25-10-2007 13:50:55

Thanks Andy!

That ugly workaround worked beautifully.

bharling

25-10-2007 15:34:20

You could also just apply 2 seperate transformations to end up at the right orientation, but applying a single quaternion transform is probably more efficient, as you are doing...