Hi,
how can I rotate a simple Box around its y axis? The thing is I moved the Box to another LocalTranslation. Nevertheless the rotation is done around my defined rotation axis (0,1,0) which is still related to the origin 0,0,0
and not to the center of the box. How to do a rotation around the center of the box? Simliar like the rotation of the earth within 24h
private Quaternion rotQuat = new Quaternion();
private float angle = 0;
private Vector3f axis = new Vector3f(0,1,0);
box = new Box( "Box", new Vector3f(0,0,-20), 5, 6, 5);
box.setLocalTranslation(new Vector3f(15,5,5));
@Override
public void update(float tpf)
{
if (tpf < 1) {
angle = angle + (tpf * 2);
if (angle > 360) {
angle = 0;
}
}
rotQuat.fromAngleAxis(angle, axis);
box.setLocalRotation(rotQuat);
}
I use the StandardGame design and its part of a menu GameState.