改进相机的LookAt矩阵
This commit is contained in:
parent
8ba37b8a9d
commit
10c047a975
@ -28,7 +28,7 @@ namespace hgl
|
|||||||
Vector4f eye; ///<眼睛坐标
|
Vector4f eye; ///<眼睛坐标
|
||||||
Vector4f center; ///<视点坐标
|
Vector4f center; ///<视点坐标
|
||||||
Vector4f up_vector =Vector4f(0,0,1,0); ///<向上量(默认0,0,1)
|
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)
|
Vector4f right_vector =Vector4f(1,0,0,0); ///<向右量(默认0,0,1)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -15,10 +15,10 @@ namespace hgl
|
|||||||
|
|
||||||
Vector4f nup=cross(side,forward);
|
Vector4f nup=cross(side,forward);
|
||||||
|
|
||||||
Matrix4f result(side.x, side.y, side.z, 0.0f,
|
Matrix4f result(side.x, side.y, side.z, 0.0f,
|
||||||
nup.x, nup.y, nup.z, 0.0f,
|
nup.x, nup.y, nup.z, 0.0f,
|
||||||
-forward.x, -forward.y, -forward.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());
|
return result*translate(-eye.xyz());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user