Tuesday, April 16, 2024
HomeSample Page

Sample Page Title


I’ve a category that manipulates a mannequin matrix in opengl:

class ModelObject {
personal:
    mat4 ScaleMatrix;
    mat4 RotationMatrix;
    mat4 TranslationMatrix;

public:
    vec3 angles;
    float measurement;
    vec3 pos;
    . . .
}

I’ve a perform that rotates object round its native axises

void rotateLocal(vec3 euler_angles)
{
    quat qY = angleAxis(euler_angles.y, getUpv());
    mat4 rY = toMat4(qY);
    RotationMatrix = rY * RotationMatrix;
    quat qZ = angleAxis(euler_angles.z, getFrontv());
    mat4 rZ = toMat4(qZ);
    RotationMatrix = rZ * RotationMatrix;
    quat qX = angleAxis(euler_angles.x, getRightv());
    mat4 rX = toMat4(qX);
    RotationMatrix = rX * RotationMatrix;
}

But I can’t work out easy methods to make it change angles property accurately. Many formulation that calculate closing euler angles don’t work correctly. Here is one other perform that additionally rotates object, however round world axises

void rotate(vec3 angles)
{
    mat4 newRotation = toMat4(quat(angles));
    RotationMatrix = newRotation * RotationMatrix;

    this->angles += angles;
}

I would like rotateLocal additionally to be syncronized with angles

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments