// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "Math/UnrealMathSSE.h" #include "Math/Vector2D.h" #include "Math/Vector4.h" #include "MeshAttributeArray.h" #include "MeshAttributes.h" #include "MeshDescription.h" #include "UObject/NameTypes.h" namespace MeshAttribute { namespace Vertex { } namespace VertexInstance { extern STATICMESHDESCRIPTION_API const FName TextureCoordinate; extern STATICMESHDESCRIPTION_API const FName Normal; extern STATICMESHDESCRIPTION_API const FName Tangent; extern STATICMESHDESCRIPTION_API const FName BinormalSign; extern STATICMESHDESCRIPTION_API const FName Color; } namespace Edge { extern STATICMESHDESCRIPTION_API const FName IsHard; } namespace Triangle { extern STATICMESHDESCRIPTION_API const FName Normal; extern STATICMESHDESCRIPTION_API const FName Tangent; extern STATICMESHDESCRIPTION_API const FName Binormal; } namespace Polygon { extern STATICMESHDESCRIPTION_API const FName ObjectName; } namespace PolygonGroup { extern STATICMESHDESCRIPTION_API const FName ImportedMaterialSlotName; } } class FStaticMeshAttributes : public FMeshAttributes { public: explicit FStaticMeshAttributes(FMeshDescription& InMeshDescription) : FMeshAttributes(InMeshDescription) {} STATICMESHDESCRIPTION_API virtual void Register(bool bKeepExistingAttribute = false) override; static bool IsReservedAttributeName(const FName InAttributeName) { return FMeshAttributes::IsReservedAttributeName(InAttributeName) || InAttributeName == MeshAttribute::VertexInstance::TextureCoordinate || InAttributeName == MeshAttribute::VertexInstance::Normal || InAttributeName == MeshAttribute::VertexInstance::Tangent || InAttributeName == MeshAttribute::VertexInstance::BinormalSign || InAttributeName == MeshAttribute::VertexInstance::Color || InAttributeName == MeshAttribute::Edge::IsHard || InAttributeName == MeshAttribute::Triangle::Normal || InAttributeName == MeshAttribute::Triangle::Tangent || InAttributeName == MeshAttribute::Triangle::Binormal || InAttributeName == MeshAttribute::Polygon::ObjectName || InAttributeName == MeshAttribute::PolygonGroup::ImportedMaterialSlotName ; } STATICMESHDESCRIPTION_API void RegisterTriangleNormalAndTangentAttributes(); /** Registers a mesh attribute that is used to store the name of the object that contributed to each polygon. Used to partition the mesh * into sub-objects, if needed. * See GetPolygonObjectNames. */ STATICMESHDESCRIPTION_API void RegisterPolygonObjectNameAttribute(); TVertexInstanceAttributesRef GetVertexInstanceUVs() { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::TextureCoordinate); } TVertexInstanceAttributesConstRef GetVertexInstanceUVs() const { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::TextureCoordinate); } TVertexInstanceAttributesRef GetVertexInstanceNormals() { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::Normal); } TVertexInstanceAttributesConstRef GetVertexInstanceNormals() const { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::Normal); } TVertexInstanceAttributesRef GetVertexInstanceTangents() { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::Tangent); } TVertexInstanceAttributesConstRef GetVertexInstanceTangents() const { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::Tangent); } TVertexInstanceAttributesRef GetVertexInstanceBinormalSigns() { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::BinormalSign); } TVertexInstanceAttributesConstRef GetVertexInstanceBinormalSigns() const { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::BinormalSign); } TVertexInstanceAttributesRef GetVertexInstanceColors() { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::Color); } TVertexInstanceAttributesConstRef GetVertexInstanceColors() const { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::Color); } TEdgeAttributesRef GetEdgeHardnesses() { return MeshDescription.EdgeAttributes().GetAttributesRef(MeshAttribute::Edge::IsHard); } TEdgeAttributesConstRef GetEdgeHardnesses() const { return MeshDescription.EdgeAttributes().GetAttributesRef(MeshAttribute::Edge::IsHard); } TTriangleAttributesRef GetTriangleNormals() { return MeshDescription.TriangleAttributes().GetAttributesRef(MeshAttribute::Triangle::Normal); } TTriangleAttributesConstRef GetTriangleNormals() const { return MeshDescription.TriangleAttributes().GetAttributesRef(MeshAttribute::Triangle::Normal); } TTriangleAttributesRef GetTriangleTangents() { return MeshDescription.TriangleAttributes().GetAttributesRef(MeshAttribute::Triangle::Tangent); } TTriangleAttributesConstRef GetTriangleTangents() const { return MeshDescription.TriangleAttributes().GetAttributesRef(MeshAttribute::Triangle::Tangent); } TTriangleAttributesRef GetTriangleBinormals() { return MeshDescription.TriangleAttributes().GetAttributesRef(MeshAttribute::Triangle::Binormal); } TTriangleAttributesConstRef GetTriangleBinormals() const { return MeshDescription.TriangleAttributes().GetAttributesRef(MeshAttribute::Triangle::Binormal); } /** This attribute stores the name of the object that this part of the mesh was generated from, e.g. from a sub-object during import or during mesh merging. */ TPolygonAttributesRef GetPolygonObjectNames() { return MeshDescription.PolygonAttributes().GetAttributesRef(MeshAttribute::Polygon::ObjectName); } TPolygonAttributesConstRef GetPolygonObjectNames() const { return MeshDescription.PolygonAttributes().GetAttributesRef(MeshAttribute::Polygon::ObjectName); } TPolygonGroupAttributesRef GetPolygonGroupMaterialSlotNames() { return MeshDescription.PolygonGroupAttributes().GetAttributesRef(MeshAttribute::PolygonGroup::ImportedMaterialSlotName); } TPolygonGroupAttributesConstRef GetPolygonGroupMaterialSlotNames() const { return MeshDescription.PolygonGroupAttributes().GetAttributesRef(MeshAttribute::PolygonGroup::ImportedMaterialSlotName); } }; class FStaticMeshConstAttributes : public FMeshConstAttributes { public: explicit FStaticMeshConstAttributes(const FMeshDescription& InMeshDescription) : FMeshConstAttributes(InMeshDescription) {} TVertexInstanceAttributesConstRef GetVertexInstanceUVs() const { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::TextureCoordinate); } TVertexInstanceAttributesConstRef GetVertexInstanceNormals() const { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::Normal); } TVertexInstanceAttributesConstRef GetVertexInstanceTangents() const { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::Tangent); } TVertexInstanceAttributesConstRef GetVertexInstanceBinormalSigns() const { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::BinormalSign); } TVertexInstanceAttributesConstRef GetVertexInstanceColors() const { return MeshDescription.VertexInstanceAttributes().GetAttributesRef(MeshAttribute::VertexInstance::Color); } TEdgeAttributesConstRef GetEdgeHardnesses() const { return MeshDescription.EdgeAttributes().GetAttributesRef(MeshAttribute::Edge::IsHard); } TTriangleAttributesConstRef GetTriangleNormals() const { return MeshDescription.TriangleAttributes().GetAttributesRef(MeshAttribute::Triangle::Normal); } TTriangleAttributesConstRef GetTriangleTangents() const { return MeshDescription.TriangleAttributes().GetAttributesRef(MeshAttribute::Triangle::Tangent); } TTriangleAttributesConstRef GetTriangleBinormals() const { return MeshDescription.TriangleAttributes().GetAttributesRef(MeshAttribute::Triangle::Binormal); } TPolygonAttributesConstRef GetPolygonObjectNames() const { return MeshDescription.PolygonAttributes().GetAttributesRef(MeshAttribute::Polygon::ObjectName); } TPolygonGroupAttributesConstRef GetPolygonGroupMaterialSlotNames() const { return MeshDescription.PolygonGroupAttributes().GetAttributesRef(MeshAttribute::PolygonGroup::ImportedMaterialSlotName); } };