www.pudn.com > 3D_Tank.rar > Arithmetic.h
#ifndef __ARITHMETIC_H__ #define __ARITHMETIC_H__ #include#include struct Box { D3DXVECTOR3 m_vMin; //左下点 D3DXVECTOR3 m_vMax; //右上点 }; //方便函数 DWORD FtoDw(float f); //从float转换到DWORD float GetRandomFloat(float min, float max); //获取一定范围内的随机float数 //生成变换矩阵 D3DXMATRIX* GenerateTranslationMatrix(D3DXMATRIX *mat, const D3DXVECTOR3 &pos, const float yaw =0.0f , const float pitch = 0.0f, const float roll = 0.0f); //获得变换矩阵的look、up、right VOID GetThreeDirFromMatrix(D3DXMATRIX *mat, D3DXVECTOR3 *right, D3DXVECTOR3 *up, D3DXVECTOR3 *look); //根据look、up、right、pos生成变换矩阵 D3DXMATRIX* GenerateMatrix(D3DXMATRIX *mat, const D3DXVECTOR3 &right, const D3DXVECTOR3 &up, const D3DXVECTOR3 &look, const D3DXVECTOR3 &pos); //几何体碰撞测试 BOOL IsPointInBox(const D3DXVECTOR3 &point, const Box &box); BOOL BoxTest(const Box &box1, const Box &box2); //游戏相关 VOID GetRotationAngle(const D3DXVECTOR3 &vTarget, float *fPitch, float *fRoll); //获得变换角度 #endif //Arithmetic