diff --git a/Assets/Scripts/OpenTS2/Content/DBPF/Scenegraph/ScenegraphModelAsset.cs b/Assets/Scripts/OpenTS2/Content/DBPF/Scenegraph/ScenegraphModelAsset.cs index e5da95d..7d8179c 100644 --- a/Assets/Scripts/OpenTS2/Content/DBPF/Scenegraph/ScenegraphModelAsset.cs +++ b/Assets/Scripts/OpenTS2/Content/DBPF/Scenegraph/ScenegraphModelAsset.cs @@ -223,7 +223,6 @@ namespace OpenTS2.Content.DBPF.Scenegraph // 3rd delta map. var deltaMapIdx = (3 - byteIdx); Debug.Assert(deltaMapIdx < vertexPosDeltas.Length); - Debug.Assert(deltaMapIdx < vertexNormDeltas.Length); var morphTarget = morphTargets[(int)vertexMapByte]; if (animations[vertexMapByte] == null) @@ -232,7 +231,11 @@ namespace OpenTS2.Content.DBPF.Scenegraph } animations[vertexMapByte].VertexPositionDeltas[i] = vertexPosDeltas[deltaMapIdx].Data[i]; - animations[vertexMapByte].VertexNormalDeltas[i] = vertexNormDeltas[deltaMapIdx].Data[i]; + // Optionally the normal morph might be defined. + if (deltaMapIdx < vertexNormDeltas.Length) + { + animations[vertexMapByte].VertexNormalDeltas[i] = vertexNormDeltas[deltaMapIdx].Data[i]; + } } } diff --git a/Assets/Scripts/OpenTS2/Engine/Tests/ScenegraphGMDCTest.cs b/Assets/Scripts/OpenTS2/Engine/Tests/ScenegraphGMDCTest.cs index e1cdd51..2973b6a 100644 --- a/Assets/Scripts/OpenTS2/Engine/Tests/ScenegraphGMDCTest.cs +++ b/Assets/Scripts/OpenTS2/Engine/Tests/ScenegraphGMDCTest.cs @@ -16,7 +16,7 @@ public class ScenegraphGMDCTest : MonoBehaviour Filesystem.GetPackagesInDirectory(Filesystem.GetDataPathForProduct(ProductFlags.BaseGame) + "/Res/Sims3D")); var resource = contentProvider.GetAsset( - new ResourceKey("chairReclinerPuffy_cres", GroupIDs.Scenegraph, TypeIDs.SCENEGRAPH_CRES)); + new ResourceKey("puFace_cres", GroupIDs.Scenegraph, TypeIDs.SCENEGRAPH_CRES)); Debug.Log($"scenegraphModel: {resource.GlobalTGI}"); var gameObject = resource.CreateRootGameObject(); diff --git a/Assets/Scripts/OpenTS2/Rendering/MaterialManager.cs b/Assets/Scripts/OpenTS2/Rendering/MaterialManager.cs index 42986b0..12eb44a 100644 --- a/Assets/Scripts/OpenTS2/Rendering/MaterialManager.cs +++ b/Assets/Scripts/OpenTS2/Rendering/MaterialManager.cs @@ -29,6 +29,7 @@ namespace OpenTS2.Rendering RegisterMaterial(); RegisterMaterial(); + RegisterMaterial(); // Ideally we'd just disable the mesh renderer to save a draw call but Maxis had to make it weird of course. // Could maybe have an ApplyToRenderer(MeshRenderer, MaterialDef) function that does just that if the material def is Null instead. diff --git a/Assets/Scripts/OpenTS2/Rendering/Materials/SimStandardMaterial.cs b/Assets/Scripts/OpenTS2/Rendering/Materials/SimStandardMaterial.cs new file mode 100644 index 0000000..92728e1 --- /dev/null +++ b/Assets/Scripts/OpenTS2/Rendering/Materials/SimStandardMaterial.cs @@ -0,0 +1,7 @@ +namespace OpenTS2.Rendering.Materials +{ + public class SimStandardMaterial : StandardMaterial + { + public override string Name => "SimStandardMaterial"; + } +} \ No newline at end of file diff --git a/Assets/Scripts/OpenTS2/Rendering/Materials/SimStandardMaterial.cs.meta b/Assets/Scripts/OpenTS2/Rendering/Materials/SimStandardMaterial.cs.meta new file mode 100644 index 0000000..e1e0eb2 --- /dev/null +++ b/Assets/Scripts/OpenTS2/Rendering/Materials/SimStandardMaterial.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4b25adaa292949a5a9ae02a93159de09 +timeCreated: 1691541379 \ No newline at end of file