OpenGL3 围绕自身中心旋转对象

OpenGL3 Rotate object around itself center

我将尝试在 openGL 中旋转对象(使用 OpenTK 框架),但他围绕零点旋转。从逻辑上讲,物体绕中心旋转,但我不知道他应该如何绕自己的中心(或其他点)旋转

    public static void Texture(Region region, float x, float y, float z, float rotateX, float rotateY, float rotateZ)
        => Texture(
            region,
            Matrix4.CreateTranslation(x, y, z),
            Matrix4.CreateRotationX(rotateX) * Matrix4.CreateRotationY(rotateY) * Matrix4.CreateRotationZ(rotateZ),
            TestGame.Camera.GetViewMatrix(),
            TestGame.Camera.GetProjectionMatrix()
            );
    public static void Texture(Region region, Matrix4 translate, Matrix4 model, Matrix4 view, Matrix4 projection)
    {
        Shaders.TextureShader.Texture(TextureUnit.Texture0); //Bind texture as 0 in shader
        region.Reference.Use(); //Bind texture as 0

        Shaders.TextureShader.Matrix4("translate", translate);
        Shaders.TextureShader.Matrix4("model", model);
        Shaders.TextureShader.Matrix4("view", view);
        Shaders.TextureShader.Matrix4("projection", projection);
        Shaders.TextureShader.Draw();
    }
#version 330 core

layout(location = 0) in vec3 aPosition;
layout(location = 1) in vec2 aTexCoord;

out vec2 texCoord;

uniform mat4 translate;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;

void main(void)
{
    texCoord = aTexCoord;

    gl_Position = vec4(aPosition, 1) * translate * model * view * projection;
}

矩阵乘法不是Commutative,顺序有问题。在平移之前旋转对象:

gl_Position = vec4(aPosition, 1) * translate * model * view * projection;

gl_Position = vec4(aPosition, 1) * model * translate * view * projection;