From d636174c049bc10912b169e09d6058bf740882dc Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 8 Jul 2014 11:13:07 +0200 Subject: [PATCH] Added SkeletalMeshVertex struct Alias of VertexStruct_XYZ_Normal_UV_Tangent_Skinning Former-commit-id: 1bec60d399dd3293aebb7a7b84370ff33e8b85dd --- include/Nazara/Utility/Enums.hpp | 1 + include/Nazara/Utility/Mesh.hpp | 1 + include/Nazara/Utility/VertexStruct.hpp | 15 ++++++++++++++- src/Nazara/Utility/VertexDeclaration.cpp | 12 ++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index c6f3c7210..4ac0a08e1 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -254,6 +254,7 @@ enum nzVertexLayout nzVertexLayout_XYZ_Normal, nzVertexLayout_XYZ_Normal_UV, nzVertexLayout_XYZ_Normal_UV_Tangent, + nzVertexLayout_XYZ_Normal_UV_Tangent_Skinning, nzVertexLayout_XYZ_UV, // Déclarations destinées à l'instancing diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 5ba54966d..8c2036f05 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -47,6 +47,7 @@ class NzMesh; class NzPrimitiveList; typedef NzVertexStruct_XYZ_Normal_UV_Tangent NzMeshVertex; +typedef NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning NzSkeletalMeshVertex; using NzMeshConstRef = NzResourceRef; using NzMeshLoader = NzResourceLoader; diff --git a/include/Nazara/Utility/VertexStruct.hpp b/include/Nazara/Utility/VertexStruct.hpp index 905bbffa2..3b1d137e6 100644 --- a/include/Nazara/Utility/VertexStruct.hpp +++ b/include/Nazara/Utility/VertexStruct.hpp @@ -10,6 +10,8 @@ #include #include +/******************************* Structures 2D *******************************/ + struct NzVertexStruct_XY { NzVector2f position; @@ -20,7 +22,7 @@ struct NzVertexStruct_XY_UV : public NzVertexStruct_XY NzVector2f uv; }; -///////////////////////////////////////// +/******************************* Structures 3D *******************************/ struct NzVertexStruct_XYZ { @@ -47,4 +49,15 @@ struct NzVertexStruct_XYZ_UV : public NzVertexStruct_XYZ NzVector2f uv; }; +/************************* Structures 3D (+ Skinning) ************************/ + +struct NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning : public NzVertexStruct_XYZ_Normal_UV_Tangent +{ + nzInt32 weightCount; + + NzVector4f weights; + NzVector4i32 jointIndexes; +}; + + #endif // NAZARA_VERTEXSTRUCT_HPP diff --git a/src/Nazara/Utility/VertexDeclaration.cpp b/src/Nazara/Utility/VertexDeclaration.cpp index 5a6adb684..b282e570b 100644 --- a/src/Nazara/Utility/VertexDeclaration.cpp +++ b/src/Nazara/Utility/VertexDeclaration.cpp @@ -247,6 +247,18 @@ bool NzVertexDeclaration::Initialize() NazaraAssert(declaration->GetStride() == sizeof(NzVertexStruct_XYZ_Normal_UV_Tangent), "Invalid stride for declaration nzVertexLayout_XYZ_Normal_UV_Tangent"); + // nzVertexLayout_XYZ_Normal_UV_Tangent_Skinning : NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning + declaration = &s_declarations[nzVertexLayout_XYZ_Normal_UV_Tangent_Skinning]; + declaration->EnableAttribute(nzAttributeUsage_Position, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, position)); + declaration->EnableAttribute(nzAttributeUsage_Normal, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, normal)); + declaration->EnableAttribute(nzAttributeUsage_TexCoord, nzAttributeType_Float2, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, uv)); + declaration->EnableAttribute(nzAttributeUsage_Tangent, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, tangent)); + declaration->EnableAttribute(nzAttributeUsage_Unused, nzAttributeType_Int1, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, weightCount)); + declaration->EnableAttribute(nzAttributeUsage_Userdata0, nzAttributeType_Float4, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, weights)); + declaration->EnableAttribute(nzAttributeUsage_Userdata1, nzAttributeType_Int4, NzOffsetOf(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning, jointIndexes)); + + NazaraAssert(declaration->GetStride() == sizeof(NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning), "Invalid stride for declaration nzVertexLayout_XYZ_Normal_UV_Tangent_Skinning"); + // nzVertexLayout_XYZ_UV : NzVertexStruct_XYZ_UV declaration = &s_declarations[nzVertexLayout_XYZ_UV]; declaration->EnableAttribute(nzAttributeUsage_Position, nzAttributeType_Float3, NzOffsetOf(NzVertexStruct_XYZ_UV, position));