afMatrix.h
资源名称:AirForce.rar [点击查看]
上传用户:kaiguan
上传日期:2007-10-28
资源大小:1074k
文件大小:2k
源码类别:
其他游戏
开发平台:
Visual C++
- #ifndef AF_MATRIX
- #define AF_MATRIX
- class afVec2;
- class afVec3;
- class afVec3n;
- class afVec4;
- struct D3DXMATRIX;
- #pragma warning (push)
- #pragma warning (disable: 4201) // disable warning about nameless struct/union
- class afMatrix
- {
- public:
- afMatrix();
- afMatrix(const float* nElements);
- afMatrix(const D3DXMATRIX& nMat);
- const D3DXMATRIX* getD3DMatrix() const { return reinterpret_cast<const D3DXMATRIX*>(this); }
- D3DXMATRIX* getD3DMatrix() { return reinterpret_cast<D3DXMATRIX*>(this); }
- void makeIdent();
- void makeRotZXY(float nHead, float nPitch, float nRoll);
- void makeTrans(const afVec3& nTrans);
- bool makeLookat(const afVec3n& nDir, const afVec3n& nUp);
- void makeScale(const afVec3& scale);
- void makeScale(float s);
- void makeProjection(float nFovY, float nAspect, float nNear, float nFar);
- bool invert();
- void preMult(const afMatrix& lf);
- void postMult(const afMatrix& rt);
- void multVector(afVec4& dst, const afVec4& src) const;
- void multVector(afVec4& dst, const afVec3& src) const;
- void multVector(afVec3& dst, const afVec3& src) const;
- //accessing functions
- typedef float float4[4];
- const float4&
- operator[](unsigned nIndex) const { return reinterpret_cast<const float4*>(&m00)[nIndex]; }
- float4&
- operator[](unsigned nIndex) { return reinterpret_cast<float4*>(&m00)[nIndex]; }
- const afVec4&
- rowVec4(unsigned nIndex) const { return reinterpret_cast<const afVec4&>((&m00)[nIndex*4]); }
- afVec4&
- rowVec4(unsigned nIndex) { return reinterpret_cast<afVec4&>((&m00)[nIndex*4]); }
- const afVec3&
- rowVec3(unsigned nIndex) const { return reinterpret_cast<const afVec3&>((&m00)[nIndex*4]); }
- afVec3&
- rowVec3(unsigned nIndex) { return reinterpret_cast<afVec3&>((&m00)[nIndex*4]); }
- afMatrix&
- operator=(const D3DXMATRIX& nMat);
- bool
- operator==(const afMatrix& nMat) const;
- protected:
- union
- {
- struct
- {
- float m00, m01, m02, m03;
- float m10, m11, m12, m13;
- float m20, m21, m22, m23;
- float m30, m31, m32, m33;
- };
- float m[4][4];
- };
- friend class afVec2;
- friend class afVec3;
- friend class afVec4;
- friend class afQuat;
- friend class afTransform;
- };
- #pragma warning (pop)
- #endif