矩阵相关函数改名以规避与GLM函数名的冲突
This commit is contained in:
@@ -51,16 +51,6 @@ namespace hgl
|
||||
return glm::all(glm::epsilonEqual(q1,q2,err));
|
||||
}
|
||||
|
||||
inline Matrix4f inverse(const Matrix4f &m)
|
||||
{
|
||||
return glm::inverse(m);
|
||||
}
|
||||
|
||||
inline Matrix4f transpose(const Matrix4f &m)
|
||||
{
|
||||
return glm::transpose(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成一个正角视图矩阵
|
||||
* @param left 左
|
||||
@@ -70,7 +60,7 @@ namespace hgl
|
||||
* @param znear 近平面z值
|
||||
* @param zfar 远平台z值
|
||||
*/
|
||||
Matrix4f ortho( float left,
|
||||
Matrix4f OrthoMatrix( float left,
|
||||
float right,
|
||||
float bottom,
|
||||
float top,
|
||||
@@ -84,14 +74,14 @@ namespace hgl
|
||||
* @param znear 近平面z值
|
||||
* @param zfar 远平台z值
|
||||
*/
|
||||
Matrix4f ortho(float width,float height,float znear,float zfar);
|
||||
Matrix4f OrthoMatrix(float width,float height,float znear,float zfar);
|
||||
|
||||
/**
|
||||
* 生成一个正角视图矩阵
|
||||
* @param width 宽
|
||||
* @param height 高
|
||||
*/
|
||||
Matrix4f ortho(float width,float height);
|
||||
Matrix4f OrthoMatrix(float width,float height);
|
||||
|
||||
/**
|
||||
* 生成一个透视矩阵
|
||||
@@ -100,7 +90,7 @@ namespace hgl
|
||||
* @param znear 近截面
|
||||
* @param zfar 远截面
|
||||
*/
|
||||
Matrix4f perspective( float field_of_view,
|
||||
Matrix4f PerspectiveMatrix( float field_of_view,
|
||||
float aspect_ratio,
|
||||
float znear,
|
||||
float zfar);
|
||||
@@ -110,39 +100,39 @@ namespace hgl
|
||||
* @param target 目标位置
|
||||
* @param up 向上向量
|
||||
*/
|
||||
Matrix4f lookat(const Vector3f &eye,const Vector3f &target,const Vector3f &up=AxisVector::Z);
|
||||
Matrix4f LookAtMatrix(const Vector3f &eye,const Vector3f &target,const Vector3f &up=AxisVector::Z);
|
||||
|
||||
inline Matrix4f translate(const Vector3f &v)
|
||||
inline Matrix4f TranslateMatrix(const Vector3f &v)
|
||||
{
|
||||
return glm::translate(Matrix4f(1.0f),v);
|
||||
}
|
||||
|
||||
inline Matrix4f translate(float x,float y,float z)
|
||||
inline Matrix4f TranslateMatrix(float x,float y,float z)
|
||||
{
|
||||
return glm::translate(Matrix4f(1.0f),Vector3f(x,y,z));
|
||||
}
|
||||
|
||||
inline Matrix4f translate(float x,float y)
|
||||
inline Matrix4f TranslateMatrix(float x,float y)
|
||||
{
|
||||
return translate(x,y,1.0f);
|
||||
return glm::translate(Matrix4f(1.0f),Vector3f(x,y,1.0f));
|
||||
}
|
||||
|
||||
inline Matrix4f scale(const Vector3f &v)
|
||||
inline Matrix4f ScaleMatrix(const Vector3f &v)
|
||||
{
|
||||
return glm::scale(Matrix4f(1.0f),v);
|
||||
}
|
||||
|
||||
inline Matrix4f scale(float x,float y,float z)
|
||||
inline Matrix4f ScaleMatrix(float x,float y,float z)
|
||||
{
|
||||
return glm::scale(Matrix4f(1.0f),Vector3f(x,y,z));
|
||||
}
|
||||
|
||||
inline Matrix4f scale(float x,float y)
|
||||
inline Matrix4f ScaleMatrix(float x,float y)
|
||||
{
|
||||
return scale(x,y,1.0f);
|
||||
return glm::scale(Matrix4f(1.0f),Vector3f(x,y,1.0f));
|
||||
}
|
||||
|
||||
inline Matrix4f scale(float s)
|
||||
inline Matrix4f ScaleMatrix(float s)
|
||||
{
|
||||
return glm::scale(Matrix4f(1.0f),Vector3f(s,s,s));
|
||||
}
|
||||
|
@@ -101,7 +101,7 @@ namespace hgl
|
||||
|
||||
void MakeNewestData(Matrix4f &mat) override
|
||||
{
|
||||
mat=translate(offset);
|
||||
mat=TranslateMatrix(offset);
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -342,7 +342,7 @@ namespace hgl
|
||||
|
||||
void MakeNewestData(Matrix4f &mat) override
|
||||
{
|
||||
mat=scale(scale3f);
|
||||
mat=ScaleMatrix(scale3f);
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -395,7 +395,7 @@ namespace hgl
|
||||
|
||||
void MakeNewestData(Matrix4f &mat) override
|
||||
{
|
||||
mat=lookat(eye,center,up);
|
||||
mat=LookAtMatrix(eye,center,up);
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -695,7 +695,7 @@ namespace hgl
|
||||
const Matrix4f GetMatrix()const //不能执行UpdateMatrix时的获取
|
||||
{
|
||||
if(matrix_dirty)
|
||||
return translate(translation_vector)*ToMatrix(rotation_quat)*scale(scale_vector);
|
||||
return TranslateMatrix(translation_vector)*ToMatrix(rotation_quat)*ScaleMatrix(scale_vector);
|
||||
else
|
||||
return matrix;
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
Matrix4f ortho( float left,
|
||||
Matrix4f OrthoMatrix( float left,
|
||||
float right,
|
||||
float bottom,
|
||||
float top,
|
||||
@@ -51,9 +51,9 @@ namespace hgl
|
||||
* @param znear 近平面z值
|
||||
* @param zfar 远平台z值
|
||||
*/
|
||||
Matrix4f ortho(float width,float height,float znear,float zfar)
|
||||
Matrix4f OrthoMatrix(float width,float height,float znear,float zfar)
|
||||
{
|
||||
return ortho(0.0f,width,height,0.0f,znear,zfar);
|
||||
return OrthoMatrix(0.0f,width,height,0.0f,znear,zfar);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,9 +61,9 @@ namespace hgl
|
||||
* @param width 宽
|
||||
* @param height 高
|
||||
*/
|
||||
Matrix4f ortho(float width,float height)
|
||||
Matrix4f OrthoMatrix(float width,float height)
|
||||
{
|
||||
return ortho(width,height,0.0f,1.0f);
|
||||
return OrthoMatrix(width,height,0.0f,1.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ namespace hgl
|
||||
* @param znear 近截面
|
||||
* @param zfar 远截面
|
||||
*/
|
||||
Matrix4f perspective( float field_of_view,
|
||||
Matrix4f PerspectiveMatrix( float field_of_view,
|
||||
float aspect_ratio,
|
||||
float znear,
|
||||
float zfar)
|
||||
@@ -105,7 +105,7 @@ namespace hgl
|
||||
//经查证,此代码等于glm::perspectiveRH_ZO之后将[1][1]乘-1,在SaschaWillems的范例中,如果反转Y轴,则[1][1]确实要乘-1。
|
||||
}
|
||||
|
||||
Matrix4f lookat(const Vector3f &eye,const Vector3f &target,const Vector3f &up)
|
||||
Matrix4f LookAtMatrix(const Vector3f &eye,const Vector3f &target,const Vector3f &up)
|
||||
{
|
||||
Vector3f forward=normalize(target-eye);
|
||||
Vector3f right =normalize(cross(forward,up));
|
||||
|
@@ -52,7 +52,7 @@ namespace hgl
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix=translate(translation_vector)*ToMatrix(rotation_quat)*scale(scale_vector);
|
||||
matrix=TranslateMatrix(translation_vector)*ToMatrix(rotation_quat)*ScaleMatrix(scale_vector);
|
||||
inverse_matrix=inverse(matrix);
|
||||
transpose_inverse_matrix=transpose(inverse_matrix);
|
||||
|
||||
|
Reference in New Issue
Block a user