4.1的格式转换
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using NLog;
|
||||
using SpineViewer.Spine.Implementations.SkeletonConverter;
|
||||
using SpineViewer.Utils;
|
||||
using SpineViewer.Utils.Localize;
|
||||
using System.Configuration;
|
||||
@@ -45,16 +46,16 @@ namespace SpineViewer
|
||||
{
|
||||
// 此处先初始化全局配置再触发静态字段 Logger 引用构造, 才能将配置应用到新的日志器上
|
||||
InitializeLogConfiguration();
|
||||
logger.Info("Program Started");
|
||||
logger.Info("Program Started");
|
||||
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
LocalizeConfiguration.SetCulture();
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
Application.Run(new SpineViewerForm() { Text = $"SpineViewer - v{Version}"});
|
||||
Application.Run(new SpineViewerForm() { Text = $"SpineViewer - v{Version}" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -294,7 +294,7 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
||||
data["inertia"] = reader.ReadFloat();
|
||||
data["strength"] = reader.ReadFloat();
|
||||
data["damping"] = reader.ReadFloat();
|
||||
if ((flags & 128) != 0) data["mass"] = reader.ReadFloat();
|
||||
if ((flags & 128) != 0) data["mass"] = 1.0f / reader.ReadFloat(); //在binary中存储的是质量的倒数,在json中存储的是质量
|
||||
data["wind"] = reader.ReadFloat();
|
||||
data["gravity"] = reader.ReadFloat();
|
||||
|
||||
@@ -325,6 +325,21 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
||||
// other skins
|
||||
for (int n = reader.ReadVarInt(); n > 0; n--)
|
||||
skins.Add(ReadSkin());
|
||||
|
||||
//处理linkedmesh的问题,后面有相关代码和注释
|
||||
foreach (JsonObject skin in skins)
|
||||
{
|
||||
foreach (var (_, slot) in skin["attachments"].AsObject())
|
||||
{
|
||||
foreach (var (_, attachment) in slot.AsObject())
|
||||
{
|
||||
if ((string)attachment["type"] == "linkedMesh")
|
||||
{
|
||||
attachment["skin"] = (string)skins[(int)attachment["skin"]]["name"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private JsonObject? ReadSkin(bool isDefault = false)
|
||||
@@ -423,7 +438,9 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
||||
if ((flags & 32) != 0) attachment["color"] = reader.ReadInt().ToString("x8");
|
||||
if ((flags & 64) != 0) attachment["sequence"] = ReadSequence();
|
||||
if ((flags & 128) == 0) attachment["timelines"] = false;
|
||||
attachment["skin"] = (string)skins[reader.ReadVarInt()]["name"];
|
||||
//attachment["skin"] = (string)skins[reader.ReadVarInt()]["name"];
|
||||
//还是那个mix-and-match,4.2版本的mix-and-match,出现了读取错误,后面写的时候也一样,linkedmesh的skin为后面还未访问的skin
|
||||
attachment["skin"] = reader.ReadVarInt();
|
||||
attachment["parent"] = reader.ReadStringRef();
|
||||
if (nonessential)
|
||||
{
|
||||
@@ -1084,7 +1101,7 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
||||
}
|
||||
return attachmentTimelines.Count > 0 ? attachmentTimelines : null;
|
||||
}
|
||||
|
||||
|
||||
private JsonArray? ReadDrawOrderTimelines()
|
||||
{
|
||||
JsonArray slots = root["slots"].AsArray();
|
||||
@@ -1500,7 +1517,7 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
||||
writer.WriteFloat((float)(data["inertia"] ?? 1f));
|
||||
writer.WriteFloat((float)(data["strength"] ?? 100f));
|
||||
writer.WriteFloat((float)(data["damping"] ?? 1f));
|
||||
if ((flags & 128) != 0) writer.WriteFloat(1f / (float)data["mass"]);
|
||||
if ((flags & 128) != 0) writer.WriteFloat(1f / (float)data["mass"]);
|
||||
writer.WriteFloat((float)(data["wind"] ?? 0f));
|
||||
writer.WriteFloat((float)(data["gravity"] ?? 0f));
|
||||
|
||||
@@ -1528,8 +1545,14 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
||||
writer.WriteVarInt(0); // 其他皮肤数量
|
||||
return;
|
||||
}
|
||||
|
||||
//此处还是得先把数据全读了,反面例子还是那个mix-and-match,4.2版本的mix-and-match中,default用到了后面的skin,转换失败
|
||||
//mix-and-match的full-skins/boy这个skin,他的linkedmesh调用了后面的full-skins/boy
|
||||
JsonArray skins = root["skins"].AsArray();
|
||||
foreach (var sk in skins)
|
||||
{
|
||||
skin2idx[(string)sk["name"]] = skin2idx.Count;
|
||||
}
|
||||
|
||||
bool hasDefault = false;
|
||||
foreach (JsonObject skin in skins)
|
||||
{
|
||||
@@ -1537,7 +1560,7 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
||||
{
|
||||
hasDefault = true;
|
||||
WriteSkin(skin, true);
|
||||
skin2idx["default"] = skin2idx.Count;
|
||||
//skin2idx["default"] = skin2idx.Count;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1558,7 +1581,7 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
||||
if (name != "default")
|
||||
{
|
||||
WriteSkin(skin);
|
||||
skin2idx[name] = skin2idx.Count;
|
||||
//skin2idx[name] = skin2idx.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1960,7 +1983,7 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (type == "rotate")
|
||||
{
|
||||
writer.WriteByte(SkeletonBinary.BONE_ROTATE);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
|
||||
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||
<Version>0.12.8</Version>
|
||||
<Version>0.12.9</Version>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ApplicationIcon>appicon.ico</ApplicationIcon>
|
||||
|
||||
Reference in New Issue
Block a user