i have a very simple controller, which makes a node look at a target to change its rotation and move towards him.
As you see in the sysout's from time to time the WorldRotation of the Node, where the controller is attached to, is not up to date.
Without the myself.updateWorldVectors() the lookAt will rotate the node into the wrong direction.
class MyController extends Controller {
private Node target = null;
private Node myself = null;
public MyController(Node myself, Node target) {
this.target = target;
this.myself = myself;
}
public void update(float time) {
System.out.println("my local translation: " +myself.getLocalTranslation());
System.out.println("my world translation: " +myself.getWorldTranslation());
myself.updateWorldVectors(); <---- this is needed
myself.lookAt(target.getLocalTranslation(), Vector3f.UNIT_Y);
node.getLocalRotation().getRotationColumn(2).mult(speed*time));
}
}
my world translation: com.jme.math.Vector3f [X=0.0, Y=20.0, Z=100.0]
my local translation: com.jme.math.Vector3f [X=0.0, Y=20.0, Z=100.0]
my world translation: com.jme.math.Vector3f [X=0.0, Y=20.0, Z=100.0]
my local translation: com.jme.math.Vector3f [X=0.0, Y=20.0, Z=100.0]
my world translation: com.jme.math.Vector3f [X=0.0, Y=20.0, Z=100.0]
my local translation: com.jme.math.Vector3f [X=0.0, Y=20.0, Z=100.0]
my world translation: com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]
my local translation: com.jme.math.Vector3f [X=0.0, Y=20.0, Z=100.0]
my world translation: com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]
my local translation: com.jme.math.Vector3f [X=0.0, Y=20.0, Z=100.0]
my world translation: com.jme.math.Vector3f [X=0.0, Y=0.0, Z=0.0]
my local translation: com.jme.math.Vector3f [X=0.0, Y=20.0, Z=100.0]
my world translation: com.jme.math.Vector3f [X=0.0, Y=20.0, Z=100.0]
In the Spatials.updateWorldData() the controllers are first updated and then the WorldVectors.
I guess that makes sense, since the controllers moves the node and later the world vectors need to be updated.
What i wonder is, do i always need to call updateworldVectors() to be sure they are up to date?