afTransform.cpp
资源名称:AirForce.rar [点击查看]
上传用户:kaiguan
上传日期:2007-10-28
资源大小:1074k
文件大小:1k
源码类别:
其他游戏
开发平台:
Visual C++
- #include "afTransform.h"
- afTransform& afTransform::operator=(const afTransform& nT)
- {
- pos = nT.pos;
- rot = nT.rot;
- scale = nT.scale;
- dirty=true;
- return *this;
- }
- afTransform& afTransform::operator*=(const afTransform& nT)
- {
- pos += nT.pos;
- rot *= nT.rot;
- scale.x *= nT.scale.x;
- scale.y *= nT.scale.y;
- scale.z *= nT.scale.z;
- dirty=true;
- return *this;
- }
- afTransform& afTransform::operator>=(const afTransform& nT)
- {
- pos += nT.pos;
- rot >= nT.rot; //rot = t.rot * rot
- scale.x *= nT.scale.x;
- scale.y *= nT.scale.y;
- scale.z *= nT.scale.z;
- dirty=true;
- return *this;
- }
- const afMatrix&
- afTransform::getMatrix()
- {
- updateMatrix();
- return matrix;
- }
- void
- afTransform::updateMatrix()
- {
- if(!dirty)
- return;
- afMatrix mrot;
- rot.setMatrix(mrot);
- matrix.m00 = mrot.m00*scale.x;
- matrix.m10 = mrot.m10*scale.y;
- matrix.m20 = mrot.m20*scale.z;
- matrix.m30 = pos.x;
- matrix.m01 = mrot.m01*scale.x;
- matrix.m11 = mrot.m11*scale.y;
- matrix.m21 = mrot.m21*scale.z;
- matrix.m31 = pos.y;
- matrix.m02 = mrot.m02*scale.x;
- matrix.m12 = mrot.m12*scale.y;
- matrix.m22 = mrot.m22*scale.z;
- matrix.m32 = pos.z;
- matrix.m03 = 0.0f;
- matrix.m13 = 0.0f;
- matrix.m23 = 0.0f;
- matrix.m33 = 1.0f;
- }