summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-02-12 14:12:01 +0100
committerTreeki <treeki@gmail.com>2011-02-12 14:12:01 +0100
commitcd9ce0418bf8e36e39e71757c8ef74fa4a163ab3 (patch)
tree4839829a4e6b8e8dda427983432d76c27a23c42e
parentf809b701c4116fc993d449a8b36e395b55984f42 (diff)
downloadnw4rtools-cd9ce0418bf8e36e39e71757c8ef74fa4a163ab3.tar.gz
nw4rtools-cd9ce0418bf8e36e39e71757c8ef74fa4a163ab3.zip
changed the matrix stuff to Schaf's version
Diffstat (limited to '')
-rw-r--r--NW4RTools/ColladaWriter.cs49
1 files changed, 21 insertions, 28 deletions
diff --git a/NW4RTools/ColladaWriter.cs b/NW4RTools/ColladaWriter.cs
index c9412d3..a292ba0 100644
--- a/NW4RTools/ColladaWriter.cs
+++ b/NW4RTools/ColladaWriter.cs
@@ -79,39 +79,32 @@ namespace NW4RTools {
//cNode.type = NodeType.JOINT;
cNode.node1 = new node[0];
- /*var origMatrix = origNode.NodeMatrix;
+ float cosX = Math.Cos(origNode.Rotation.x / 180 * Math.PI);
+ float cosY = Math.Cos(origNode.Rotation.y / 180 * Math.PI);
+ float cosZ = Math.Cos(origNode.Rotation.z / 180 * Math.PI);
+ float sinX = Math.Sin(origNode.Rotation.x / 180 * Math.PI);
+ float sinY = Math.Sin(origNode.Rotation.y / 180 * Math.PI);
+ float sinZ = Math.Sin(origNode.Rotation.z / 180 * Math.PI);
+
var nodeMatrix = new matrix();
nodeMatrix.Values = new double[] {
- origMatrix.v00, origMatrix.v01, origMatrix.v02, origMatrix.v03,
- origMatrix.v10, origMatrix.v11, origMatrix.v12, origMatrix.v13,
- origMatrix.v20, origMatrix.v21, origMatrix.v22, origMatrix.v23,
- 0.0, 0.0, 0.0, 1.0
+ origNode.Scale.X * cosY * cosZ,
+ origNode.Scale.Y * (sinX * cosZ * sinY - cosX * sinZ),
+ origNode.Scale.Z * (sinX * sinZ + cosX * cosZ * sinY),
+ origNode.Translation.x,
+ origNode.Scale.X * sinZ * cosY,
+ origNode.Scale.Y * (sinX * sinZ * sinY + cosZ * cosX),
+ origNode.Scale.Z * (cosX * sinZ * sinY - sinX * cosZ),
+ origNode.Translation.y,
+ -origNode.Scale.X * sinY,
+ origNode.Scale.Y * sinX * cosY,
+ origNode.Scale.Z * cosX * cosY,
+ origNode.Translation.z,
+ 0, 0, 0, 1
};
cNode.Items = new object[] { nodeMatrix };
- cNode.ItemsElementName = new ItemsChoiceType2[] { ItemsChoiceType2.matrix };*/
-
- var tScale = new TargetableFloat3();
- var tRotate = new rotate();
- var tTranslate = new TargetableFloat3();
-
- tScale.Values = new double[] {
- origNode.Scale.x, origNode.Scale.y, origNode.Scale.z
- };
-
- tRotate.Values = new double[] {
- 0, 0, 0, 0 // TODO
- };
-
- tTranslate.Values = new double[] {
- origNode.Translation.x, origNode.Translation.y, origNode.Translation.z
- };
-
- cNode.Items = new object[] { tScale, tRotate, tTranslate };
- cNode.ItemsElementName = new ItemsChoiceType2[] {
- ItemsChoiceType2.scale, ItemsChoiceType2.rotate,
- ItemsChoiceType2.translate
- };
+ cNode.ItemsElementName = new ItemsChoiceType2[] { ItemsChoiceType2.matrix };
NodeDefs[origNode] = cNode;
}