/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #pragma once #include #include #include #include namespace AtomSampleViewer { struct SkinnedMeshConfig { int m_segmentCount = 8; int m_verticesPerSegment = 8; int m_boneCount = 4; int m_influencesPerVertex = 4; int m_subMeshCount = 2; }; //! Class for creating SkinnedMeshInputBuffers with arbitrary bone/vertex counts //! Assumes z-up right handed coordinate system class ProceduralSkinnedMesh { public: void Resize(SkinnedMeshConfig& skinnedMeshConfig); void UpdateAnimation(float time, bool useOutOfSyncBoneAnimation = false); uint32_t GetInfluencesPerVertex() const; uint32_t GetSubMeshCount() const; float GetSubMeshYOffset() const; uint32_t GetVertexCount() const; uint32_t GetAlignedVertCountForRGBStream() const; uint32_t GetAlignedVertCountForRGBAStream() const; static const uint32_t MaxInfluencesPerVertex = 4; // Mesh data that's used for rendering AZ::Aabb m_aabb = AZ::Aabb::CreateNull(); AZStd::vector m_indices; AZStd::vector m_positions; AZStd::vector m_normals; AZStd::vector m_tangents; AZStd::vector m_bitangents; AZStd::vector m_blendIndices; AZStd::vector m_blendWeights; AZStd::vector> m_uvs; AZStd::vector m_boneMatrices; private: void CalculateBones(); void CalculateSegments(); void CalculateVertexBuffers(); // Extra values that are used while generating per-vertex data AZStd::vector m_boneHeights; AZStd::vector m_segmentHeights; AZStd::vector m_segmentBlendIndices; AZStd::vector m_segmentBlendWeights; AZStd::vector m_segmentHeightOffsets; uint32_t m_boneCount = 0; uint32_t m_vertexCount = 0; uint32_t m_alignedVertCountForRGBStream = 0; uint32_t m_alignedVertCountForRGBAStream = 0; uint32_t m_verticesPerSegment = 0; uint32_t m_segmentCount = 0; uint32_t m_influencesPerVertex = 0; uint32_t m_subMeshCount = 0; float m_height = 1.0f; float m_radius = 0.1f; }; } // namespace AtomSampleViewer