Transform.cc

Go to the documentation of this file.
00001 #include <esg/Transform.h>
00002 
00003 using namespace esg;
00004 
00005 void Transform::_duplicate_attributes(const Transform& o)
00006 {
00007     _mat.set(((Transform&)o)._mat);
00008     _haveAbbrev = ((Transform&)o)._haveAbbrev;
00009     if (_haveAbbrev) {
00010         _rotMat.set(((Transform&)o)._rotMat);
00011         _trVec.set(((Transform&)o)._trVec);
00012         _scVec.set(((Transform&)o)._scVec);
00013     }
00014 }
00015 
00016 Transform* Transform::clone(void) const
00017 {
00018     Transform* pA = new Transform;
00019     pA->_duplicate_attributes(*this);
00020     return pA;
00021 }
00022 
00023 void Transform::rotateX(float a)
00024 {
00025     Matrix4 rotMat;
00026     rotMat.rotX(a);
00027     _mat.mul(rotMat, _mat);
00028     _haveAbbrev = false;
00029 }
00030 
00031 void Transform::rotateY(float a)
00032 {
00033     Matrix4 rotMat;
00034     rotMat.rotY(a);
00035     _mat.mul(rotMat, _mat);
00036     _haveAbbrev = false;
00037 }
00038 
00039 void Transform::rotateZ(float a)
00040 {
00041     Matrix4 rotMat;
00042     rotMat.rotZ(a);
00043     _mat.mul(rotMat, _mat);
00044     _haveAbbrev = false;
00045 }
00046 
00047 void Transform::rotate(float a, const Vector3& axis)
00048 {
00049     Matrix4 rotMat;
00050     rotMat.rotationGL(a, axis);
00051     _mat.mul(rotMat, _mat);
00052     _haveAbbrev = false;
00053 }
00054 
00055 void Transform::translate(float x, float y, float z)
00056 {
00057     Matrix4 auxTrMat;
00058     auxTrMat.setScaleTranslate(1,x,y,z);  // translation matrix
00059     _mat.mul(auxTrMat, _mat);
00060     _haveAbbrev = false;
00061 }
00062 
00063 void Transform::scale(float s)
00064 {
00065     Matrix4 scaleMat;
00066     scaleMat.setScaleTranslate(s,0,0,0);
00067     _mat.mul(scaleMat, _mat);
00068     _haveAbbrev = false;
00069 }
00070 
00071 void Transform::scale(float sx, float sy, float sz)
00072 {
00073     Matrix4 scaleMat;
00074     scaleMat.setIdentity();
00075     scaleMat.setElement(0, 0, sx);
00076     scaleMat.setElement(1, 1, sy);
00077     scaleMat.setElement(2, 2, sz);
00078     _mat.mul(scaleMat, _mat);
00079     _haveAbbrev = false;
00080 }
00081 
00082 void Transform::scale(const Vector3& s)
00083 {
00084     Matrix4 scaleMat;
00085     scaleMat.setIdentity();
00086     scaleMat.setElement(0, 0, s.x);
00087     scaleMat.setElement(1, 1, s.y);
00088     scaleMat.setElement(2, 2, s.z);
00089     _mat.mul(scaleMat, _mat);
00090     _haveAbbrev = false;
00091 }
00092 
00093 void Transform::transform(const Matrix4& mat)
00094 {
00095     _mat.mul(mat, _mat);
00096     _haveAbbrev = false;
00097 }
00098 
00099 
00100 

Generated on Wed Jun 28 12:24:32 2006 for esg by  doxygen 1.4.6