-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from NotAdam/xande
Pull in what we have for Xande so far
- Loading branch information
Showing
6 changed files
with
81 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,54 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Lumina.Data.Files; | ||
|
||
namespace Lumina.Models.Models | ||
{ | ||
public class Shape | ||
{ | ||
public string ShapeName { get; private set; } | ||
public struct ShapeMesh { | ||
public Mesh AssociatedMesh; | ||
|
||
public ( ushort BaseIndicesIndex, ushort ReplacedVertexIndex )[] Values; | ||
|
||
public static IReadOnlyList< ShapeMesh > ConstructList( MdlFile file, IReadOnlyList< Mesh > meshes ) | ||
{ | ||
var ret = new ShapeMesh[ file.ModelHeader.ShapeMeshCount ]; | ||
var idx = 0; | ||
|
||
var meshDict = meshes.ToDictionary( m => file.Meshes[ m.MeshIndex ].StartIndex, m => m ); | ||
|
||
foreach( var shapeMeshStruct in file.ShapeMeshes ) { | ||
|
||
if( !meshDict.TryGetValue( shapeMeshStruct.MeshIndexOffset, out var mesh ) ) continue; | ||
|
||
var values = Enumerable | ||
.Range( (int)shapeMeshStruct.ShapeValueOffset, (int)shapeMeshStruct.ShapeValueCount ) | ||
.Select( i => ( file.ShapeValues[ i ].BaseIndicesIndex, file.ShapeValues[ i ].ReplacingVertexIndex ) ) | ||
.ToArray(); | ||
|
||
ret[ idx++ ] = new ShapeMesh { | ||
AssociatedMesh = mesh, | ||
Values = values, | ||
}; | ||
} | ||
|
||
return ret; | ||
} | ||
} | ||
|
||
public class Shape { | ||
public string Name { get; private set; } | ||
public ShapeMesh[] Meshes { get; private set; } | ||
|
||
public Shape(Model model, int shapeIndex) | ||
public Shape( Model model, Model.ModelLod lod, IReadOnlyList< ShapeMesh > shapeMeshes, int shapeIndex ) | ||
{ | ||
var currentShape = model.File.Shapes[ shapeIndex ]; | ||
ShapeName = model.StringOffsetToStringMap[ (int) currentShape.StringOffset ]; | ||
|
||
// TODO: shape index modifier things | ||
// someone else do this pls | ||
Name = model.StringOffsetToStringMap[ (int)currentShape.StringOffset ]; | ||
Meshes = new ShapeMesh[ currentShape.ShapeMeshCount[ (int)lod ] ]; | ||
var end = currentShape.ShapeMeshCount[ (int)lod ]; | ||
var offset = currentShape.ShapeMeshStartIndex[ (int)lod ]; | ||
for( var i = 0; i < end; ++i ) { | ||
Meshes[ i ] = shapeMeshes[ i + offset ]; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters