Added Position/Direction in SceneOrient
This commit is contained in:
parent
6571a27f41
commit
8ebb3095a7
@ -18,7 +18,10 @@ namespace hgl
|
|||||||
|
|
||||||
//ObjectList<Transform> TransformList;
|
//ObjectList<Transform> TransformList;
|
||||||
|
|
||||||
Matrix4f LocalMatrix; ///<当前矩阵
|
Vector3f Position; ///<坐标
|
||||||
|
Vector3f Direction; ///<方向
|
||||||
|
|
||||||
|
Matrix4f LocalMatrix; ///<当前矩阵(指相对上一级的变换矩阵)
|
||||||
Matrix4f LocalToWorldMatrix; ///<当前到世界矩阵
|
Matrix4f LocalToWorldMatrix; ///<当前到世界矩阵
|
||||||
|
|
||||||
Matrix4f InverseLocalMatrix; ///<反向当前矩阵
|
Matrix4f InverseLocalMatrix; ///<反向当前矩阵
|
||||||
@ -30,6 +33,16 @@ namespace hgl
|
|||||||
SceneOrient(const Matrix4f &mat);
|
SceneOrient(const Matrix4f &mat);
|
||||||
virtual ~SceneOrient()=default;
|
virtual ~SceneOrient()=default;
|
||||||
|
|
||||||
|
void SetPosition (const Vector3f &pos){Position=pos;}
|
||||||
|
void SetDirection (const Vector3f &dir){Direction=dir;}
|
||||||
|
|
||||||
|
const Vector3f & GetLocalPosition ()const{return Position;}
|
||||||
|
const Vector3f & GetLocalDirection ()const{return Direction;}
|
||||||
|
const Vector3f & GetWorldPosition ()const{return TransformPosition(LocalToWorldMatrix,Position);}
|
||||||
|
const Vector3f & GetWorldDirection ()const{return TransformDirection(LocalToWorldMatrix,Direction);}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
Matrix4f & SetLocalMatrix (const Matrix4f &); ///<设定当前节点矩阵
|
Matrix4f & SetLocalMatrix (const Matrix4f &); ///<设定当前节点矩阵
|
||||||
Matrix4f & SetLocalToWorldMatrix (const Matrix4f &); ///<设定当前节点到世界矩阵
|
Matrix4f & SetLocalToWorldMatrix (const Matrix4f &); ///<设定当前节点到世界矩阵
|
||||||
|
|
||||||
|
@ -5,18 +5,21 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
SceneOrient::SceneOrient()
|
SceneOrient::SceneOrient()
|
||||||
{
|
{
|
||||||
LocalMatrix =Matrix4f(1.0f);
|
Position=Vector3f(0.0f);
|
||||||
LocalToWorldMatrix =Matrix4f(1.0f);
|
Direction=Vector3f(0.0f);
|
||||||
InverseLocalMatrix =Matrix4f(1.0f);
|
|
||||||
InverseLocalToWorldMatrix =Matrix4f(1.0f);
|
LocalMatrix =Identity4f;
|
||||||
|
LocalToWorldMatrix =Identity4f;
|
||||||
|
InverseLocalMatrix =Identity4f;
|
||||||
|
InverseLocalToWorldMatrix =Identity4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneOrient::SceneOrient(const Matrix4f &mat)
|
SceneOrient::SceneOrient(const Matrix4f &mat)
|
||||||
{
|
{
|
||||||
SetLocalMatrix(mat);
|
SetLocalMatrix(mat);
|
||||||
|
|
||||||
LocalToWorldMatrix =Matrix4f(1.0f);
|
LocalToWorldMatrix =Identity4f;
|
||||||
InverseLocalToWorldMatrix =Matrix4f(1.0f);
|
InverseLocalToWorldMatrix =Identity4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4f &SceneOrient::SetLocalMatrix(const Matrix4f &m)
|
Matrix4f &SceneOrient::SetLocalMatrix(const Matrix4f &m)
|
||||||
@ -43,7 +46,7 @@ namespace hgl
|
|||||||
*/
|
*/
|
||||||
void SceneOrient::RefreshLocalToWorldMatrix(const Matrix4f *m)
|
void SceneOrient::RefreshLocalToWorldMatrix(const Matrix4f *m)
|
||||||
{
|
{
|
||||||
SetLocalToWorldMatrix((*m)*LocalMatrix);
|
SetLocalToWorldMatrix(TransformMatrix(*m,LocalMatrix));
|
||||||
}
|
}
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user