-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
114 lines (89 loc) · 3.41 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
namespace Godbert
{
using Newtonsoft.Json;
using SaintCoinach;
using SaintCoinach.Graphics;
using SaintCoinach.Graphics.Viewer;
using SaintCoinach.Graphics.Viewer.Interop;
using SaintCoinach.IO;
using System;
using System.Collections.Generic;
using System.IO;
public struct PrimaryConfig
{
public string GameDirectory;
}
public struct ConfigJson
{
public string SkeletonPath;
public List<string> AnimationPaths;
public bool MergeAnimations;
public bool IncludeBindPose;
}
public class main
{
private static ARealmReversed Realm;
public static void Main(string[] args)
{
HavokInterop.InitializeSTA();
var cwd = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
System.IO.Directory.SetCurrentDirectory(cwd);
if (args.Length == 0)
{
args = new string[1];
args[0] = cwd + "\\..\\settings\\default.json";
}
var gameDirectory = System.IO.File.ReadAllText(cwd + "\\..\\game_directory.config");
gameDirectory = gameDirectory.Trim();
Console.WriteLine("Using Game Directory: " + gameDirectory);
var configBlob = System.IO.File.ReadAllText(args[0]);
var config = JsonConvert.DeserializeObject<ConfigJson>(configBlob);
Realm = new ARealmReversed(gameDirectory, SaintCoinach.Ex.Language.English);
var paps = new List<PapFile>();
foreach(var anim in config.AnimationPaths)
{
paps.Add(InitPap(anim));
}
var model_skel = new Skeleton(InitSklb(config.SkeletonPath));
var body = "chara/equipment/e0000/model/c0101e0000_top.mdl";
ModelFile file = (ModelFile)Realm.Packs.GetFile(body);
Model model = new Model(file.GetModelDefinition(), ModelQuality.High);
var configName = Path.GetFileNameWithoutExtension(args[0]);
System.IO.Directory.CreateDirectory(cwd + "\\..\\results");
Console.WriteLine(paps.Count + " PAP File(s).");
int anims = 0;
for(int i = 0; i < paps.Count; i++)
{
anims += paps[i].Animations.Length;
}
Console.WriteLine(anims + " Total Animation(s).");
var mode = 0;
if(config.MergeAnimations)
{
Console.WriteLine("Animation Merging: Enabled");
mode = mode | 1;
} else
{
Console.WriteLine("Animation Merging: Disabled");
}
if (config.IncludeBindPose) {
mode = mode | 2;
Console.WriteLine("Include Frame 0 Bind Pose: Enabled");
} else
{
Console.WriteLine("Include Frame 0 Bind Pose: Disabled");
}
FbxExport.ExportFbx(cwd + "\\..\\results\\" + configName + ".fbx", model.Meshes, model_skel, paps, mode);
}
private static SklbFile InitSklb(string path)
{
SaintCoinach.IO.File file = Realm.Packs.GetFile(path);
return new SklbFile(file);
}
private static PapFile InitPap(string path)
{
SaintCoinach.IO.File file = Realm.Packs.GetFile(path);
return new PapFile(file);
}
}
}