24
24
using xivModdingFramework . Materials . FileTypes ;
25
25
using System . Security . AccessControl ;
26
26
using xivModdingFramework . Models . Enums ;
27
+ using MathNet . Numerics . LinearAlgebra ;
27
28
28
29
namespace xivModdingFramework . Models . Helpers
29
30
{
@@ -1140,7 +1141,6 @@ public static async Task RaceConvert(TTModel incomingModel, XivRace targetRace,
1140
1141
public static async Task RaceConvertRecursive ( TTModel model , XivRace targetRace , XivRace originalRace , Action < bool , string > loggingFunction = null , ModTransaction tx = null )
1141
1142
{
1142
1143
await INTERNAL_RaceConvertRecursive ( model , targetRace , originalRace , loggingFunction , tx ) ;
1143
- await CalculateTangents ( model , loggingFunction , true ) ;
1144
1144
}
1145
1145
private static async Task INTERNAL_RaceConvertRecursive ( TTModel model , XivRace targetRace , XivRace originalRace , Action < bool , string > loggingFunction = null , ModTransaction tx = null )
1146
1146
{
@@ -1379,8 +1379,8 @@ public static async Task ApplyRacialDeform(TTModel model, XivRace targetRace, bo
1379
1379
1380
1380
position += MatrixTransform ( v . Position , matrix ) * boneWeight ;
1381
1381
normal += MatrixTransform ( v . Normal , normalMatrix ) * boneWeight ;
1382
- binormal += MatrixTransform ( v . Binormal , normalMatrix ) * boneWeight ;
1383
- tangent += MatrixTransform ( v . Tangent , normalMatrix ) * boneWeight ;
1382
+ binormal += MatrixTransform ( v . Binormal , matrix ) * boneWeight ;
1383
+ tangent += MatrixTransform ( v . Tangent , matrix ) * boneWeight ;
1384
1384
}
1385
1385
1386
1386
v . Position = position ;
@@ -1420,8 +1420,8 @@ public static async Task ApplyRacialDeform(TTModel model, XivRace targetRace, bo
1420
1420
1421
1421
position += MatrixTransform ( v . Position , matrix ) * boneWeight ;
1422
1422
normal += MatrixTransform ( v . Normal , normalMatrix ) * boneWeight ;
1423
- binormal += MatrixTransform ( v . Binormal , normalMatrix ) * boneWeight ;
1424
- tangent += MatrixTransform ( v . Tangent , normalMatrix ) * boneWeight ;
1423
+ binormal += MatrixTransform ( v . Binormal , matrix ) * boneWeight ;
1424
+ tangent += MatrixTransform ( v . Tangent , matrix ) * boneWeight ;
1425
1425
}
1426
1426
1427
1427
v . Position = position ;
@@ -1440,6 +1440,34 @@ public static async Task ApplyRacialDeform(TTModel model, XivRace targetRace, bo
1440
1440
}
1441
1441
}
1442
1442
1443
+ private static Vector3 MulVec ( Matrix < float > mat , Vector3 v , float lastCol = 1.0f )
1444
+ {
1445
+ var r = Vector3 . Zero ;
1446
+ var vec = Vector < float > . Build . Dense ( 4 ) ;
1447
+ vec [ 0 ] = v . X ;
1448
+ vec [ 1 ] = v . Y ;
1449
+ vec [ 2 ] = v . Z ;
1450
+ vec [ 3 ] = lastCol ;
1451
+ var res = mat * vec ;
1452
+ r . X += res [ 0 ] ;
1453
+ r . Y += res [ 1 ] ;
1454
+ r . Z += res [ 2 ] ;
1455
+ return r ;
1456
+ }
1457
+
1458
+ private static Matrix < float > ConvertMatrix ( Matrix m )
1459
+ {
1460
+ var pMatrix = Matrix < float > . Build . Dense ( 4 , 4 ) ;
1461
+ for ( int i = 0 ; i < 16 ; i ++ )
1462
+ {
1463
+ var x = i / 4 ;
1464
+ var y = ( i % 4 ) ;
1465
+ var v = m [ i ] ;
1466
+ pMatrix [ x , y ] = v ;
1467
+ }
1468
+ return pMatrix ;
1469
+ }
1470
+
1443
1471
1444
1472
/// <summary>
1445
1473
/// This takes a standard Affine Transformation matrix [0,0,0,1 on bottom], and a vector, and applies the transformation to it.
0 commit comments