4.1的格式转换
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using NLog;
|
using NLog;
|
||||||
|
using SpineViewer.Spine.Implementations.SkeletonConverter;
|
||||||
using SpineViewer.Utils;
|
using SpineViewer.Utils;
|
||||||
using SpineViewer.Utils.Localize;
|
using SpineViewer.Utils.Localize;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -294,7 +294,7 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
|||||||
data["inertia"] = reader.ReadFloat();
|
data["inertia"] = reader.ReadFloat();
|
||||||
data["strength"] = reader.ReadFloat();
|
data["strength"] = reader.ReadFloat();
|
||||||
data["damping"] = 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["wind"] = reader.ReadFloat();
|
||||||
data["gravity"] = reader.ReadFloat();
|
data["gravity"] = reader.ReadFloat();
|
||||||
|
|
||||||
@@ -325,6 +325,21 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
|||||||
// other skins
|
// other skins
|
||||||
for (int n = reader.ReadVarInt(); n > 0; n--)
|
for (int n = reader.ReadVarInt(); n > 0; n--)
|
||||||
skins.Add(ReadSkin());
|
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)
|
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 & 32) != 0) attachment["color"] = reader.ReadInt().ToString("x8");
|
||||||
if ((flags & 64) != 0) attachment["sequence"] = ReadSequence();
|
if ((flags & 64) != 0) attachment["sequence"] = ReadSequence();
|
||||||
if ((flags & 128) == 0) attachment["timelines"] = false;
|
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();
|
attachment["parent"] = reader.ReadStringRef();
|
||||||
if (nonessential)
|
if (nonessential)
|
||||||
{
|
{
|
||||||
@@ -1528,8 +1545,14 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
|||||||
writer.WriteVarInt(0); // 其他皮肤数量
|
writer.WriteVarInt(0); // 其他皮肤数量
|
||||||
return;
|
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();
|
JsonArray skins = root["skins"].AsArray();
|
||||||
|
foreach (var sk in skins)
|
||||||
|
{
|
||||||
|
skin2idx[(string)sk["name"]] = skin2idx.Count;
|
||||||
|
}
|
||||||
|
|
||||||
bool hasDefault = false;
|
bool hasDefault = false;
|
||||||
foreach (JsonObject skin in skins)
|
foreach (JsonObject skin in skins)
|
||||||
{
|
{
|
||||||
@@ -1537,7 +1560,7 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
|||||||
{
|
{
|
||||||
hasDefault = true;
|
hasDefault = true;
|
||||||
WriteSkin(skin, true);
|
WriteSkin(skin, true);
|
||||||
skin2idx["default"] = skin2idx.Count;
|
//skin2idx["default"] = skin2idx.Count;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1558,7 +1581,7 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
|
|||||||
if (name != "default")
|
if (name != "default")
|
||||||
{
|
{
|
||||||
WriteSkin(skin);
|
WriteSkin(skin);
|
||||||
skin2idx[name] = skin2idx.Count;
|
//skin2idx[name] = skin2idx.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<TargetFramework>net8.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
|
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
|
||||||
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||||
<Version>0.12.8</Version>
|
<Version>0.12.9</Version>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ApplicationIcon>appicon.ico</ApplicationIcon>
|
<ApplicationIcon>appicon.ico</ApplicationIcon>
|
||||||
|
|||||||
Reference in New Issue
Block a user