TransformFaceToCamera class is finished.

This commit is contained in:
2024-08-31 15:46:11 +08:00
parent 99264b5b0a
commit 5e8957b78b
6 changed files with 130 additions and 27 deletions

View File

@@ -26,11 +26,20 @@ namespace hgl
Matrix4f parent_matrix;
Matrix4f local_matrix;
bool local_is_identity;
Vector3f local_normal;
TransformManager transform_manager;
Matrix4f transform_matrix;
Vector3f OriginWorldPosition; //原始世界坐标
Vector3f FinalWorldPosition; //最终世界坐标
protected:
Vector3f OriginWorldPosition; //变换前世界坐标
Vector3f FinalWorldPosition; //变换后世界坐标
Vector3f OriginWorldNormal; //变换前世界法线
Vector3f FinalWorldNormal; //变换后世界法线
protected:
@@ -44,6 +53,7 @@ namespace hgl
void Clear();
const Matrix4f &GetLocalMatrix()const{return local_matrix;} ///<取得本地矩阵
const Vector3f &GetLocalNormal()const{return local_normal;} ///<取得本地法线
const Matrix4f &GetLocalToWorldMatrix(){return GetNewestVersionData();} ///<取得本地到世界矩阵
const Matrix4f &GetInverseLocalToWorldMatrix(){UpdateNewestData();return inverse_local_to_world_matrix;} ///<取得世界到本地矩阵
@@ -56,6 +66,7 @@ namespace hgl
TransformManager &GetTransform(){return transform_manager;} ///<取得变换管理器
const Vector3f &GetWorldPosition()const{return FinalWorldPosition;} ///<取得世界坐标
const Vector3f &GetWorldNormal()const { return FinalWorldNormal; } ///<取得世界法线
public:
@@ -67,6 +78,16 @@ namespace hgl
UpdateVersion();
}
void SetLocalNormal(const Vector3f &normal)
{
//if(IsNearlyEqual(local_normal,normal))
if(!hgl_cmp(local_normal,normal))
return;
local_normal=normal;
UpdateVersion();
}
void SetLocalMatrix(const Matrix4f &mat)
{
//if (IsNearlyEqual(local_matrix,mat))
@@ -74,6 +95,8 @@ namespace hgl
return;
local_matrix=mat;
local_is_identity=IsIdentityMatrix(mat);
UpdateVersion();
}
@@ -86,6 +109,8 @@ namespace hgl
parent_matrix=pm;
UpdateVersion();
}
virtual void Update();
};//class SceneMatrix
}//namespace graph
}//namespace hgl

View File

@@ -28,8 +28,9 @@ namespace hgl
scene_matrix.Clear();
}
void SetLocalMatrix (const Matrix4f &mat){scene_matrix.SetLocalMatrix(mat);} ///<设置本地矩阵
void SetParentMatrix (const Matrix4f &mat){scene_matrix.SetParentMatrix(mat);} ///<设置上级到世界空间变换矩阵
void SetLocalNormal(const Vector3f &nor) {scene_matrix.SetLocalNormal(nor);} ///<设置本地法线
void SetLocalMatrix (const Matrix4f &mat){scene_matrix.SetLocalMatrix(mat);} ///<设置本地矩阵
void SetParentMatrix(const Matrix4f &mat){scene_matrix.SetParentMatrix(mat);} ///<设置上级到世界空间变换矩阵
public: