改进相机的LookAt矩阵

This commit is contained in:
hyzboy 2019-06-24 20:17:20 +08:00
parent 8ba37b8a9d
commit 10c047a975
2 changed files with 5 additions and 5 deletions

View File

@ -28,7 +28,7 @@ namespace hgl
Vector4f eye; ///<眼睛坐标
Vector4f center; ///<视点坐标
Vector4f up_vector =Vector4f(0,0,1,0); ///<向上量(默认0,0,1)
Vector4f forward_vector =Vector4f(0,1,0,0); ///<向前量(默认0,1,0)
Vector4f forward_vector =Vector4f(0,-1,0,0); ///<向前量(默认0,1,0)
Vector4f right_vector =Vector4f(1,0,0,0); ///<向右量(默认0,0,1)
public:

View File

@ -18,7 +18,7 @@ namespace hgl
Matrix4f result(side.x, side.y, side.z, 0.0f,
nup.x, nup.y, nup.z, 0.0f,
-forward.x, -forward.y, -forward.z, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
-dot(side,eye), -dot(nup,eye), dot(forward,eye), 1.0f);
return result*translate(-eye.xyz());
}