1
0
mirror of synced 2025-02-20 12:41:10 +01:00

Fix normals changing when model is scaled from transform tool

This commit is contained in:
KillzXGaming 2019-04-12 16:00:03 -04:00
parent 71db632ece
commit 2197414b5f
9 changed files with 11 additions and 5 deletions

Binary file not shown.

View File

@ -1098,8 +1098,6 @@ namespace Bfres.Structs
weights.Clear();
boneInd.Clear();
Console.WriteLine($"Mesh {Text} {VertexSkinCount}");
foreach (Vertex vtx in vertices)
{
if (VertexSkinCount == 0 || VertexSkinCount == 1)

View File

@ -163,11 +163,19 @@ namespace Switch_Toolbox.Library
public void TransformPosition(Vector3 Position, Vector3 Rotation, Vector3 Scale)
{
Matrix4 BonePosExtra = Utils.TransformValues(Position, Rotation, Scale);
Matrix4 positionMat = Matrix4.CreateTranslation(Position);
Matrix4 rotXMat = Matrix4.CreateRotationX(MathHelper.DegreesToRadians(Rotation.X));
Matrix4 rotYMat = Matrix4.CreateRotationY(MathHelper.DegreesToRadians(Rotation.Y));
Matrix4 rotZMat = Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(Rotation.Z));
Matrix4 scaleMat = Matrix4.CreateScale(Scale);
Matrix4 Transformation = (rotXMat * rotYMat * rotZMat) * positionMat;
foreach (Vertex v in vertices)
{
v.pos = Vector3.TransformPosition(v.pos, BonePosExtra);
v.nrm = Vector3.TransformNormal(v.nrm, BonePosExtra);
v.pos = Vector3.TransformPosition(v.pos, Transformation);
v.pos = Vector3.TransformPosition(v.pos, scaleMat);
v.nrm = Vector3.TransformNormal(v.nrm, Transformation);
}
}