this.useViewDirection = viewDirectionEnabled;
}
public void update(float tpf) {
if (enabled && spatial != null) {
Quaternion localRotationQuat = spatial.getLocalRotation();
Vector3f localLocation = spatial.getLocalTranslation();
if (!applyLocal && spatial.getParent() != null) {
getPhysicsLocation(localLocation);
localLocation.subtractLocal(spatial.getParent().getWorldTranslation());
localLocation.divideLocal(spatial.getParent().getWorldScale());
tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
spatial.setLocalTranslation(localLocation);
if (useViewDirection) {
localRotationQuat.lookAt(viewDirection, Vector3f.UNIT_Y);
spatial.setLocalRotation(localRotationQuat);
}
} else {
spatial.setLocalTranslation(getPhysicsLocation());
localRotationQuat.lookAt(viewDirection, Vector3f.UNIT_Y);
spatial.setLocalRotation(localRotationQuat);
}
}
}