实体

可放置 CPlaceable

位置、朝向与矩阵基类

CPlaceable.h

位置 / 朝向基类。CEntity 继承它。有矩阵走 m_matrix,否则走 m_placement

取位置

GetPosition / m_placement / m_matrix

无矩阵时用 simple transform。

CSimpleTransform m_placement;
CMatrixLink* m_matrix;
// GetPosition() 内联:有 matrix 取 matrix 位,否则 m_placement.m_vPosn

设位置

SetPosn

只改坐标不改朝向。

void SetPosn(float x, float y, float z);
void SetPosn(CVector const& pos);

朝向与航向

SetHeading / GetHeading / SetOrientation

参数为弧度。

void SetHeading(float heading);
float GetHeading();
void SetOrientation(float x, float y, float z);
void GetOrientation(float& x, float& y, float& z);

轴向

GetRight / GetForward / GetUp

需要已分配矩阵。

CVector& GetRight() const;
CVector& GetForward() const;
CVector& GetUp() const;
CVector GetRightDirection();
CVector GetTopDirection();
CVector GetAtDirection();

矩阵分配

GetMatrix / AllocateMatrix / SetMatrix
CMatrixLink& GetMatrix();
void AllocateMatrix();
void AllocateStaticMatrix();
void FreeStaticMatrix();
void RemoveMatrix();
void SetMatrix(CMatrix const& matrix);

区域判定

IsWithinArea

2D / 3D 矩形盒。

bool IsWithinArea(float x1, float y1, float x2, float y2);
bool IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2);

On this page