Browse Source

Fix light range and spot angle conversion

Range is always calculated through the spot angle divided by 5.

Range and spot angle were also serialized in the wrong order :(
habeebweeb 4 years ago
parent
commit
263663f261
1 changed files with 6 additions and 6 deletions
  1. 6 6
      COM3D2.MeidoPhotoStudio.Converter/Program.cs

+ 6 - 6
COM3D2.MeidoPhotoStudio.Converter/Program.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.IO;
 using System.IO;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
@@ -19,7 +19,7 @@ namespace COM3D2.MeidoPhotoStudio.Converter
         private const string pluginGuid = "com.habeebweeb.com3d2.meidophotostudio.converter";
         private const string pluginGuid = "com.habeebweeb.com3d2.meidophotostudio.converter";
         public const string pluginName = "MeidoPhotoStudio Converter";
         public const string pluginName = "MeidoPhotoStudio Converter";
         public const string pluginVersion = "0.0.0";
         public const string pluginVersion = "0.0.0";
-        private readonly byte[] noThumb = Convert.FromBase64String(
+        private static readonly byte[] noThumb = Convert.FromBase64String(
             "iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7D" +
             "iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7D" +
             "AcdvqGQAAAFOSURBVFhH3dJbjoMwEETRLIRP9r+zrCGpqJABY+x+2Ua5ys9EcteJNK/3sj7ws7E+j2ln8Q9+O7eE2Vjpq4kdJTsLTZRl" +
             "AcdvqGQAAAFOSURBVFhH3dJbjoMwEETRLIRP9r+zrCGpqJABY+x+2Ua5ys9EcteJNK/3sj7ws7E+j2ln8Q9+O7eE2Vjpq4kdJTsLTZRl" +
             "jBMLTZFdDTkLDZYVAQUWGia7Wy+z0ABZZfqWhbrK6rs1Fuoka442WChcJllss1CgTDgnYqEQmXxLykJOmWpIwUJmmXZFx0IGmWFCzUKq" +
             "jBMLTZFdDTkLDZYVAQUWGia7Wy+z0ABZZfqWhbrK6rs1Fuoka442WChcJllss1CgTDgnYqEQmXxLykJOmWpIwUJmmXZFx0IGmWFCzUKq" +
@@ -638,7 +638,7 @@ namespace COM3D2.MeidoPhotoStudio.Converter
                 // MM uses spotAngle for both range and spotAngle based on which light type is used
                 // MM uses spotAngle for both range and spotAngle based on which light type is used
                 float intensity = float.Parse(strArray3[24]);
                 float intensity = float.Parse(strArray3[24]);
                 float spotAngle = float.Parse(strArray3[25]);
                 float spotAngle = float.Parse(strArray3[25]);
-                float range = lightType == 2 ? spotAngle / 5f : spotAngle; ;
+                float range = spotAngle / 5f;
                 float shadowStrength = 0.098f;
                 float shadowStrength = 0.098f;
                 if (strArray4 != null) shadowStrength = float.Parse(strArray4[0]);
                 if (strArray4 != null) shadowStrength = float.Parse(strArray4[0]);
 
 
@@ -647,7 +647,7 @@ namespace COM3D2.MeidoPhotoStudio.Converter
                     if (i == lightType || (i == 0 && lightType == 3))
                     if (i == lightType || (i == 0 && lightType == 3))
                     {
                     {
                         SerializeLightProperty(
                         SerializeLightProperty(
-                            binaryWriter, lightRotation, lightColour, intensity, spotAngle, range, shadowStrength
+                            binaryWriter, lightRotation, lightColour, intensity, range, spotAngle, shadowStrength
                         );
                         );
                     }
                     }
                     else SerializeDefaultLight(binaryWriter);
                     else SerializeDefaultLight(binaryWriter);
@@ -684,14 +684,14 @@ namespace COM3D2.MeidoPhotoStudio.Converter
 
 
                     float intensity = float.Parse(lightProperties[6]);
                     float intensity = float.Parse(lightProperties[6]);
                     float spotAngle = float.Parse(lightProperties[7]);
                     float spotAngle = float.Parse(lightProperties[7]);
-                    float range = lightType == 2 ? spotAngle / 5f : spotAngle;
+                    float range = spotAngle / 5f;
                     float shadowStrength = 0.098f;
                     float shadowStrength = 0.098f;
                     for (int j = 0; j < 3; j++)
                     for (int j = 0; j < 3; j++)
                     {
                     {
                         if (j == lightType)
                         if (j == lightType)
                         {
                         {
                             SerializeLightProperty(
                             SerializeLightProperty(
-                                binaryWriter, lightRotation, lightColour, intensity, spotAngle, range, shadowStrength
+                                binaryWriter, lightRotation, lightColour, intensity, range, spotAngle, shadowStrength
                             );
                             );
                         }
                         }
                         else SerializeDefaultLight(binaryWriter);
                         else SerializeDefaultLight(binaryWriter);