From 8b48608d45c8266b765e8ee29e612fb18376aa65 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sat, 12 Feb 2011 15:00:44 +0100 Subject: fixed W7 (missing vtxclr/nrm/texcoord dicts now supported) and the matrix code --- NW4RTools/BrresReader.cs | 44 +++++++++++++++++++++++++++------- NW4RTools/ColladaWriter.cs | 30 +++++++++++------------ NW4RTools/bin/Debug/NW4RTools.dll | Bin 158720 -> 159232 bytes NW4RTools/bin/Debug/NW4RTools.dll.mdb | Bin 87798 -> 87942 bytes 4 files changed, 51 insertions(+), 23 deletions(-) (limited to 'NW4RTools') 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(); VtxTexCoordIndexLookup = new Dictionary(); - using (var c2 = Debug.Push("Vertex Position Data")) - mdl.VtxPosData = ReadAndConvertDict(ins.At(startPos + vtxPosOffset), ConvertVtxPosData); - using (var c2 = Debug.Push("Vertex Normal Data")) - mdl.VtxNrmData = ReadAndConvertDict(ins.At(startPos + vtxNrmOffset), ConvertVtxNrmData); - using (var c2 = Debug.Push("Vertex Colour Data")) - mdl.VtxClrData = ReadAndConvertDict(ins.At(startPos + vtxClrOffset), ConvertVtxClrData); - using (var c2 = Debug.Push("Vertex TexCoord Data")) - mdl.VtxTexCoordData = ReadAndConvertDict(ins.At(startPos + texCoordOffset), ConvertVtxTexCoordData); + using (var c2 = Debug.Push("Vertex Position Data")) { + if (vtxPosOffset == 0) { + Debug.Send("None (what?)"); + mdl.VtxPosData = new ResDict(); + } else { + mdl.VtxPosData = ReadAndConvertDict(ins.At(startPos + vtxPosOffset), ConvertVtxPosData); + } + } + + using (var c2 = Debug.Push("Vertex Normal Data")) { + if (vtxNrmOffset == 0) { + Debug.Send("None"); + mdl.VtxNrmData = new ResDict(); + } else { + mdl.VtxNrmData = ReadAndConvertDict(ins.At(startPos + vtxNrmOffset), ConvertVtxNrmData); + } + } + + using (var c2 = Debug.Push("Vertex Colour Data")) { + if (vtxClrOffset == 0) { + Debug.Send("None"); + mdl.VtxClrData = new ResDict(); + } else { + mdl.VtxClrData = ReadAndConvertDict(ins.At(startPos + vtxClrOffset), ConvertVtxClrData); + } + } + + using (var c2 = Debug.Push("Vertex TexCoord Data")) { + if (texCoordOffset == 0) { + Debug.Send("None"); + mdl.VtxTexCoordData = new ResDict(); + } else { + mdl.VtxTexCoordData = ReadAndConvertDict(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 Binary files a/NW4RTools/bin/Debug/NW4RTools.dll and b/NW4RTools/bin/Debug/NW4RTools.dll differ diff --git a/NW4RTools/bin/Debug/NW4RTools.dll.mdb b/NW4RTools/bin/Debug/NW4RTools.dll.mdb index d635b92..a9dff6f 100644 Binary files a/NW4RTools/bin/Debug/NW4RTools.dll.mdb and b/NW4RTools/bin/Debug/NW4RTools.dll.mdb differ -- cgit v1.2.3