Object facing/local axes

First let me say that I am very new to jME and jMEPhysics/ODE, but I am an experienced programmer of C/C++/Java/Perl/Ruby, etc…



I was recently trying to impart a force on an object in the same way a spaceship's rear engine would.  That is the force is always given in the same direction as the facing of the craft.  When I created the object the Y axis pointed out the nose of the craft so the local Y axis is the facing.  However, once the craft has been rotated I didn't see any easy way to get the local y axis.  I ended up using something like this:


Vector3f localYAxis = new Vector3f (0.0f, 1.0f, 0.0f);
Quaternion orientation = obj.getLocalRotation();
orientation.multLocal(localYAxis);
localYAxis.multLocal(THRUST);
obj.addForce( localYAxis );



Is that the best way to do it?  I kind of expected there to be some method like this:

Vector3f localYAxis = obj.getLocalAxis(Y_AXIS); // No such method



which would return a unit vector facing along the local Y.  Is there no such method?

Now that I think about it, the existence of such methods might be more of a general jme question than a jmephysics question...

Welcome Skoll !



You're right there's an easier method.



//didn't test this but should be something similiar:
localYAxis = obj.getLocalRotation().getRotationColumn(2);



... and don't tell me this isn't easy to find ... i know that  :)

Thanks winkman.  That does work.  However the y axis is 1.  I suppose



0 is x

1 is y

2 is z



The javadoc on that method could definitely use a little clarification, even if we are expected to have the inner workings of a rotation matrix memorized at all times…