Spatial heading

I know this is basic 3d math, but I'm a bit confused.

These are my questions:

  1. Is there a way to retreive the heading vector of a spatial or I do I have to use my own variable for each entity?

      Is it:



      Vector3f heading = spatial.getLocalRotation().getRotationColumn(2, new Vector3f());


  2. How can I apply a new heading to a spatial?
  1. this obviously depends on where your spatial actually 'heads' while it's not rotated. Generally you get it's heading by

spatial.getWorldRotation().mult( unrotatedHeadingVector )

2) you can simply use Spatial.lookAt - but be aware that it again depends on that unrotatedHeadingVector what you have to specify as parameter values

What do you mean by an unrotatedHeadingVector? Is unrotatedHeadingVecto the desired heading and

spatial.getWorldRotation().mult( unrotatedHeadingVector )

is the actual heading?

unrotatedHeadingVector is the direction that the object would move if it would not rotate. It normally is the direction to the front of the object. 

So where do I derive an unrotatedHeadingVector from, or is it something that I set manually

as an entity's parameter?

Yes, it's on you to decide that - e.g. could be new Vector( 0, 0, 1 ) if the face of your model points into z-axis direction.

Okay, thanks for the help!

I think I got it now… :expressionless: