2
0
Fork 0
mirror of https://github.com/KillzXGaming/Switch-Toolbox synced 2025-03-13 13:26:58 +00:00

Add .mod stuff

This commit is contained in:
KillzXGaming 2020-01-29 20:01:33 -05:00
parent 2093b3f02e
commit e9751d0cd0

View file

@ -90,6 +90,8 @@ namespace FirstPlugin
private Vector3[] Vertices; private Vector3[] Vertices;
private Vector3[] VertexNormals; private Vector3[] VertexNormals;
private Vector4[] Colors; private Vector4[] Colors;
private Envelope[] Envelopes;
private enum ChunkNames private enum ChunkNames
{ {
Header, Header,
@ -152,7 +154,7 @@ namespace FirstPlugin
string[] JointNames = new string[0]; string[] JointNames = new string[0];
Joint[] Joints = new Joint[0]; Joint[] Joints = new Joint[0];
Envelope[] Envelopes = new Envelope[0]; Envelopes = new Envelope[0];
while (reader.EndOfStream == false) while (reader.EndOfStream == false)
{ {
long chunkStart = reader.Position; long chunkStart = reader.Position;
@ -219,6 +221,18 @@ namespace FirstPlugin
} }
Skeleton.reset(); Skeleton.reset();
Skeleton.update(); Skeleton.update();
foreach (var mesh in Renderer.Meshes)
{
for (int v = 0; v < mesh.vertices.Count; v++) {
var vertex = mesh.vertices[v];
if (vertex.boneIds.Count == 1)
{
var transform = Skeleton.bones[vertex.boneIds[0]].Transform;
vertex.pos = Vector3.TransformPosition(vertex.pos, transform);
}
}
}
} }
} }
@ -365,6 +379,15 @@ namespace FirstPlugin
pos = Vertices[vtxIdx] pos = Vertices[vtxIdx]
}; };
int envIdx = 0;
if (Envelopes.Length > envIdx)
{
for (int i = 0; i < Envelopes[envIdx].Indices?.Length; i++) {
newVertex.boneIds.Add(Envelopes[envIdx].Indices[i]);
newVertex.boneWeights.Add(Envelopes[envIdx].Weights[i]);
}
}
if (VertexNormals != null) if (VertexNormals != null)
newVertex.nrm = VertexNormals[nrmIdx]; newVertex.nrm = VertexNormals[nrmIdx];
if (Colors != null) if (Colors != null)