@@ -1476,7 +1476,7 @@ public static async Task<TTModel> LoadFromFile(string filePath, Action<bool, str
1476
1476
{
1477
1477
loggingFunction = ModelModifiers . NoOp ;
1478
1478
}
1479
- if ( settings == null )
1479
+ if ( settings == null )
1480
1480
{
1481
1481
settings = new ModelImportOptions ( ) ;
1482
1482
}
@@ -1519,7 +1519,7 @@ public static async Task<TTModel> LoadFromFile(string filePath, Action<bool, str
1519
1519
}
1520
1520
else
1521
1521
{
1522
- model . MeshGroups [ meshNum ] . MeshType = ( EMeshType ) Enum . Parse ( typeof ( EMeshType ) , t ) ;
1522
+ model . MeshGroups [ meshNum ] . MeshType = ( EMeshType ) Enum . Parse ( typeof ( EMeshType ) , t ) ;
1523
1523
}
1524
1524
1525
1525
model . MeshGroups [ meshNum ] . Name = reader . GetString ( "name" ) ;
@@ -1546,7 +1546,7 @@ public static async Task<TTModel> LoadFromFile(string filePath, Action<bool, str
1546
1546
}
1547
1547
1548
1548
// Spawn parts as needed.
1549
- while ( model . MeshGroups [ meshNum ] . Parts . Count <= partNum )
1549
+ while ( model . MeshGroups [ meshNum ] . Parts . Count <= partNum )
1550
1550
{
1551
1551
model . MeshGroups [ meshNum ] . Parts . Add ( new TTMeshPart ( ) ) ;
1552
1552
@@ -1672,14 +1672,15 @@ public static async Task<TTModel> LoadFromFile(string filePath, Action<bool, str
1672
1672
vertex . FlowDirection [ 0 ] = reader . GetFloat ( "flow_u" ) ;
1673
1673
vertex . FlowDirection [ 1 ] = reader . GetFloat ( "flow_v" ) ;
1674
1674
1675
- if ( vertex . Binormal != Vector3 . Zero )
1675
+ if ( vertex . Binormal != Vector3 . Zero )
1676
1676
{
1677
1677
var tangent = Vector3 . Cross ( vertex . Normal , vertex . Binormal ) . Normalized ( ) ;
1678
1678
var dot = Vector3 . Dot ( tangent , vertex . Tangent ) ;
1679
- if ( dot < 0.5f )
1679
+ if ( dot < 0.5f )
1680
1680
{
1681
1681
vertex . Handedness = true ;
1682
- } else
1682
+ }
1683
+ else
1683
1684
{
1684
1685
vertex . Handedness = false ;
1685
1686
}
@@ -1693,7 +1694,8 @@ public static async Task<TTModel> LoadFromFile(string filePath, Action<bool, str
1693
1694
try
1694
1695
{
1695
1696
return reader . GetInt32 ( "vertex_id" ) ;
1696
- } catch ( Exception ex )
1697
+ }
1698
+ catch ( Exception ex )
1697
1699
{
1698
1700
throw ex ;
1699
1701
}
@@ -1741,25 +1743,42 @@ public static async Task<TTModel> LoadFromFile(string filePath, Action<bool, str
1741
1743
}
1742
1744
}
1743
1745
}
1744
- db . Close ( ) ;
1745
- }
1746
1746
1747
- // Try to make sure the DB is properly unlocked.'
1747
+ //Load Mats if applicable
1748
+ query = "select * from materials order by material_id" ;
1749
+ using ( var cmd = new SQLiteCommand ( query , db ) )
1750
+ {
1751
+ using ( var reader = new CacheReader ( cmd . ExecuteReader ( ) ) )
1752
+ {
1753
+ while ( reader . NextRow ( ) )
1754
+ {
1755
+ var matNum = reader . GetInt32 ( "material_id" ) ;
1756
+ var materialPath = reader . GetString ( "name" ) ;
1757
+ model . MeshGroups [ matNum ] . Material = materialPath ;
1758
+ }
1759
+ }
1760
+
1748
1761
1749
- XivCache . WaitForSqlCleanup ( ) ;
1762
+ db . Close ( ) ;
1763
+ }
1750
1764
1751
- model . UVState = UVAddressingSpace . Standard ;
1765
+ // Try to make sure the DB is properly unlocked.'
1752
1766
1753
- // Convert the model to FFXIV's internal weirdness.
1754
- ModelModifiers . MakeImportReady ( model , settings . ShiftImportUV , loggingFunction ) ;
1767
+ XivCache . WaitForSqlCleanup ( ) ;
1755
1768
1756
- await ModelModifiers . CalculateTangents ( model , loggingFunction ) ;
1769
+ model . UVState = UVAddressingSpace . Standard ;
1757
1770
1758
- await ModelModifiers . ConvertFlowData ( model , loggingFunction ) ;
1771
+ // Convert the model to FFXIV's internal weirdness.
1772
+ ModelModifiers . MakeImportReady ( model , settings . ShiftImportUV , loggingFunction ) ;
1759
1773
1760
- ModelModifiers . CleanWeights ( model , loggingFunction ) ;
1774
+ await ModelModifiers . CalculateTangents ( model , loggingFunction ) ;
1761
1775
1762
- return model ;
1776
+ await ModelModifiers . ConvertFlowData ( model , loggingFunction ) ;
1777
+
1778
+ ModelModifiers . CleanWeights ( model , loggingFunction ) ;
1779
+
1780
+ return model ;
1781
+ }
1763
1782
}
1764
1783
1765
1784
private static void MigrateImportDb ( SQLiteConnection db )
0 commit comments