--------------------------------------------------------------------
| 36 | |
| 37 | //-------------------------------------------------------------------- |
| 38 | void Node::getTransformationMatrix(COLLADABU::Math::Matrix4& transformationMatrix) const |
| 39 | { |
| 40 | transformationMatrix = COLLADABU::Math::Matrix4::IDENTITY; |
| 41 | |
| 42 | for ( size_t i = 0, count = mTransformations.getCount(); i < count; ++i ) |
| 43 | { |
| 44 | Transformation* transform = mTransformations[i]; |
| 45 | |
| 46 | switch ( transform->getTransformationType() ) |
| 47 | { |
| 48 | case Transformation::ROTATE: |
| 49 | { |
| 50 | Rotate* rotate = (Rotate*)transform; |
| 51 | COLLADABU::Math::Vector3 axis = rotate->getRotationAxis(); |
| 52 | axis.normalise(); |
| 53 | double angle = rotate->getRotationAngle(); |
| 54 | transformationMatrix = transformationMatrix * COLLADABU::Math::Matrix4(COLLADABU::Math::Quaternion(COLLADABU::Math::Utils::degToRad(angle), axis)); |
| 55 | break; |
| 56 | } |
| 57 | case Transformation::TRANSLATE: |
| 58 | { |
| 59 | Translate* translate = (Translate*)transform; |
| 60 | const COLLADABU::Math::Vector3& translation = translate->getTranslation(); |
| 61 | COLLADABU::Math::Matrix4 translationMatrix; |
| 62 | translationMatrix.makeTrans(translation); |
| 63 | transformationMatrix = transformationMatrix * translationMatrix; |
| 64 | break; |
| 65 | } |
| 66 | case Transformation::SCALE: |
| 67 | { |
| 68 | Scale* scale = (Scale*)transform; |
| 69 | const COLLADABU::Math::Vector3& scaleVector = scale->getScale(); |
| 70 | COLLADABU::Math::Matrix4 scaleMatrix; |
| 71 | scaleMatrix.makeScale(scaleVector); |
| 72 | transformationMatrix = transformationMatrix * scaleMatrix; |
| 73 | break; |
| 74 | } |
| 75 | case Transformation::MATRIX: |
| 76 | { |
| 77 | Matrix* matrix = (Matrix*)transform; |
| 78 | transformationMatrix = transformationMatrix * matrix->getMatrix(); |
| 79 | break; |
| 80 | } |
| 81 | case Transformation::LOOKAT: |
| 82 | break; /** @TODO unhandled case */ |
| 83 | case Transformation::SKEW: |
| 84 | break; /** @TODO unhandled case */ |
| 85 | } |
| 86 | |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | //-------------------------------------------------------------------- |
| 91 | COLLADABU::Math::Matrix4 Node::getTransformationMatrix() const |
no test coverage detected