Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

Commit

Permalink
规范化
Browse files Browse the repository at this point in the history
  • Loading branch information
Perfare committed Oct 23, 2018
1 parent 2c082bd commit 3a5eb20
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
7 changes: 4 additions & 3 deletions AzurLaneLive2DExtract/CubismModel3Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

namespace AzurLaneLive2DExtract
{
Expand All @@ -13,15 +14,15 @@ public class CubismModel3Json
public SerializableGroup[] Groups;
}

public struct SerializableFileReferences
public class SerializableFileReferences
{
public string Moc;
public string[] Textures;
public string[] Motions;
public string Physics;
public JObject Motions;
}

public struct SerializableGroup
public class SerializableGroup
{
public string Target;
public string Name;
Expand Down
1 change: 0 additions & 1 deletion AzurLaneLive2DExtract/CubismMotion3Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class SerializableMeta
public float Duration;
public float Fps;
public bool Loop;
public bool AreBeziersRestricted;
public int CurveCount;
public int TotalSegmentCount;
public int TotalPointCount;
Expand Down
32 changes: 27 additions & 5 deletions AzurLaneLive2DExtract/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
using AssetStudioCore;
using AssetStudioCore.Classes;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace AzurLaneLive2DExtract
{
class Program
{
static void Main(string[] args)
{
if (args.Length == 0)
return;
foreach (var arg in args)
{
if (!File.Exists(arg))
Expand Down Expand Up @@ -78,15 +81,14 @@ static void Main(string[] args)
Duration = animation.Duration,
Fps = animation.SampleRate,
Loop = true,
AreBeziersRestricted = true,
CurveCount = animation.TrackList.Count,
TotalSegmentCount = 63, //TODO How to calculate this?
TotalPointCount = 165, //TODO How to calculate this?
UserDataCount = 0,
TotalUserDataSize = 0
},
Curves = new SerializableCurve[animation.TrackList.Count]
};
int totalSegmentCount = 0;
int totalPointCount = 0;
for (int i = 0; i < animation.TrackList.Count; i++)
{
var track = animation.TrackList[i];
Expand All @@ -106,6 +108,8 @@ static void Main(string[] args)
json.Curves[i].Segments.Add(2f);
json.Curves[i].Segments.Add(curve.time);
json.Curves[i].Segments.Add(curve.value);
totalSegmentCount++;
totalPointCount += 3;
lastTime = curve.time;
}
else //LinearSegment
Expand All @@ -116,6 +120,8 @@ static void Main(string[] args)
json.Curves[i].Segments.Add(0f);
json.Curves[i].Segments.Add(t);
json.Curves[i].Segments.Add(preCurve.Evaluate(t));
totalSegmentCount++;
totalPointCount += 3;
lastTime = t;
}
}
Expand All @@ -126,21 +132,37 @@ static void Main(string[] args)
json.Curves[i].Segments.Add(0f);
json.Curves[i].Segments.Add(lastCurve.time);
json.Curves[i].Segments.Add(lastCurve.value);
totalSegmentCount++;
totalPointCount += 3;
}
}

json.Meta.TotalSegmentCount = totalSegmentCount;
json.Meta.TotalPointCount = totalPointCount;

motions.Add($"motions/{animation.Name}.motion3.json");
File.WriteAllText($"{destAnimationPath}{animation.Name}.motion3.json", JsonConvert.SerializeObject(json, Formatting.Indented, new MyJsonConverter()));
}
//model
var job = new JObject();
var jarray = new JArray();
var tempjob = new JObject();
foreach (var motion in motions)
{
tempjob["File"] = motion;
jarray.Add(tempjob);
}
job[""] = jarray;

var model3 = new CubismModel3Json
{
Version = 3,
FileReferences = new SerializableFileReferences
{
Moc = $"{name}.moc3",
Textures = textures.ToArray(),
Motions = motions.ToArray(),
Physics = $"{physics.m_Name}.json"
Physics = $"{physics.m_Name}.json",
Motions = job
},
Groups = new[]
{
Expand Down

0 comments on commit 3a5eb20

Please sign in to comment.