@@ -1397,6 +1397,10 @@ public async Task<Dictionary<string, string>> ImportModel(IItemModel item, XivMd
1397
1397
// A dictionary containing error messages if there are any so that a single exception can be thrown with all available context
1398
1398
var errorDictionary = new Dictionary < int , string > ( ) ;
1399
1399
1400
+ // Calculations for bounding boxes.
1401
+ var maxPos = Vector3 . Zero ;
1402
+ var minPos = Vector3 . Zero ;
1403
+
1400
1404
// Check for missing data and add dummy data if possible or throw exception
1401
1405
for ( var i = 0 ; i < meshPartDataDictionary . Count ; i ++ )
1402
1406
{
@@ -1462,6 +1466,7 @@ public async Task<Dictionary<string, string>> ImportModel(IItemModel item, XivMd
1462
1466
throw new Exception ( errorString ) ;
1463
1467
}
1464
1468
1469
+
1465
1470
var indexListList = new List < List < int [ ] > > ( ) ;
1466
1471
var partStartingIndexDicList = new List < Dictionary < ( int Start , int End ) , Dictionary < string , int > > > ( ) ;
1467
1472
for ( var i = 0 ; i < meshPartDataDictionary . Count ; i ++ )
@@ -1491,6 +1496,7 @@ public async Task<Dictionary<string, string>> ImportModel(IItemModel item, XivMd
1491
1496
var biNormalMax = 0 ;
1492
1497
var vColorAlphaMax = 0 ;
1493
1498
1499
+
1494
1500
if ( partDataDict . Count > 0 )
1495
1501
{
1496
1502
var startingIndex = 0 ;
@@ -1523,8 +1529,10 @@ public async Task<Dictionary<string, string>> ImportModel(IItemModel item, XivMd
1523
1529
}
1524
1530
1525
1531
// Consolidate all index data into one Collada Data per mesh
1532
+
1526
1533
for ( var k = 0 ; k < partDataDict [ partNum ] . PositionIndices . Count ; k ++ )
1527
1534
{
1535
+
1528
1536
meshDataDictionary [ i ] . Indices . Add ( partDataDict [ partNum ] . PositionIndices [ k ] + positionMax ) ;
1529
1537
meshDataDictionary [ i ] . Indices . Add ( partDataDict [ partNum ] . NormalIndices [ k ] + normalMax ) ;
1530
1538
meshDataDictionary [ i ] . Indices . Add ( partDataDict [ partNum ] . TextureCoordinate0Indices [ k ] + texCoord0Max ) ;
@@ -1745,9 +1753,18 @@ Dictionary<string,int> GetIndexLocDictionary(int meshIndex,int index,string key)
1745
1753
1746
1754
for ( var i = 0 ; i < colladaData . Positions . Count ; i += 3 )
1747
1755
{
1748
- positionCollection . Add ( new Vector3 ( ( colladaData . Positions [ i ] / ModelMultiplier ) ,
1756
+
1757
+ var pos = new Vector3 ( ( colladaData . Positions [ i ] / ModelMultiplier ) ,
1749
1758
( colladaData . Positions [ i + 1 ] / ModelMultiplier ) ,
1750
- ( colladaData . Positions [ i + 2 ] / ModelMultiplier ) ) ) ;
1759
+ ( colladaData . Positions [ i + 2 ] / ModelMultiplier ) ) ;
1760
+
1761
+ maxPos . X = maxPos . X > pos . X ? maxPos . X : pos . X ;
1762
+ maxPos . Y = maxPos . Y > pos . Y ? maxPos . Y : pos . Y ;
1763
+ maxPos . Z = maxPos . Z > pos . Z ? maxPos . Z : pos . Z ;
1764
+ minPos . X = minPos . X < pos . X ? minPos . X : pos . X ;
1765
+ minPos . Y = minPos . Y < pos . Y ? minPos . Y : pos . Y ;
1766
+ minPos . Z = minPos . Z < pos . Z ? minPos . Z : pos . Z ;
1767
+ positionCollection . Add ( pos ) ;
1751
1768
}
1752
1769
1753
1770
for ( var i = 0 ; i < colladaData . Normals . Count ; i += 3 )
@@ -2377,6 +2394,17 @@ Dictionary<string,int> GetIndexLocDictionary(int meshIndex,int index,string key)
2377
2394
warningsDictionary . Add ( $ "Weight Corrections", weightErrorString ) ;
2378
2395
}
2379
2396
2397
+ xivMdl . BoundBox . PointList [ 0 ] = new Vector4 ( minPos , 1 ) ;
2398
+ xivMdl . BoundBox . PointList [ 1 ] = new Vector4 ( maxPos , 1 ) ;
2399
+ xivMdl . BoundBox . PointList [ 2 ] = new Vector4 ( minPos , 1 ) ;
2400
+ xivMdl . BoundBox . PointList [ 3 ] = new Vector4 ( maxPos , 1 ) ;
2401
+ xivMdl . BoundBox . PointList [ 4 ] = new Vector4 ( 0 , 0 , 0 , 0 ) ;
2402
+ xivMdl . BoundBox . PointList [ 5 ] = new Vector4 ( 0 , 0 , 0 , 0 ) ;
2403
+ xivMdl . BoundBox . PointList [ 6 ] = new Vector4 ( 0 , 0 , 0 , 0 ) ;
2404
+ xivMdl . BoundBox . PointList [ 7 ] = new Vector4 ( 0 , 0 , 0 , 0 ) ;
2405
+ //xivMdl.BoundBox.PointList[1] = Vector(;
2406
+ //xivMdl.BoundBox.PointList[2] = minPos;
2407
+
2380
2408
await MakeNewMdlFile ( colladaMeshDataList , item , xivMdl , advImportSettings , source , rawDataOnly ) ;
2381
2409
2382
2410
return warningsDictionary ;
@@ -3934,7 +3962,7 @@ private async Task MakeNewMdlFile(List<ColladaMeshData> colladaMeshDataList, IIt
3934
3962
#region Bounding Box Data Block
3935
3963
3936
3964
var boundingBoxDataBlock = new List < byte > ( ) ;
3937
-
3965
+
3938
3966
var boundingBox = xivMdl . BoundBox ;
3939
3967
3940
3968
foreach ( var point in boundingBox . PointList )
0 commit comments