Problem rotating a node

Hey guys,

I have a problem with rotation of a node. The basic thing I want is, that the humanoid (which is my node ;)) looks straight to a given bearing Vector (which is normalized Vector pointing into to direction where the humanoid should look at).

The code I wrote is the following:

   public void setBearing(Vector3f bearing) {
      Vector3f oldBearing = this.getBearing().normalizeLocal();
      if(bearing != null && oldBearing != null){
         Vector3f newBearing = bearing.normalizeLocal();

            float angle = oldBearing.angleBetween(newBearing);
                 Quaternion q = new Quaternion();
            q.fromAngleNormalAxis(angle * -1, Vector3f.UNIT_Z);

The problem is, that I do not know in which direction I have to turn, cause angleBetween always returns 0-PI. So if I click left from the humanoid, the bearing is correct. If I then click right to the humanoid, the bearing is ok (180

Spatial.lookAt() should allow you to point the -Z of your node at any arbitrary point.

So, get your bearing vector.  Add it to your current position.  Do the lookat.

So, do "humanoid.lookAt(worldPosition + bearing, Vector3f.UNIT_Z);"

Alternatively, there seems to be a Quaternion.lookAt() that takes a direction (not a global position) and an up vector.  You could easily do

"myQuaternion.lookAt(bearing, Vector3f.UNIT_Z);" to get a rotation from a bearing.  You would then need to appropriately concatenate the transforms, depending on whether or not the localRotation == globalRotation.