Pergunta

public void changeAx(double value) {
    translateAx.set(new Vector3f(0f, -0.325f, 0f));
    trans.setTransform(translateAx);
    rotation1.rotY(value);
    rotation.mul(rotation1);
    rot.setTransform(rotation);
    translateAx.set(new Vector3f(-0.2f, -0.325f, 0f);
    trans.setTransform(translateAx);
}

This is the method that is not working. I want to rotate object on the X axis. I translate the objects X axis position back to the origin. I then perform the rotation and then translate the object back to the position it should be at. However the object rotates as if the first translation has not been made. This means that it does not rotate as if it is sitting on the origin but as if it is -0.2f away from it and thus the entire object moves around with a -0.2f radius, but I want it to stay in the same translation when it rotates. I want to know what I'm doing wrong in the code that is messing with the rotation.

For the record, if I take out the second (re-translation) the object will move to the X origin and rotate correctly, but I want to move it back to where it should be afterwards, and this is messing the rotation up.

Foi útil?

Solução

Try this changed first line for translating the object's X axis position to the origin:

    translateAx.set(new Vector3f(0.2f, -0.325f, 0f));
August

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top