Dont know if this would be useful to anyone / there is a better solution. Please provide fixes / feedback if you encounter issues. Converted from c++ code.
[java]
public Vector3f GetUpVector()
{
float x = this.Geometry.getWorldRotation().getX();
float y = this.Geometry.getWorldRotation().getY();
float z = this.Geometry.getWorldRotation().getZ();
float w = this.Geometry.getWorldRotation().getW();
return new Vector3f( 2 * (x * y - w * z),
1 - 2 * (x * x + z * z),
2 * (y * z + w * x));
}
public Vector3f GetForwardVector()
{
float x = this.Geometry.getWorldRotation().getX();
float y = this.Geometry.getWorldRotation().getY();
float z = this.Geometry.getWorldRotation().getZ();
float w = this.Geometry.getWorldRotation().getW();
return new Vector3f( 2 * (x * z + w * y),
2 * (y * x - w * x),
1 - 2 * (x * x + y * y));
}
public Vector3f GetRightVector()
{
float x = this.Geometry.getWorldRotation().getX();
float y = this.Geometry.getWorldRotation().getY();
float z = this.Geometry.getWorldRotation().getZ();
float w = this.Geometry.getWorldRotation().getW();
return new Vector3f( 1 - 2 * (y * y + z * z),
2 * (x * y + w * z),
2 * (x * z - w * y));
}
public Vector3f GetLeftVector(){
return GetRightVector().negate();
}
public Vector3f GetBackwardVector(){
return GetForwardVector().negate();
}
public Vector3f GetDownVector(){
return GetUpVector().negate();
}
[/java]