summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-02-12 15:00:44 +0100
committerTreeki <treeki@gmail.com>2011-02-12 15:00:44 +0100
commit8b48608d45c8266b765e8ee29e612fb18376aa65 (patch)
treedabb0546d053586e7c022de8b481c79d892857f8
parentcd9ce0418bf8e36e39e71757c8ef74fa4a163ab3 (diff)
downloadnw4rtools-8b48608d45c8266b765e8ee29e612fb18376aa65.tar.gz
nw4rtools-8b48608d45c8266b765e8ee29e612fb18376aa65.zip
fixed W7 (missing vtxclr/nrm/texcoord dicts now supported) and the matrix code
-rw-r--r--NW4RTools/BrresReader.cs44
-rw-r--r--NW4RTools/ColladaWriter.cs30
-rwxr-xr-xNW4RTools/bin/Debug/NW4RTools.dllbin158720 -> 159232 bytes
-rw-r--r--NW4RTools/bin/Debug/NW4RTools.dll.mdbbin87798 -> 87942 bytes
-rw-r--r--TestApp/Main.cs2
-rwxr-xr-xTestApp/bin/Debug/NW4RTools.dllbin158720 -> 159232 bytes
-rw-r--r--TestApp/bin/Debug/NW4RTools.dll.mdbbin87798 -> 87942 bytes
-rwxr-xr-xTestApp/bin/Debug/TestApp.exebin4096 -> 4096 bytes
-rw-r--r--TestApp/bin/Debug/TestApp.exe.mdbbin479 -> 479 bytes
9 files changed, 51 insertions, 25 deletions
diff --git a/NW4RTools/BrresReader.cs b/NW4RTools/BrresReader.cs
index fa3bf26..20d7739 100644
--- a/NW4RTools/BrresReader.cs
+++ b/NW4RTools/BrresReader.cs
@@ -152,14 +152,42 @@ namespace NW4RTools {
VtxClrIndexLookup = new Dictionary<int, VertexClrData>();
VtxTexCoordIndexLookup = new Dictionary<int, VertexTexCoordData>();
- using (var c2 = Debug.Push("Vertex Position Data"))
- mdl.VtxPosData = ReadAndConvertDict<VertexPosData>(ins.At(startPos + vtxPosOffset), ConvertVtxPosData);
- using (var c2 = Debug.Push("Vertex Normal Data"))
- mdl.VtxNrmData = ReadAndConvertDict<VertexNrmData>(ins.At(startPos + vtxNrmOffset), ConvertVtxNrmData);
- using (var c2 = Debug.Push("Vertex Colour Data"))
- mdl.VtxClrData = ReadAndConvertDict<VertexClrData>(ins.At(startPos + vtxClrOffset), ConvertVtxClrData);
- using (var c2 = Debug.Push("Vertex TexCoord Data"))
- mdl.VtxTexCoordData = ReadAndConvertDict<VertexTexCoordData>(ins.At(startPos + texCoordOffset), ConvertVtxTexCoordData);
+ using (var c2 = Debug.Push("Vertex Position Data")) {
+ if (vtxPosOffset == 0) {
+ Debug.Send("None (what?)");
+ mdl.VtxPosData = new ResDict<VertexPosData>();
+ } else {
+ mdl.VtxPosData = ReadAndConvertDict<VertexPosData>(ins.At(startPos + vtxPosOffset), ConvertVtxPosData);
+ }
+ }
+
+ using (var c2 = Debug.Push("Vertex Normal Data")) {
+ if (vtxNrmOffset == 0) {
+ Debug.Send("None");
+ mdl.VtxNrmData = new ResDict<VertexNrmData>();
+ } else {
+ mdl.VtxNrmData = ReadAndConvertDict<VertexNrmData>(ins.At(startPos + vtxNrmOffset), ConvertVtxNrmData);
+ }
+ }
+
+ using (var c2 = Debug.Push("Vertex Colour Data")) {
+ if (vtxClrOffset == 0) {
+ Debug.Send("None");
+ mdl.VtxClrData = new ResDict<VertexClrData>();
+ } else {
+ mdl.VtxClrData = ReadAndConvertDict<VertexClrData>(ins.At(startPos + vtxClrOffset), ConvertVtxClrData);
+ }
+ }
+
+ using (var c2 = Debug.Push("Vertex TexCoord Data")) {
+ if (texCoordOffset == 0) {
+ Debug.Send("None");
+ mdl.VtxTexCoordData = new ResDict<VertexTexCoordData>();
+ } else {
+ mdl.VtxTexCoordData = ReadAndConvertDict<VertexTexCoordData>(ins.At(startPos + texCoordOffset), ConvertVtxTexCoordData);
+ }
+ }
+
//*/
// Load materials and associated structs
diff --git a/NW4RTools/ColladaWriter.cs b/NW4RTools/ColladaWriter.cs
index a292ba0..b2fc5a2 100644
--- a/NW4RTools/ColladaWriter.cs
+++ b/NW4RTools/ColladaWriter.cs
@@ -79,26 +79,26 @@ namespace NW4RTools {
//cNode.type = NodeType.JOINT;
cNode.node1 = new node[0];
- 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);
+ double cosX = Math.Cos(origNode.Rotation.x / 180 * Math.PI);
+ double cosY = Math.Cos(origNode.Rotation.y / 180 * Math.PI);
+ double cosZ = Math.Cos(origNode.Rotation.z / 180 * Math.PI);
+ double sinX = Math.Sin(origNode.Rotation.x / 180 * Math.PI);
+ double sinY = Math.Sin(origNode.Rotation.y / 180 * Math.PI);
+ double sinZ = Math.Sin(origNode.Rotation.z / 180 * Math.PI);
var nodeMatrix = new matrix();
nodeMatrix.Values = new double[] {
- origNode.Scale.X * cosY * cosZ,
- origNode.Scale.Y * (sinX * cosZ * sinY - cosX * sinZ),
- origNode.Scale.Z * (sinX * sinZ + cosX * cosZ * sinY),
+ 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.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.Scale.x * sinY,
+ origNode.Scale.y * sinX * cosY,
+ origNode.Scale.z * cosX * cosY,
origNode.Translation.z,
0, 0, 0, 1
};
diff --git a/NW4RTools/bin/Debug/NW4RTools.dll b/NW4RTools/bin/Debug/NW4RTools.dll
index 1b431d2..611af6c 100755
--- a/NW4RTools/bin/Debug/NW4RTools.dll
+++ b/NW4RTools/bin/Debug/NW4RTools.dll
Binary files differ
diff --git a/NW4RTools/bin/Debug/NW4RTools.dll.mdb b/NW4RTools/bin/Debug/NW4RTools.dll.mdb
index d635b92..a9dff6f 100644
--- a/NW4RTools/bin/Debug/NW4RTools.dll.mdb
+++ b/NW4RTools/bin/Debug/NW4RTools.dll.mdb
Binary files differ
diff --git a/TestApp/Main.cs b/TestApp/Main.cs
index 1196f08..afe6dda 100644
--- a/TestApp/Main.cs
+++ b/TestApp/Main.cs
@@ -7,8 +7,6 @@ namespace TestApp {
public static void Main(string[] args) {
string mdlPath = "/home/me/Games/Newer/ModelRev/";
- // NOTE: CS_W7 is broken!!
-
string mdlName = "CS_W7";
//string mdlName = "bgB_4502";
diff --git a/TestApp/bin/Debug/NW4RTools.dll b/TestApp/bin/Debug/NW4RTools.dll
index 1b431d2..611af6c 100755
--- a/TestApp/bin/Debug/NW4RTools.dll
+++ b/TestApp/bin/Debug/NW4RTools.dll
Binary files differ
diff --git a/TestApp/bin/Debug/NW4RTools.dll.mdb b/TestApp/bin/Debug/NW4RTools.dll.mdb
index d635b92..a9dff6f 100644
--- a/TestApp/bin/Debug/NW4RTools.dll.mdb
+++ b/TestApp/bin/Debug/NW4RTools.dll.mdb
Binary files differ
diff --git a/TestApp/bin/Debug/TestApp.exe b/TestApp/bin/Debug/TestApp.exe
index 7dc9d18..5845276 100755
--- a/TestApp/bin/Debug/TestApp.exe
+++ b/TestApp/bin/Debug/TestApp.exe
Binary files differ
diff --git a/TestApp/bin/Debug/TestApp.exe.mdb b/TestApp/bin/Debug/TestApp.exe.mdb
index 1e26877..a86d949 100644
--- a/TestApp/bin/Debug/TestApp.exe.mdb
+++ b/TestApp/bin/Debug/TestApp.exe.mdb
Binary files differ