相关疑难解决方法(0)

变换模型矩阵

使用 glm 设置 ViewMatrix 很容易:

glm::lookAt(Position, Direction, UpVector);
Run Code Online (Sandbox Code Playgroud)

但是如果我尝试将 funktion 与 modelMatrix 一起使用,我会得到令人困惑的值(模型的位置不正确,而且旋转看起来也不正确)。我只想以与设置相机相同的方式设置对象。我可以使用 lookAt 功能并在之后进行一些更改吗?还是我必须为此编写自己的功能?如果是这样,如何?

我用这个固定了位置:

m_Orientation = glm::lookAtLH(Position, Direction, UpVector);
m_Orientation[3][0] = -m_Orientation[3][0];
m_Orientation[3][1] = -m_Orientation[3][1];
m_Orientation[3][2] = -m_Orientation[3][2];
Run Code Online (Sandbox Code Playgroud)

也在 vertexshader 里面我用这个:

gl_Position = CameraMatrix * ModelMatrix * Pos;
Run Code Online (Sandbox Code Playgroud)

其中 CameraMatrix 是一个 viewProjectionMatrix,ModelMatrix(我的问题)和 Pos 是我的顶点在模型空间中的位置

c++ opengl coordinate-transformation glm-math

0
推荐指数
1
解决办法
1999
查看次数

标签 统计

c++ ×1

coordinate-transformation ×1

glm-math ×1

opengl ×1