MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / getTransformationMatrix

Method getTransformationMatrix

COLLADAFramework/src/COLLADAFWNode.cpp:38–88  ·  view source on GitHub ↗

--------------------------------------------------------------------

Source from the content-addressed store, hash-verified

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

Callers 8

setNodePropertiesMethod · 0.80
writeNodeMethod · 0.80
writeNodeMethod · 0.80
handleNodeMethod · 0.80
handleNodeMethod · 0.80

Calls 10

QuaternionClass · 0.85
getTransformationTypeMethod · 0.80
makeTransMethod · 0.80
makeScaleMethod · 0.80
Matrix4Class · 0.50
getCountMethod · 0.45
normaliseMethod · 0.45
getRotationAngleMethod · 0.45
getScaleMethod · 0.45
getMatrixMethod · 0.45

Tested by

no test coverage detected