Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,118 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneData/GraphData/AnimationData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
AnimationData::AnimationData()
: m_timeStepBetweenFrames(1.0/30.0) // default value
{
}
void AnimationData::AddKeyFrame(const SceneAPI::DataTypes::MatrixType& keyFrameTransform)
{
m_keyFrames.push_back(keyFrameTransform);
}
void AnimationData::ReserveKeyFrames(size_t count)
{
m_keyFrames.reserve(count);
}
void AnimationData::SetTimeStepBetweenFrames(double timeStep)
{
m_timeStepBetweenFrames = timeStep;
}
size_t AnimationData::GetKeyFrameCount() const
{
return m_keyFrames.size();
}
const SceneAPI::DataTypes::MatrixType& AnimationData::GetKeyFrame(size_t index) const
{
AZ_Assert(index < m_keyFrames.size(), "GetTranslationKeyFrame index %i is out of range for frame size %i", index, m_keyFrames.size());
return m_keyFrames[index];
}
double AnimationData::GetTimeStepBetweenFrames() const
{
return m_timeStepBetweenFrames;
}
void AnimationData::GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("KeyFrames", m_keyFrames);
output.Write("TimeStepBetweenFrames", m_timeStepBetweenFrames);
}
BlendShapeAnimationData::BlendShapeAnimationData()
: m_timeStepBetweenFrames(1 / 30.0) // default value
{
}
void BlendShapeAnimationData::SetBlendShapeName(const char* blendShapeName)
{
m_blendShapeName = blendShapeName;
}
void BlendShapeAnimationData::AddKeyFrame(double keyFrameValue)
{
m_keyFrames.push_back(keyFrameValue);
}
void BlendShapeAnimationData::ReserveKeyFrames(size_t count)
{
m_keyFrames.reserve(count);
}
void BlendShapeAnimationData::SetTimeStepBetweenFrames(double timeStep)
{
m_timeStepBetweenFrames = timeStep;
}
const char* BlendShapeAnimationData::GetBlendShapeName() const
{
return m_blendShapeName.c_str();
}
size_t BlendShapeAnimationData::GetKeyFrameCount() const
{
return m_keyFrames.size();
}
double BlendShapeAnimationData::GetKeyFrame(size_t index) const
{
AZ_Assert(index < m_keyFrames.size(), "BlendShapeAnimationData::GetKeyFrame index %i is out of range for frame count %i", index, m_keyFrames.size());
return m_keyFrames[index];
}
double BlendShapeAnimationData::GetTimeStepBetweenFrames() const
{
return m_timeStepBetweenFrames;
}
void BlendShapeAnimationData::GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("BlendShapeName", m_blendShapeName);
output.Write("KeyFrames", m_keyFrames);
output.Write("TimeStepBetweenFrames", m_timeStepBetweenFrames);
}
}
}
}
@@ -0,0 +1,77 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/std/string/string.h>
#include <AzCore/std/containers/vector.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IAnimationData.h>
#include <SceneAPI/SceneCore/DataTypes/MatrixType.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS AnimationData
: public SceneAPI::DataTypes::IAnimationData
{
public:
AZ_RTTI(AnimationData, "{D350732E-4727-41C8-95E0-FBAF5F2AC074}", SceneAPI::DataTypes::IAnimationData);
SCENE_DATA_API AnimationData();
SCENE_DATA_API ~AnimationData() override = default;
SCENE_DATA_API virtual void AddKeyFrame(const SceneAPI::DataTypes::MatrixType& keyFrameTransform);
SCENE_DATA_API virtual void ReserveKeyFrames(size_t count);
SCENE_DATA_API virtual void SetTimeStepBetweenFrames(double timeStep);
SCENE_DATA_API size_t GetKeyFrameCount() const override;
SCENE_DATA_API const SceneAPI::DataTypes::MatrixType& GetKeyFrame(size_t index) const override;
SCENE_DATA_API double GetTimeStepBetweenFrames() const override;
SCENE_DATA_API void GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<SceneAPI::DataTypes::MatrixType> m_keyFrames;
double m_timeStepBetweenFrames;
};
class BlendShapeAnimationData
: public SceneAPI::DataTypes::IBlendShapeAnimationData
{
public:
AZ_RTTI(BlendShapeAnimationData, "{02766CCF-BDA7-46B6-9BB1-58A90C1AD6AA}", SceneAPI::DataTypes::IBlendShapeAnimationData);
SCENE_DATA_API BlendShapeAnimationData();
SCENE_DATA_API ~BlendShapeAnimationData() override = default;
SCENE_DATA_API virtual void SetBlendShapeName(const char* name);
SCENE_DATA_API virtual void AddKeyFrame(double keyFrameValue);
SCENE_DATA_API virtual void ReserveKeyFrames(size_t count);
SCENE_DATA_API virtual void SetTimeStepBetweenFrames(double timeStep);
SCENE_DATA_API const char* GetBlendShapeName() const override;
SCENE_DATA_API size_t GetKeyFrameCount() const override;
SCENE_DATA_API double GetKeyFrame(size_t index) const override;
SCENE_DATA_API double GetTimeStepBetweenFrames() const override;
SCENE_DATA_API void GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::string m_blendShapeName;
AZStd::vector<double> m_keyFrames;
double m_timeStepBetweenFrames;
};
}
}
}
@@ -0,0 +1,110 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/Casting/numeric_cast.h>
#include <SceneAPI/SceneData/GraphData/BlendShapeData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
namespace DataTypes = SceneAPI::DataTypes;
BlendShapeData::~BlendShapeData() = default;
unsigned int BlendShapeData::AddVertex(const Vector3& position, const Vector3& normal)
{
m_positions.push_back(position);
m_normals.push_back(normal);
return static_cast<unsigned int>(m_positions.size()-1);
}
void BlendShapeData::AddFace(const Face& face)
{
m_faces.push_back(face);
}
void BlendShapeData::SetVertexIndexToControlPointIndexMap(int vertexIndex, int controlPointIndex)
{
m_vertexIndexToControlPointIndexMap[vertexIndex] = controlPointIndex;
// The above hashmap stores the control point index (value) per vertex (key).
// We construct an unordered set and fill in the control point indices in order to get access to the number of unique control points indices.
m_controlPointToUsedVertexIndexMap.emplace(controlPointIndex, aznumeric_cast<unsigned int>(m_controlPointToUsedVertexIndexMap.size()));
}
int BlendShapeData::GetControlPointIndex(int vertexIndex) const
{
auto iter = m_vertexIndexToControlPointIndexMap.find(vertexIndex);
AZ_Assert(iter != m_vertexIndexToControlPointIndexMap.end(), "Vertex index %i doesn't exist", vertexIndex);
// Note: AZStd::unordered_map's operator [] doesn't have const version...
return iter->second;
}
size_t BlendShapeData::GetUsedControlPointCount() const
{
return m_controlPointToUsedVertexIndexMap.size();
}
int BlendShapeData::GetUsedPointIndexForControlPoint(int controlPointIndex) const
{
auto iter = m_controlPointToUsedVertexIndexMap.find(controlPointIndex);
if (iter != m_controlPointToUsedVertexIndexMap.end())
{
return iter->second;
}
else
{
return -1; // That control point is not used in this mesh
}
}
unsigned int BlendShapeData::GetVertexCount() const
{
return static_cast<unsigned int>(m_positions.size());
}
unsigned int BlendShapeData::GetFaceCount() const
{
return static_cast<unsigned int>(m_faces.size());
}
const Vector3& BlendShapeData::GetPosition(unsigned int index) const
{
AZ_Assert(index < m_positions.size(), "GetPosition index not in range");
return m_positions[index];
}
const Vector3& BlendShapeData::GetNormal(unsigned int index) const
{
AZ_Assert(index < m_normals.size(), "GetNormal index not in range");
return m_normals[index];
}
unsigned int BlendShapeData::GetFaceVertexIndex(unsigned int face, unsigned int vertexIndex) const
{
AZ_Assert(face < m_faces.size(), "GetFaceVertexPositionIndex face index not in range");
AZ_Assert(vertexIndex < 3, "GetFaceVertexPositionIndex vertexIndex index not in range");
return m_faces[face].vertexIndex[vertexIndex];
}
void BlendShapeData::GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("Positions", m_positions);
output.Write("Normals", m_normals);
output.Write("Faces", m_faces);
}
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,66 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IBlendShapeData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS BlendShapeData
: public SceneAPI::DataTypes::IBlendShapeData
{
public:
AZ_RTTI(BlendShapeData, "{FF875C22-2E4F-4CE3-BA49-09BF78C70A09}", SceneAPI::DataTypes::IBlendShapeData)
SCENE_DATA_API ~BlendShapeData() override;
SCENE_DATA_API virtual unsigned int AddVertex(const Vector3& position, const Vector3& normal);
//assume consistent winding - no stripping or fanning expected (3 index per face)
SCENE_DATA_API virtual void AddFace(const Face& face);
SCENE_DATA_API void SetVertexIndexToControlPointIndexMap(int vertexIndex, int controlPointIndex);
SCENE_DATA_API size_t GetUsedControlPointCount() const override;
SCENE_DATA_API int GetControlPointIndex(int vertexIndex) const override;
SCENE_DATA_API int GetUsedPointIndexForControlPoint(int controlPointIndex) const override;
//assume consistent winding - no stripping or fanning expected (3 index per face)
SCENE_DATA_API unsigned int GetVertexCount() const override;
SCENE_DATA_API unsigned int GetFaceCount() const override;
SCENE_DATA_API const Vector3& GetPosition(unsigned int index) const override;
SCENE_DATA_API const Vector3& GetNormal(unsigned int index) const override;
SCENE_DATA_API unsigned int GetFaceVertexIndex(unsigned int face, unsigned int vertexIndex) const override;
SCENE_DATA_API void GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<Vector3> m_positions;
AZStd::vector<Vector3> m_normals;
AZStd::vector<Face> m_faces;
AZStd::unordered_map<int, int> m_vertexIndexToControlPointIndexMap;
AZStd::unordered_map<int, int> m_controlPointToUsedVertexIndexMap;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,51 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <SceneAPI/SceneData/GraphData/BoneData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
void BoneData::SetWorldTransform(const SceneAPI::DataTypes::MatrixType& transform)
{
m_worldTransform = transform;
}
const SceneAPI::DataTypes::MatrixType& BoneData::GetWorldTransform() const
{
return m_worldTransform;
}
void BoneData::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<BoneData>()->Version(1)
->Field("worldTransform", &BoneData::m_worldTransform);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<BoneData>("Bone data", "Data this individual bone contributes to the overall skeleton.")
->DataElement(AZ::Edit::UIHandlers::Default, &BoneData::m_worldTransform, "World", "World transform this bone contributes to the overall skeleton.");
}
}
}
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,42 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IBoneData.h>
namespace AZ
{
class ReflectContext;
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS BoneData
: public AZ::SceneAPI::DataTypes::IBoneData
{
public:
AZ_RTTI(BoneData, "{EDFB7CDB-DA39-41F1-800D-1E10421849E5}", AZ::SceneAPI::DataTypes::IBoneData);
SCENE_DATA_API void SetWorldTransform(const SceneAPI::DataTypes::MatrixType& transform);
SCENE_DATA_API const SceneAPI::DataTypes::MatrixType& GetWorldTransform() const override;
static void Reflect(ReflectContext* context);
protected:
SceneAPI::DataTypes::MatrixType m_worldTransform;
};
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,192 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <SceneAPI/SceneData/GraphData/MaterialData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
namespace DataTypes = AZ::SceneAPI::DataTypes;
const AZStd::string MaterialData::s_DiffuseMapName = "Diffuse";
const AZStd::string MaterialData::s_SpecularMapName = "Specular";
const AZStd::string MaterialData::s_BumpMapName = "Bump";
const AZStd::string MaterialData::s_emptyString = "";
MaterialData::MaterialData()
: m_isNoDraw(false)
, m_diffuseColor(AZ::Vector3::CreateOne())
, m_specularColor(AZ::Vector3::CreateZero())
, m_emissiveColor(AZ::Vector3::CreateZero())
, m_opacity(1.f)
, m_shininess(10.f)
{
}
void MaterialData::SetMaterialName(AZStd::string materialName)
{
m_materialName = AZStd::move(materialName);
}
const AZStd::string& MaterialData::GetMaterialName() const
{
return m_materialName;
}
void MaterialData::SetTexture(TextureMapType mapType, const char* textureFileName)
{
if (textureFileName)
{
SetTexture(mapType, AZStd::string(textureFileName));
}
}
void MaterialData::SetTexture(TextureMapType mapType, const AZStd::string& textureFileName)
{
SetTexture(mapType, AZStd::string(textureFileName));
}
void MaterialData::SetTexture(TextureMapType mapType, AZStd::string&& textureFileName)
{
if (!textureFileName.empty())
{
m_textureMap[mapType] = AZStd::move(textureFileName);
}
}
const AZStd::string& MaterialData::GetTexture(TextureMapType mapType) const
{
auto result = m_textureMap.find(mapType);
if (result != m_textureMap.end())
{
return result->second;
}
return s_emptyString;
}
void MaterialData::SetNoDraw(bool isNoDraw)
{
m_isNoDraw = isNoDraw;
}
bool MaterialData::IsNoDraw() const
{
return m_isNoDraw;
}
void MaterialData::SetDiffuseColor(const AZ::Vector3& color)
{
m_diffuseColor = color;
}
void MaterialData::SetUniqueId(uint64_t uid)
{
m_uniqueId = uid;
}
const AZ::Vector3& MaterialData:: GetDiffuseColor() const
{
return m_diffuseColor;
}
void MaterialData::SetSpecularColor(const AZ::Vector3& color)
{
m_specularColor = color;
}
const AZ::Vector3& MaterialData::GetSpecularColor() const
{
return m_specularColor;
}
void MaterialData::SetEmissiveColor(const AZ::Vector3& color)
{
m_emissiveColor = color;
}
const AZ::Vector3& MaterialData::GetEmissiveColor() const
{
return m_emissiveColor;
}
void MaterialData::SetOpacity(float opacity)
{
m_opacity = opacity;
}
float MaterialData::GetOpacity() const
{
return m_opacity;
}
void MaterialData::SetShininess(float shininess)
{
m_shininess = shininess;
}
float MaterialData::GetShininess() const
{
return m_shininess;
}
uint64_t MaterialData::GetUniqueId() const
{
return m_uniqueId;
}
void MaterialData::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<MaterialData>()->Version(2)
->Field("textureMap", &MaterialData::m_textureMap)
->Field("diffuseColor", &MaterialData::m_diffuseColor)
->Field("specularColor", &MaterialData::m_specularColor)
->Field("emissiveColor", &MaterialData::m_emissiveColor)
->Field("opacity", &MaterialData::m_opacity)
->Field("shininess", &MaterialData::m_shininess)
->Field("noDraw", &MaterialData::m_isNoDraw)
->Field("uniqueId", &MaterialData::m_uniqueId);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<MaterialData>("Materials", "Material configuration for the parent.")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_diffuseColor, "Diffuse", "Diffuse color component of the material.")
->Attribute(Edit::Attributes::LabelForX, "R")
->Attribute(Edit::Attributes::LabelForY, "G")
->Attribute(Edit::Attributes::LabelForZ, "B")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_specularColor, "Specular", "Specular color component of the material.")
->Attribute(Edit::Attributes::LabelForX, "R")
->Attribute(Edit::Attributes::LabelForY, "G")
->Attribute(Edit::Attributes::LabelForZ, "B")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_emissiveColor, "Emissive", "Emissive color component of the material.")
->Attribute(Edit::Attributes::LabelForX, "R")
->Attribute(Edit::Attributes::LabelForY, "G")
->Attribute(Edit::Attributes::LabelForZ, "B")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_opacity, "Opacity", "Opacity strength of the material, with 0 fully transparent and 1 fully opaque.")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_shininess, "Shininess", "The shininess strength of the material.")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_isNoDraw, "No draw", "If enabled the mesh with material will not be drawn.")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_textureMap, "Texture map", "List of assigned texture slots.");
}
}
}
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,88 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMaterialData.h>
#include <AzCore/std/containers/unordered_map.h>
namespace AZ
{
class ReflectContext;
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS MaterialData
: public AZ::SceneAPI::DataTypes::IMaterialData
{
public:
AZ_RTTI(MaterialData, "{F2EE1768-183B-483E-9778-CB3D3D0DA68A}", AZ::SceneAPI::DataTypes::IMaterialData)
SCENE_DATA_API MaterialData();
SCENE_DATA_API virtual ~MaterialData() = default;
SCENE_DATA_API void SetMaterialName(AZStd::string materialName);
SCENE_DATA_API const AZStd::string& GetMaterialName() const override;
SCENE_DATA_API virtual void SetTexture(TextureMapType mapType, const char* textureFileName);
SCENE_DATA_API virtual void SetTexture(TextureMapType mapType, const AZStd::string& textureFileName);
SCENE_DATA_API virtual void SetTexture(TextureMapType mapType, AZStd::string&& textureFileName);
SCENE_DATA_API virtual void SetNoDraw(bool isNoDraw);
SCENE_DATA_API virtual void SetDiffuseColor(const AZ::Vector3& color);
SCENE_DATA_API virtual void SetSpecularColor(const AZ::Vector3& color);
SCENE_DATA_API virtual void SetEmissiveColor(const AZ::Vector3& color);
SCENE_DATA_API virtual void SetOpacity(float opacity);
SCENE_DATA_API virtual void SetShininess(float shininess);
SCENE_DATA_API virtual void SetUniqueId(uint64_t uid);
SCENE_DATA_API const AZStd::string& GetTexture(TextureMapType mapType) const override;
SCENE_DATA_API bool IsNoDraw() const override;
SCENE_DATA_API const AZ::Vector3& GetDiffuseColor() const override;
SCENE_DATA_API const AZ::Vector3& GetSpecularColor() const override;
SCENE_DATA_API const AZ::Vector3& GetEmissiveColor() const override;
SCENE_DATA_API float GetOpacity() const override;
SCENE_DATA_API float GetShininess() const override;
SCENE_DATA_API uint64_t GetUniqueId() const override;
static void Reflect(ReflectContext* context);
protected:
AZStd::unordered_map<TextureMapType, AZStd::string> m_textureMap;
AZ::Vector3 m_diffuseColor;
AZ::Vector3 m_specularColor;
AZ::Vector3 m_emissiveColor;
float m_opacity;
float m_shininess;
bool m_isNoDraw;
const static AZStd::string s_DiffuseMapName;
const static AZStd::string s_SpecularMapName;
const static AZStd::string s_BumpMapName;
const static AZStd::string s_emptyString;
// A unique id which is used to identify a material in a fbx.
// This is the same as the ID in the fbx file's FbxNode
uint64_t m_uniqueId;
//! Material name from FbxNode's Object name
AZStd::string m_materialName;
};
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,156 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneData/GraphData/MeshData.h>
#include <AzCore/Casting/numeric_cast.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
namespace DataTypes = AZ::SceneAPI::DataTypes;
MeshData::~MeshData() = default;
void MeshData::AddPosition(const AZ::Vector3& position)
{
m_positions.push_back(position);
}
void MeshData::AddNormal(const AZ::Vector3& normal)
{
m_normals.push_back(normal);
}
//assume consistent winding - no stripping or fanning expected (3 index per face)
//indices can be used for position and normal
void MeshData::AddFace(unsigned int index1, unsigned int index2, unsigned int index3, unsigned int faceMaterialId)
{
IMeshData::Face face;
face.vertexIndex[0] = index1;
face.vertexIndex[1] = index2;
face.vertexIndex[2] = index3;
m_faceList.push_back(face);
m_faceMaterialIds.push_back(faceMaterialId);
}
void MeshData::AddFace(const DataTypes::IMeshData::Face& face, unsigned int faceMaterialId)
{
m_faceList.push_back(face);
m_faceMaterialIds.push_back(faceMaterialId);
}
void MeshData::SetSdkMeshIndex(int sdkMeshIndex)
{
m_sdkMeshIndex = sdkMeshIndex;
}
int MeshData::GetSdkMeshIndex() const
{
return m_sdkMeshIndex;
}
void MeshData::SetVertexIndexToControlPointIndexMap(int vertexIndex, int controlPointIndex)
{
m_vertexIndexToControlPointIndexMap[vertexIndex] = controlPointIndex;
// The above hashmap stores the control point index (value) per vertex (key).
// We construct an unordered set and fill in the control point indices in order to get access to the number of unique control points indices.
if (m_controlPointToUsedVertexIndexMap.find(controlPointIndex) == m_controlPointToUsedVertexIndexMap.end())
{
m_controlPointToUsedVertexIndexMap[controlPointIndex] = aznumeric_cast<unsigned int>(m_controlPointToUsedVertexIndexMap.size());
}
}
int MeshData::GetControlPointIndex(int vertexIndex) const
{
AZ_Assert(m_vertexIndexToControlPointIndexMap.find(vertexIndex) != m_vertexIndexToControlPointIndexMap.end(), "Vertex index %i doesn't exist", vertexIndex);
// Note: AZStd::unordered_map's operator [] doesn't have const version...
return m_vertexIndexToControlPointIndexMap.find(vertexIndex)->second;
}
size_t MeshData::GetUsedControlPointCount() const
{
return m_controlPointToUsedVertexIndexMap.size();
}
int MeshData::GetUsedPointIndexForControlPoint(int controlPointIndex) const
{
auto iter = m_controlPointToUsedVertexIndexMap.find(controlPointIndex);
if (iter != m_controlPointToUsedVertexIndexMap.end())
{
return iter->second;
}
else
{
return -1; // That control point is not used in this mesh
}
}
unsigned int MeshData::GetVertexCount() const
{
return static_cast<unsigned int>(m_positions.size());
}
bool MeshData::HasNormalData() const
{
return m_normals.size() > 0;
}
const AZ::Vector3& MeshData::GetPosition(unsigned int index) const
{
AZ_Assert(index < m_positions.size(), "GetPosition index not in range");
return m_positions[index];
}
const AZ::Vector3& MeshData::GetNormal(unsigned int index) const
{
AZ_Assert(index < m_normals.size(), "GetNormal index not in range");
return m_normals[index];
}
unsigned int MeshData::GetFaceCount() const
{
return static_cast<unsigned int>(m_faceList.size());
}
const DataTypes::IMeshData::Face& MeshData::GetFaceInfo(unsigned int index) const
{
AZ_Assert(index < m_faceList.size(), "GetFaceInfo index not in range");
return m_faceList[index];
}
unsigned int MeshData::GetFaceMaterialId(unsigned int index) const
{
AZ_Assert(index < m_faceMaterialIds.size(), "GetFaceMaterialIds index not in range");
return m_faceMaterialIds[index];
}
unsigned int MeshData::GetVertexIndex(int faceIndex, int vertexIndexInFace) const
{
AZ_Assert(faceIndex < m_faceList.size(), "GetFaceInfo index not in range");
AZ_Assert(vertexIndexInFace < 3, "vertexIndexInFace index not in range");
return m_faceList[faceIndex].vertexIndex[vertexIndexInFace];
}
void MeshData::GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("Positions", m_positions);
output.Write("Normals", m_normals);
output.Write("FaceList", m_faceList);
output.Write("FaceMaterialIds", m_faceMaterialIds);
}
}
}
}
@@ -0,0 +1,83 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/containers/unordered_set.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS MeshData
: public AZ::SceneAPI::DataTypes::IMeshData
{
public:
AZ_RTTI(MeshData, "{a2589bd4-42fb-40ba-a38d-cfcd6e9ea169}", AZ::SceneAPI::DataTypes::IMeshData)
SCENE_DATA_API ~MeshData() override;
//assumes 1 to 1 mapping for these position, normal, color, uv
//positions with more than one normal or uv (seam) will duplicate shared values in multiple verts
SCENE_DATA_API virtual void AddPosition(const AZ::Vector3& position);
SCENE_DATA_API virtual void AddNormal(const AZ::Vector3& normal);
//assume consistent winding - no stripping or fanning expected (3 index per face)
SCENE_DATA_API void AddFace(unsigned int index1, unsigned int index2, unsigned int index3,
unsigned int faceMaterialId = AZ::SceneAPI::DataTypes::IMeshData::s_invalidMaterialId);
SCENE_DATA_API void AddFace(const AZ::SceneAPI::DataTypes::IMeshData::Face& face,
unsigned int faceMaterialId = AZ::SceneAPI::DataTypes::IMeshData::s_invalidMaterialId);
SCENE_DATA_API void SetSdkMeshIndex(int sdkMeshIndex);
SCENE_DATA_API int GetSdkMeshIndex() const;
SCENE_DATA_API void SetVertexIndexToControlPointIndexMap(int vertexIndex, int controlPointIndex);
SCENE_DATA_API size_t GetUsedControlPointCount() const override;
SCENE_DATA_API int GetControlPointIndex(int vertexIndex) const override;
SCENE_DATA_API int GetUsedPointIndexForControlPoint(int controlPointIndex) const override;
SCENE_DATA_API unsigned int GetVertexCount() const override;
SCENE_DATA_API bool HasNormalData() const override;
SCENE_DATA_API const AZ::Vector3& GetPosition(unsigned int index) const override;
SCENE_DATA_API const AZ::Vector3& GetNormal(unsigned int index) const override;
SCENE_DATA_API unsigned int GetFaceCount() const override;
SCENE_DATA_API const AZ::SceneAPI::DataTypes::IMeshData::Face& GetFaceInfo(unsigned int index) const override;
SCENE_DATA_API unsigned int GetFaceMaterialId(unsigned int index) const override;
SCENE_DATA_API unsigned int GetVertexIndex(int faceIndex, int vertexIndexInFace) const override;
SCENE_DATA_API void GetDebugOutput(SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<AZ::Vector3> m_positions;
AZStd::vector<AZ::Vector3> m_normals;
AZStd::vector<AZ::SceneAPI::DataTypes::IMeshData::Face> m_faceList;
AZStd::vector<unsigned int> m_faceMaterialIds;
AZStd::unordered_map<int, int> m_vertexIndexToControlPointIndexMap;
AZStd::unordered_map<int, int> m_controlPointToUsedVertexIndexMap;
int m_sdkMeshIndex = -1;
};
}
}
}
@@ -0,0 +1,83 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneData/GraphData/MeshData.h>
#include <SceneAPI/SceneData/GraphData/MeshDataPrimitiveUtils.h>
#include <algorithm>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
namespace DataTypes = AZ::SceneAPI::DataTypes;
std::unique_ptr<DataTypes::IMeshData > MeshDataPrimitiveUtils::CreateBox(const AZ::Vector3& dimensions, unsigned int materialId)
{
return CreateBox(dimensions.GetX(), dimensions.GetY(), dimensions.GetZ(), materialId);
}
std::unique_ptr<DataTypes::IMeshData> MeshDataPrimitiveUtils::CreateBox(float xDimension, float yDimension, float zDimension, unsigned int materialId)
{
const float c_minDimension = 0.00001f;
xDimension = std::max(xDimension, c_minDimension);
yDimension = std::max(yDimension, c_minDimension);
zDimension = std::max(zDimension, c_minDimension);
xDimension /= 2.0f;
yDimension /= 2.0f;
zDimension /= 2.0f;
//assume box is centered
//assume clockwise rotation for faces
MeshData* meshData = new MeshData();
//clockwise looking from neg x
meshData->AddPosition(Vector3(-xDimension, -yDimension, -zDimension));
meshData->AddPosition(Vector3(-xDimension, -yDimension, zDimension));
meshData->AddPosition(Vector3(-xDimension, yDimension, zDimension));
meshData->AddPosition(Vector3(-xDimension, yDimension, -zDimension));
//clockwise looking from pos x
meshData->AddPosition(Vector3(xDimension, -yDimension, -zDimension));
meshData->AddPosition(Vector3(xDimension, yDimension, -zDimension));
meshData->AddPosition(Vector3(xDimension, yDimension, zDimension));
meshData->AddPosition(Vector3(xDimension, -yDimension, zDimension));
//negx
meshData->AddFace(0, 1, 2, materialId);
meshData->AddFace(0, 2, 3, materialId);
//x
meshData->AddFace(4, 5, 6, materialId);
meshData->AddFace(4, 6, 7, materialId);
//negy
meshData->AddFace(0, 4, 7, materialId);
meshData->AddFace(0, 7, 1, materialId);
//y
meshData->AddFace(3, 2, 6, materialId);
meshData->AddFace(3, 6, 5, materialId);
//negz
meshData->AddFace(0, 3, 4, materialId);
meshData->AddFace(4, 3, 5, materialId);
//z
meshData->AddFace(7, 6, 2, materialId);
meshData->AddFace(7, 2, 1, materialId);
return std::unique_ptr<DataTypes::IMeshData>(meshData);
}
}
}
}
@@ -0,0 +1,42 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <memory>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class MeshDataPrimitiveUtils
{
public:
SCENE_DATA_API static std::unique_ptr<AZ::SceneAPI::DataTypes::IMeshData> CreateBox(
const AZ::Vector3& dimensions,
unsigned int materialId = AZ::SceneAPI::DataTypes::IMeshData::s_invalidMaterialId
);
SCENE_DATA_API static std::unique_ptr<AZ::SceneAPI::DataTypes::IMeshData> CreateBox(
float xDimension,
float yDimension,
float zDimension,
unsigned int materialId = AZ::SceneAPI::DataTypes::IMeshData::s_invalidMaterialId
);
};
}
}
}
@@ -0,0 +1,89 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneData/GraphData/MeshVertexBitangentData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
size_t MeshVertexBitangentData::GetCount() const
{
return m_bitangents.size();
}
const AZ::Vector3& MeshVertexBitangentData::GetBitangent(size_t index) const
{
AZ_Assert(index < m_bitangents.size(), "Invalid index %i for mesh bitangents.", index);
return m_bitangents[index];
}
void MeshVertexBitangentData::ReserveContainerSpace(size_t numVerts)
{
m_bitangents.reserve(numVerts);
}
void MeshVertexBitangentData::Resize(size_t numVerts)
{
m_bitangents.resize(numVerts);
}
void MeshVertexBitangentData::AppendBitangent(const AZ::Vector3& bitangent)
{
m_bitangents.push_back(bitangent);
}
void MeshVertexBitangentData::SetBitangent(size_t vertexIndex, const AZ::Vector3& bitangent)
{
m_bitangents[vertexIndex] = bitangent;
}
void MeshVertexBitangentData::SetBitangentSetIndex(size_t setIndex)
{
m_setIndex = setIndex;
}
size_t MeshVertexBitangentData::GetBitangentSetIndex() const
{
return m_setIndex;
}
AZ::SceneAPI::DataTypes::TangentSpace MeshVertexBitangentData::GetTangentSpace() const
{
return m_tangentSpace;
}
void MeshVertexBitangentData::SetTangentSpace(AZ::SceneAPI::DataTypes::TangentSpace space)
{
m_tangentSpace = space;
}
void MeshVertexBitangentData::GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("Bitangents", m_bitangents);
output.Write("TangentSpace", aznumeric_cast<int64_t>(m_tangentSpace));
}
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,60 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Math/Vector3.h>
#include <AzCore/std/containers/vector.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexBitangentData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS MeshVertexBitangentData
: public AZ::SceneAPI::DataTypes::IMeshVertexBitangentData
{
public:
AZ_RTTI(MeshVertexBitangentData, "{F56FB088-4C92-4453-AFE9-4E820F03FA90}", AZ::SceneAPI::DataTypes::IMeshVertexBitangentData);
SCENE_DATA_API ~MeshVertexBitangentData() override = default;
SCENE_DATA_API size_t GetCount() const override;
SCENE_DATA_API const AZ::Vector3& GetBitangent(size_t index) const override;
SCENE_DATA_API void SetBitangent(size_t vertexIndex, const AZ::Vector3& bitangent) override;
SCENE_DATA_API void SetBitangentSetIndex(size_t setIndex) override;
SCENE_DATA_API size_t GetBitangentSetIndex() const override;
SCENE_DATA_API void Resize(size_t numVerts);
SCENE_DATA_API void ReserveContainerSpace(size_t numVerts);
SCENE_DATA_API void AppendBitangent(const AZ::Vector3& bitangent);
SCENE_DATA_API AZ::SceneAPI::DataTypes::TangentSpace GetTangentSpace() const override;
SCENE_DATA_API void SetTangentSpace(AZ::SceneAPI::DataTypes::TangentSpace space) override;
SCENE_DATA_API void GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<AZ::Vector3> m_bitangents;
AZ::SceneAPI::DataTypes::TangentSpace m_tangentSpace = AZ::SceneAPI::DataTypes::TangentSpace::FromFbx;
size_t m_setIndex = 0;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,60 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneData/GraphData/MeshVertexColorData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
const AZ::Name& MeshVertexColorData::GetCustomName() const
{
return m_customName;
}
void MeshVertexColorData::SetCustomName(const char* name)
{
m_customName = name;
}
size_t MeshVertexColorData::GetCount() const
{
return m_colors.size();
}
const AZ::SceneAPI::DataTypes::Color& MeshVertexColorData::GetColor(size_t index) const
{
AZ_Assert(index < m_colors.size(), "Invalid index %i for mesh vertex color.", index);
return m_colors[index];
}
void MeshVertexColorData::ReserveContainerSpace(size_t size)
{
m_colors.reserve(size);
}
void MeshVertexColorData::AppendColor(const AZ::SceneAPI::DataTypes::Color& color)
{
m_colors.push_back(color);
}
void MeshVertexColorData::GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("Colors", m_colors);
output.Write("ColorsCustomName", m_customName.GetCStr());
}
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,51 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/std/containers/vector.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class MeshVertexColorData
: public AZ::SceneAPI::DataTypes::IMeshVertexColorData
{
public:
AZ_RTTI(MeshVertexColorData, "{17477B86-B163-4574-8FB2-4916BC218B3D}", AZ::SceneAPI::DataTypes::IMeshVertexColorData);
SCENE_DATA_API ~MeshVertexColorData() override = default;
SCENE_DATA_API const AZ::Name& GetCustomName() const override;
SCENE_DATA_API void SetCustomName(const char* name);
SCENE_DATA_API size_t GetCount() const override;
SCENE_DATA_API const AZ::SceneAPI::DataTypes::Color& GetColor(size_t index) const override;
// Pre-allocates memory for the color storage container. This can speed up loading as
// the container doesn't need to resize between adding colors.
SCENE_DATA_API void ReserveContainerSpace(size_t size);
SCENE_DATA_API void AppendColor(const AZ::SceneAPI::DataTypes::Color& color);
SCENE_DATA_API void GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<AZ::SceneAPI::DataTypes::Color> m_colors;
AZ::Name m_customName;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,91 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneData/GraphData/MeshVertexTangentData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
size_t MeshVertexTangentData::GetCount() const
{
return m_tangents.size();
}
const AZ::Vector4& MeshVertexTangentData::GetTangent(size_t index) const
{
AZ_Assert(index < m_tangents.size(), "Invalid index %i for mesh tangents.", index);
return m_tangents[index];
}
void MeshVertexTangentData::ReserveContainerSpace(size_t numVerts)
{
m_tangents.reserve(numVerts);
}
void MeshVertexTangentData::Resize(size_t numVerts)
{
m_tangents.resize(numVerts);
}
void MeshVertexTangentData::AppendTangent(const AZ::Vector4& tangent)
{
m_tangents.push_back(tangent);
}
void MeshVertexTangentData::GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("Tangents", m_tangents);
output.Write("TangentSpace", aznumeric_cast<int64_t>(m_tangentSpace));
output.Write("SetIndex", aznumeric_cast<uint64_t>(m_setIndex));
}
void MeshVertexTangentData::SetTangent(size_t vertexIndex, const AZ::Vector4& tangent)
{
m_tangents[vertexIndex] = tangent;
}
void MeshVertexTangentData::SetTangentSetIndex(size_t setIndex)
{
m_setIndex = setIndex;
}
size_t MeshVertexTangentData::GetTangentSetIndex() const
{
return m_setIndex;
}
AZ::SceneAPI::DataTypes::TangentSpace MeshVertexTangentData::GetTangentSpace() const
{
return m_tangentSpace;
}
void MeshVertexTangentData::SetTangentSpace(AZ::SceneAPI::DataTypes::TangentSpace space)
{
m_tangentSpace = space;
}
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,59 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Math/Vector4.h>
#include <AzCore/std/containers/vector.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexTangentData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS MeshVertexTangentData
: public AZ::SceneAPI::DataTypes::IMeshVertexTangentData
{
public:
AZ_RTTI(MeshVertexTangentData, "{C16F0F38-8F8F-45A2-A33B-F2758922A7C4}", AZ::SceneAPI::DataTypes::IMeshVertexTangentData);
SCENE_DATA_API ~MeshVertexTangentData() override = default;
SCENE_DATA_API size_t GetCount() const override;
SCENE_DATA_API const AZ::Vector4& GetTangent(size_t index) const override;
SCENE_DATA_API void SetTangent(size_t vertexIndex, const AZ::Vector4& tangent) override;
SCENE_DATA_API void SetTangentSetIndex(size_t setIndex) override;
SCENE_DATA_API size_t GetTangentSetIndex() const override;
SCENE_DATA_API AZ::SceneAPI::DataTypes::TangentSpace GetTangentSpace() const override;
SCENE_DATA_API void SetTangentSpace(AZ::SceneAPI::DataTypes::TangentSpace space) override;
SCENE_DATA_API void Resize(size_t numVerts);
SCENE_DATA_API void ReserveContainerSpace(size_t numVerts);
SCENE_DATA_API void AppendTangent(const AZ::Vector4& tangent);
SCENE_DATA_API void GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<AZ::Vector4> m_tangents;
AZ::SceneAPI::DataTypes::TangentSpace m_tangentSpace = AZ::SceneAPI::DataTypes::TangentSpace::FromFbx;
size_t m_setIndex = 0;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,60 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneData/GraphData/MeshVertexUVData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
const AZ::Name& MeshVertexUVData::GetCustomName() const
{
return m_customName;
}
void MeshVertexUVData::SetCustomName(const char* name)
{
m_customName = name;
}
size_t MeshVertexUVData::GetCount() const
{
return m_uvs.size();
}
const AZ::Vector2& MeshVertexUVData::GetUV(size_t index) const
{
AZ_Assert(index < m_uvs.size(), "Invalid index %i for mesh vertex UVs.", index);
return m_uvs[index];
}
void MeshVertexUVData::ReserveContainerSpace(size_t size)
{
m_uvs.reserve(size);
}
void MeshVertexUVData::AppendUV(const AZ::Vector2& uv)
{
m_uvs.push_back(uv);
}
void MeshVertexUVData::GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("UVs", m_uvs);
output.Write("UVCustomName", m_customName.GetCStr());
}
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,52 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/Math/Vector2.h>
#include <AzCore/std/containers/vector.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexUVData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class MeshVertexUVData
: public AZ::SceneAPI::DataTypes::IMeshVertexUVData
{
public:
AZ_RTTI(MeshVertexUVData, "{B435C091-482C-4EB9-B1F4-FA5B480796DA}", AZ::SceneAPI::DataTypes::IMeshVertexUVData);
SCENE_DATA_API ~MeshVertexUVData() override = default;
SCENE_DATA_API const AZ::Name& GetCustomName() const override;
SCENE_DATA_API void SetCustomName(const char* name);
SCENE_DATA_API size_t GetCount() const override;
SCENE_DATA_API const AZ::Vector2& GetUV(size_t index) const override;
// Pre-allocate memory
SCENE_DATA_API void ReserveContainerSpace(size_t size);
SCENE_DATA_API void AppendUV(const AZ::Vector2& uv);
SCENE_DATA_API void GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<AZ::Vector2> m_uvs;
AZ::Name m_customName;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,40 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <SceneAPI/SceneData/GraphData/RootBoneData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
void RootBoneData::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<RootBoneData, BoneData>()->Version(1);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<RootBoneData>("Root Bone data", "First bone in the skeletal hierarchy.");
}
}
}
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,37 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <SceneAPI/SceneData/GraphData/BoneData.h>
namespace AZ
{
class ReflectContext;
namespace SceneData
{
namespace GraphData
{
class RootBoneData
: public AZ::SceneData::GraphData::BoneData
{
public:
AZ_RTTI(RootBoneData, "{EB1FCB42-77A2-4EBA-B70B-8BB1B6948355}", AZ::SceneData::GraphData::BoneData);
virtual ~RootBoneData() override = default;
static void Reflect(ReflectContext* context);
};
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,34 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneData/GraphData/MeshData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SkinMeshData
: public MeshData
{
public:
AZ_RTTI(SkinMeshData, "{F765B68B-101E-4CED-879A-663AEDE6AE89}", MeshData);
virtual ~SkinMeshData() override = default;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,85 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/Casting/numeric_cast.h>
#include <SceneAPI/SceneData/GraphData/SkinWeightData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
size_t SkinWeightData::GetVertexCount() const
{
return m_vertexLinks.size();
}
size_t SkinWeightData::GetLinkCount(size_t vertexIndex) const
{
AZ_Assert(vertexIndex < m_vertexLinks.size(), "Invalid vertex index %i for skin weight data links.", vertexIndex);
return m_vertexLinks[vertexIndex].size();
}
const SceneAPI::DataTypes::ISkinWeightData::Link& SkinWeightData::GetLink(size_t vertexIndex, size_t linkIndex) const
{
AZ_Assert(vertexIndex < m_vertexLinks.size(), "Invalid vertex index %i for skin weight data links.", vertexIndex);
AZ_Assert(linkIndex < m_vertexLinks[vertexIndex].size(), "Invalid link index %i for skin weight data %i.", linkIndex, vertexIndex);
return m_vertexLinks[vertexIndex][linkIndex];
}
SceneAPI::DataTypes::ISkinWeightData::Link& SkinWeightData::GetLink(size_t vertexIndex, size_t linkIndex)
{
AZ_Assert(vertexIndex < m_vertexLinks.size(), "Invalid vertex index %i for skin weight data links.", vertexIndex);
AZ_Assert(linkIndex < m_vertexLinks[vertexIndex].size(), "Invalid link index %i for skin weight data %i.", linkIndex, vertexIndex);
return m_vertexLinks[vertexIndex][linkIndex];
}
size_t SkinWeightData::GetBoneCount() const
{
return m_boneIdNameMap.size();
}
const AZStd::string& SkinWeightData::GetBoneName(int boneId) const
{
AZ_Assert(m_boneIdNameMap.find(boneId) != m_boneIdNameMap.end(), "Invalid bone id %i to look up bone name.", boneId);
return m_boneIdNameMap.at(boneId);
}
void SkinWeightData::ResizeContainerSpace(size_t size)
{
m_vertexLinks.resize(size);
}
void SkinWeightData::AppendLink(size_t vertexIndex, const SceneAPI::DataTypes::ISkinWeightData::Link& link)
{
AZ_Assert(vertexIndex < m_vertexLinks.size(), "Invalid vertex index %i for skin weight data links.", vertexIndex);
m_vertexLinks[vertexIndex].push_back(link);
}
int SkinWeightData::GetBoneId(const AZStd::string& boneName)
{
if (m_boneNameIdMap.find(boneName) == m_boneNameIdMap.end())
{
m_boneNameIdMap[boneName] = aznumeric_caster(m_boneNameIdMap.size());
m_boneIdNameMap[m_boneNameIdMap[boneName]] = boneName;
}
return m_boneNameIdMap[boneName];
}
void SkinWeightData::GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const
{
output.Write("VertexLinks", m_vertexLinks);
}
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,55 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/ISkinWeightData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
class SkinWeightData
: public SceneAPI::DataTypes::ISkinWeightData
{
public:
AZ_RTTI(SkinWeightData, "{2175A399-8EAA-4BFF-9720-C5FED739717E}", SceneAPI::DataTypes::ISkinWeightData);
SCENE_DATA_API ~SkinWeightData() override = default;
SCENE_DATA_API size_t GetVertexCount() const override;
SCENE_DATA_API size_t GetLinkCount(size_t vertexIndex) const override;
SCENE_DATA_API const Link& GetLink(size_t vertexIndex, size_t linkIndex) const override;
SCENE_DATA_API Link& GetLink(size_t vertexIndex, size_t linkIndex);
SCENE_DATA_API size_t GetBoneCount() const override;
SCENE_DATA_API const AZStd::string& GetBoneName(int boneId) const override;
SCENE_DATA_API void ResizeContainerSpace(size_t size);
SCENE_DATA_API void AppendLink(size_t vertexIndex, const SceneAPI::DataTypes::ISkinWeightData::Link& link);
SCENE_DATA_API int GetBoneId(const AZStd::string& boneName);
SCENE_DATA_API void GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const override;
protected:
AZStd::vector<AZStd::vector<SceneAPI::DataTypes::ISkinWeightData::Link>> m_vertexLinks;
AZStd::unordered_map<AZStd::string, int> m_boneNameIdMap;
AZStd::unordered_map<int, AZStd::string> m_boneIdNameMap;
};
} // GraphData
} // SceneData
} // AZ
@@ -0,0 +1,61 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <SceneAPI/SceneData/GraphData/TransformData.h>
namespace AZ
{
namespace SceneData
{
namespace GraphData
{
TransformData::TransformData(const SceneAPI::DataTypes::MatrixType& transform)
: m_transform(transform)
{
}
void TransformData::SetMatrix(const SceneAPI::DataTypes::MatrixType& transform)
{
m_transform = transform;
}
SceneAPI::DataTypes::MatrixType& TransformData::GetMatrix()
{
return m_transform;
}
const SceneAPI::DataTypes::MatrixType& TransformData::GetMatrix() const
{
return m_transform;
}
void TransformData::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<TransformData>()->Version(1)
->Field("transform", &TransformData::m_transform);
EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<TransformData>("Transform", "Transform matrix applied as a node or as a child.")
->DataElement(AZ::Edit::UIHandlers::Default, &TransformData::m_transform, "", "Transform matrix applied as a node or as a child.");
}
}
}
} // namespace GraphData
} // namespace SceneData
} // namespace AZ
@@ -0,0 +1,47 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <SceneAPI/SceneData/SceneDataConfiguration.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/ITransform.h>
namespace AZ
{
class ReflectContext;
namespace SceneData
{
namespace GraphData
{
class SCENE_DATA_CLASS TransformData
: public AZ::SceneAPI::DataTypes::ITransform
{
public:
AZ_RTTI(TransformData, "{EA86343D-8DB4-4907-8CA8-E6BAB8961914}", AZ::SceneAPI::DataTypes::ITransform);
SCENE_DATA_API TransformData() = default;
SCENE_DATA_API explicit TransformData(const SceneAPI::DataTypes::MatrixType& transform);
SCENE_DATA_API virtual void SetMatrix(const SceneAPI::DataTypes::MatrixType& transform);
SCENE_DATA_API SceneAPI::DataTypes::MatrixType& GetMatrix() override;
SCENE_DATA_API const SceneAPI::DataTypes::MatrixType& GetMatrix() const override;
static void Reflect(ReflectContext* context);
protected:
SceneAPI::DataTypes::MatrixType m_transform;
};
} // namespace GraphData
} // namespace SceneData
} // namespace AZ