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,141 @@
/*
* 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 <assimp/scene.h>
#include <AzCore/Debug/Trace.h>
#include <AzCore/Math/Sha1.h>
#include <AzCore/Debug/Trace.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SDKWrapper/AssImpMaterialWrapper.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
namespace AZ
{
namespace AssImpSDKWrapper
{
AssImpMaterialWrapper::AssImpMaterialWrapper(aiMaterial* aiMaterial)
:SDKMaterial::MaterialWrapper(aiMaterial)
{
AZ_Assert(aiMaterial, "Asset Importer Material cannot be null");
}
AZStd::string AssImpMaterialWrapper::GetName() const
{
return m_assImpMaterial->GetName().C_Str();
}
AZ::u64 AssImpMaterialWrapper::GetUniqueId() const
{
AZStd::string fingerprintString;
fingerprintString.append(GetName());
AZStd::string extraInformation = AZStd::string::format("%i%i%i%i%i%i", m_assImpMaterial->GetTextureCount(aiTextureType_DIFFUSE),
m_assImpMaterial->GetTextureCount(aiTextureType_SPECULAR), m_assImpMaterial->GetTextureCount(aiTextureType_NORMALS), m_assImpMaterial->GetTextureCount(aiTextureType_SHININESS),
m_assImpMaterial->GetTextureCount(aiTextureType_AMBIENT), m_assImpMaterial->GetTextureCount(aiTextureType_EMISSIVE));
fingerprintString.append(extraInformation);
AZ::Sha1 sha;
sha.ProcessBytes(fingerprintString.data(), fingerprintString.size());
AZ::u32 digest[5]; //sha1 populate a 5 element array of AZ:u32
sha.GetDigest(digest);
return (static_cast<AZ::u64>(digest[0]) << 32) | digest[1];
}
AZ::Vector3 AssImpMaterialWrapper::GetDiffuseColor() const
{
aiColor3D color(1.f, 1.f, 1.f);
if (m_assImpMaterial->Get(AI_MATKEY_COLOR_DIFFUSE, color) == aiReturn::aiReturn_FAILURE)
{
AZ_Warning(AZ::SceneAPI::Utilities::WarningWindow, false, "Unable to get diffuse property from the material. Using default.");
}
return AZ::Vector3(color.r, color.g, color.b);
}
AZ::Vector3 AssImpMaterialWrapper::GetSpecularColor() const
{
aiColor3D color(0.f, 0.f, 0.f);
if (m_assImpMaterial->Get(AI_MATKEY_COLOR_SPECULAR, color) == aiReturn::aiReturn_FAILURE)
{
AZ_Warning(AZ::SceneAPI::Utilities::WarningWindow, false, "Unable to get specular property from the material. Using default.");
}
return AZ::Vector3(color.r, color.g, color.b);
}
AZ::Vector3 AssImpMaterialWrapper::GetEmissiveColor() const
{
aiColor3D color(0.f, 0.f, 0.f);
if (m_assImpMaterial->Get(AI_MATKEY_COLOR_EMISSIVE, color) == aiReturn::aiReturn_FAILURE)
{
AZ_Warning(AZ::SceneAPI::Utilities::WarningWindow, false, "Unable to get emissive property from the material. Using default.");
}
return AZ::Vector3(color.r, color.g, color.b);
}
float AssImpMaterialWrapper::GetOpacity() const
{
float opacity = 1.0f;
if (m_assImpMaterial->Get(AI_MATKEY_OPACITY, opacity) == aiReturn::aiReturn_FAILURE)
{
AZ_Warning(AZ::SceneAPI::Utilities::WarningWindow, false, "Unable to get opacity from the material. Using default.");
}
return opacity;
}
float AssImpMaterialWrapper::GetShininess() const
{
float shininess = 0.0f;
if (m_assImpMaterial->Get(AI_MATKEY_SHININESS, shininess) == aiReturn::aiReturn_FAILURE)
{
AZ_Warning(AZ::SceneAPI::Utilities::WarningWindow, false, "Unable to get shininess from the material. Using default.");
}
return shininess;
}
AZStd::string AssImpMaterialWrapper::GetTextureFileName(MaterialMapType textureType) const
{
/// Engine currently doesn't support multiple textures. Right now we only use first texture.
int textureIndex = 0;
aiString absTexturePath;
switch (textureType)
{
case MaterialMapType::Diffuse:
if (m_assImpMaterial->GetTextureCount(aiTextureType_DIFFUSE) > textureIndex)
{
m_assImpMaterial->GetTexture(aiTextureType_DIFFUSE, textureIndex, &absTexturePath);
}
break;
case MaterialMapType::Specular:
if (m_assImpMaterial->GetTextureCount(aiTextureType_SPECULAR) > textureIndex)
{
m_assImpMaterial->GetTexture(aiTextureType_SPECULAR, textureIndex, &absTexturePath);
}
break;
case MaterialMapType::Bump:
if (m_assImpMaterial->GetTextureCount(aiTextureType_HEIGHT) > textureIndex)
{
m_assImpMaterial->GetTexture(aiTextureType_HEIGHT, textureIndex, &absTexturePath);
}
break;
case MaterialMapType::Normal:
if (m_assImpMaterial->GetTextureCount(aiTextureType_NORMALS) > textureIndex)
{
m_assImpMaterial->GetTexture(aiTextureType_NORMALS, textureIndex, &absTexturePath);
}
break;
default:
AZ_TraceContext("Unknown value", aznumeric_cast<int>(textureType));
AZ_TracePrintf(SceneAPI::Utilities::WarningWindow, "Unrecognized MaterialMapType retrieved");
return AZStd::string();
}
return AZStd::string(absTexturePath.C_Str());
}
} // namespace AssImpSDKWrapper
} // 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/SDKWrapper/MaterialWrapper.h>
#include <AzCore/std/string/string.h>
namespace AZ
{
namespace AssImpSDKWrapper
{
class AssImpMaterialWrapper : public SDKMaterial::MaterialWrapper
{
public:
AZ_RTTI(AssImpMaterialWrapper, "{66992628-CFCE-441B-8849-9344A49AFAC9}", SDKMaterial::MaterialWrapper);
AssImpMaterialWrapper(aiMaterial* aiMaterial);
~AssImpMaterialWrapper() override = default;
AZStd::string GetName() const override;
AZ::u64 GetUniqueId() const override;
AZ::Vector3 GetDiffuseColor() const override;
AZ::Vector3 GetSpecularColor() const override;
AZ::Vector3 GetEmissiveColor() const override;
float GetOpacity() const override;
float GetShininess() const override;
AZStd::string GetTextureFileName(MaterialMapType textureType) const override;
};
} // namespace AssImpSDKWrapper
}// namespace AZ
@@ -0,0 +1,74 @@
/*
* 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/Debug/Trace.h>
#include <AzCore/Math/Sha1.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SDKWrapper/AssImpNodeWrapper.h>
#include <assimp/scene.h>
namespace AZ
{
namespace AssImpSDKWrapper
{
AssImpNodeWrapper::AssImpNodeWrapper(aiNode* fbxNode)
:SDKNode::NodeWrapper(fbxNode)
{
AZ_Assert(m_assImpNode, "Asset Importer Node cannot be null");
}
AssImpNodeWrapper::~AssImpNodeWrapper()
{
}
const char* AssImpNodeWrapper::GetName() const
{
return m_assImpNode->mName.C_Str();
}
AZ::u64 AssImpNodeWrapper::GetUniqueId() const
{
AZStd::string fingerprintString;
fingerprintString.append(GetName());
fingerprintString.append(m_assImpNode->mParent ? m_assImpNode->mParent->mName.C_Str() : "");
AZStd::string extraInformation = AZStd::string::format("%i%i", m_assImpNode->mNumChildren, m_assImpNode->mNumMeshes);
fingerprintString.append(extraInformation);
AZ::Sha1 sha;
sha.ProcessBytes(fingerprintString.data(), fingerprintString.size());
AZ::u32 digest[5]; //sha1 populate a 5 element array of AZ:u32
sha.GetDigest(digest);
return (static_cast<AZ::u64>(digest[0]) << 32) | digest[1];
}
int AssImpNodeWrapper::GetChildCount() const
{
return m_assImpNode->mNumChildren;
}
const std::shared_ptr<SDKNode::NodeWrapper> AssImpNodeWrapper::GetChild(int childIndex) const
{
aiNode* child = m_assImpNode->mChildren[childIndex];
AZ_Error("SDKWrapper", child, "Cannot get child assImpNode at index %d", childIndex);
return child ? std::shared_ptr<SDKNode::NodeWrapper>(new AssImpNodeWrapper(child)) : nullptr;
}
const bool AssImpNodeWrapper::ContainsMesh()
{
return m_assImpNode->mNumMeshes != 0;
}
int AssImpNodeWrapper::GetMaterialCount() const
{
// one mesh uses only a single material
return m_assImpNode->mNumMeshes;
}
} // namespace AssImpSDKWrapper
} // namespace AZ
@@ -0,0 +1,33 @@
/*
* 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/SDKWrapper/NodeWrapper.h>
namespace AZ
{
namespace AssImpSDKWrapper
{
class AssImpNodeWrapper : public SDKNode::NodeWrapper
{
public:
AZ_RTTI(AssImpNodeWrapper, "{1043260B-9076-49B7-AD38-EF62E85F7C1D}", SDKNode::NodeWrapper);
AssImpNodeWrapper(aiNode* fbxNode);
~AssImpNodeWrapper() override;
const char* GetName() const override;
AZ::u64 GetUniqueId() const override;
int GetChildCount() const override;
const std::shared_ptr<NodeWrapper> GetChild(int childIndex) const override;
const bool ContainsMesh();
int GetMaterialCount() const override;
};
} // namespace AssImpSDKWrapper
}// namespace AZ
@@ -0,0 +1,97 @@
/*
* 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/Debug/Trace.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
#include <SceneAPI/SDKWrapper/AssImpSceneWrapper.h>
#include <SceneAPI/SDKWrapper/AssImpNodeWrapper.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
namespace AZ
{
namespace AssImpSDKWrapper
{
AssImpSceneWrapper::AssImpSceneWrapper()
: SDKScene::SceneWrapperBase()
{
}
AssImpSceneWrapper::AssImpSceneWrapper(aiScene* aiScene)
: SDKScene::SceneWrapperBase(aiScene)
{
}
AssImpSceneWrapper::~AssImpSceneWrapper()
{
}
bool AssImpSceneWrapper::LoadSceneFromFile(const char* fileName)
{
AZ_TracePrintf(SceneAPI::Utilities::LogWindow, "AssImpSceneWrapper::LoadSceneFromFile %s", fileName);
AZ_TraceContext("Filename", fileName);
m_assImpScene = m_importer.ReadFile(fileName,
aiProcess_CalcTangentSpace //Calculates the tangents and bitangents for the imported meshes
| aiProcess_Triangulate //Triangulates all faces of all meshes
| aiProcess_JoinIdenticalVertices //Identifies and joins identical vertex data sets for the imported meshes
| aiProcess_SortByPType //Splits meshes with more than one primitive type into homogeneous sub - meshes
| aiProcess_FixInfacingNormals //Fixes inward facing normals, AssImp documentation recommends setting this
| aiProcess_GenNormals); //Generate normals for meshes
if (!m_assImpScene)
{
AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Failed to import Asset Importer Scene. Error returned: %s", m_importer.GetErrorString());
return false;
}
return true;
}
bool AssImpSceneWrapper::LoadSceneFromFile(const AZStd::string& fileName)
{
return LoadSceneFromFile(fileName.c_str());
}
const std::shared_ptr<SDKNode::NodeWrapper> AssImpSceneWrapper::GetRootNode() const
{
return std::shared_ptr<SDKNode::NodeWrapper>(new AssImpNodeWrapper(m_assImpScene->mRootNode));
}
std::shared_ptr<SDKNode::NodeWrapper> AssImpSceneWrapper::GetRootNode()
{
return std::shared_ptr<SDKNode::NodeWrapper>(new AssImpNodeWrapper(m_assImpScene->mRootNode));
}
void AssImpSceneWrapper::Clear()
{
m_importer.FreeScene();
}
AZStd::pair<AssImpSceneWrapper::AxisVector, int32_t> AssImpSceneWrapper::GetUpVectorAndSign() const
{
AZStd::pair<AssImpSceneWrapper::AxisVector, int32_t> result(AxisVector::Z, 1);
int32_t upVectorRead(static_cast<int32_t>(result.first));
m_assImpScene->mMetaData->Get("UpAxis", upVectorRead);
m_assImpScene->mMetaData->Get("UpAxisSign", result.second);
result.first = static_cast<AssImpSceneWrapper::AxisVector>(upVectorRead);
return result;
}
AZStd::pair<AssImpSceneWrapper::AxisVector, int32_t> AssImpSceneWrapper::GetFrontVectorAndSign() const
{
AZStd::pair<AssImpSceneWrapper::AxisVector, int32_t> result(AxisVector::Y, 1);
int32_t frontVectorRead(static_cast<int32_t>(result.first));
m_assImpScene->mMetaData->Get("FrontAxis", frontVectorRead);
m_assImpScene->mMetaData->Get("FrontAxisSign", result.second);
result.first = static_cast<AssImpSceneWrapper::AxisVector>(frontVectorRead);
return result;
}
}//namespace AssImpSDKWrapper
} // namespace AZ
@@ -0,0 +1,53 @@
/*
* 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/SDKWrapper/SceneWrapper.h>
#include <assimp/Importer.hpp>
struct aiScene;
namespace AZ
{
namespace AssImpSDKWrapper
{
class AssImpSceneWrapper : public SDKScene::SceneWrapperBase
{
public:
AZ_RTTI(AssImpSceneWrapper, "{43A61F62-DCD4-4132-B80B-F2FBC80740BC}", SDKScene::SceneWrapperBase);
AssImpSceneWrapper();
AssImpSceneWrapper(aiScene* aiScene);
~AssImpSceneWrapper();
bool LoadSceneFromFile(const char* fileName) override;
bool LoadSceneFromFile(const AZStd::string& fileName) override;
const std::shared_ptr<SDKNode::NodeWrapper> GetRootNode() const override;
std::shared_ptr<SDKNode::NodeWrapper> GetRootNode() override;
void Clear() override;
enum class AxisVector
{
X = 0,
Y = 1,
Z = 2,
Unknown
};
AZStd::pair<AxisVector, int32_t> GetUpVectorAndSign() const;
AZStd::pair<AxisVector, int32_t> GetFrontVectorAndSign() const;
protected:
Assimp::Importer m_importer;
};
} // namespace AssImpSDKWrapper
} // namespace 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/SDKWrapper/AssImpTypeConverter.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h>
namespace AZ
{
namespace AssImpSDKWrapper
{
SceneAPI::DataTypes::MatrixType AssImpTypeConverter::ToTransform(const aiMatrix4x4& matrix)
{
SceneAPI::DataTypes::MatrixType transform;
transform.SetElement(0, 0, static_cast<float>(matrix.a1));
transform.SetElement(0, 1, static_cast<float>(matrix.a2));
transform.SetElement(0, 2, static_cast<float>(matrix.a3));
transform.SetElement(0, 3, static_cast<float>(matrix.a4));
transform.SetElement(1, 0, static_cast<float>(matrix.b1));
transform.SetElement(1, 1, static_cast<float>(matrix.b2));
transform.SetElement(1, 2, static_cast<float>(matrix.b3));
transform.SetElement(1, 3, static_cast<float>(matrix.b4));
transform.SetElement(2, 0, static_cast<float>(matrix.c1));
transform.SetElement(2, 1, static_cast<float>(matrix.c2));
transform.SetElement(2, 2, static_cast<float>(matrix.c3));
transform.SetElement(2, 3, static_cast<float>(matrix.c4));
return transform;
}
SceneAPI::DataTypes::MatrixType AssImpTypeConverter::ToTransform(const AZ::Matrix4x4& matrix)
{
SceneAPI::DataTypes::MatrixType transform;
for (int row = 0; row < 3; ++row)
{
for (int column = 0; column < 4; ++column)
{
transform.SetElement(row, column, matrix.GetElement(row, column));
}
}
return transform;
}
SceneAPI::DataTypes::Color AssImpTypeConverter::ToColor(const aiColor4D& color)
{
return AZ::SceneAPI::DataTypes::Color(color.r, color.g, color.b, color.a);
}
} //AssImpSDKWrapper
} // namespace AZ
@@ -0,0 +1,38 @@
/*
* 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 <assimp/scene.h>
#include <SceneAPI/SceneCore/DataTypes/MatrixType.h>
namespace AZ
{
namespace SceneAPI
{
namespace DataTypes
{
struct Color;
} // namespace DataTypes
} // namespace SceneAPI
namespace AssImpSDKWrapper
{
class AssImpTypeConverter
{
public:
static SceneAPI::DataTypes::MatrixType ToTransform(const aiMatrix4x4& matrix);
static SceneAPI::DataTypes::MatrixType ToTransform(const AZ::Matrix4x4& matrix);
static SceneAPI::DataTypes::Color ToColor(const aiColor4D& color);
};
} // namespace AssImpSDKWrapper
} // namespace AZ
@@ -0,0 +1,92 @@
/*
* 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/SDKWrapper/MaterialWrapper.h>
namespace AZ
{
namespace SDKMaterial
{
MaterialWrapper::MaterialWrapper(fbxsdk::FbxSurfaceMaterial* fbxMaterial)
:m_fbxMaterial(fbxMaterial)
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
, m_assImpMaterial(nullptr)
#endif
{
}
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
MaterialWrapper::MaterialWrapper(aiMaterial* assImpMaterial)
:m_fbxMaterial(nullptr)
, m_assImpMaterial(assImpMaterial)
{
}
#endif
MaterialWrapper::~MaterialWrapper()
{
m_fbxMaterial = nullptr;
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
m_assImpMaterial = nullptr;
#endif
}
fbxsdk::FbxSurfaceMaterial* MaterialWrapper::GetFbxMaterial()
{
return m_fbxMaterial;
}
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
aiMaterial* MaterialWrapper::GetAssImpMaterial()
{
return m_assImpMaterial;
}
#endif
AZStd::string MaterialWrapper::GetName() const
{
return AZStd::string();
}
uint64_t MaterialWrapper::GetUniqueId() const
{
return uint64_t();
}
AZ::Vector3 MaterialWrapper::GetDiffuseColor() const
{
return {};
}
AZ::Vector3 MaterialWrapper::GetSpecularColor() const
{
return {};
}
AZ::Vector3 MaterialWrapper::GetEmissiveColor() const
{
return {};
}
float MaterialWrapper::GetOpacity() const
{
return {};
}
float MaterialWrapper::GetShininess() const
{
return {};
}
AZStd::string MaterialWrapper::GetTextureFileName([[maybe_unused]]MaterialMapType textureType) const
{
return AZStd::string();
}
}// namespace SDKMaterial
}//namespace AZ
@@ -0,0 +1,70 @@
/*
* 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/RTTI/RTTI.h>
#include <AzCore/std/string/string.h>
#include <AzCore/Math/Vector3.h>
namespace fbxsdk
{
class FbxSurfaceMaterial;
}
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
struct aiMaterial;
#endif
namespace AZ
{
namespace SDKMaterial
{
class MaterialWrapper
{
public:
AZ_RTTI(MaterialWrapper, "{3B83DEE4-FF59-4AB3-B4F1-14EEE22339F3}");
enum class MaterialMapType
{
Diffuse,
Specular,
Bump,
Normal
};
MaterialWrapper(fbxsdk::FbxSurfaceMaterial* fbxMaterial);
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
MaterialWrapper(aiMaterial* assImpmaterial);
#endif
virtual ~MaterialWrapper();
fbxsdk::FbxSurfaceMaterial* GetFbxMaterial();
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
aiMaterial* GetAssImpMaterial();
#endif
virtual AZStd::string GetName() const;
virtual uint64_t GetUniqueId() const;
virtual AZStd::string GetTextureFileName(MaterialMapType textureType) const;
virtual AZ::Vector3 GetDiffuseColor() const;
virtual AZ::Vector3 GetSpecularColor() const;
virtual AZ::Vector3 GetEmissiveColor() const;
virtual float GetOpacity() const;
virtual float GetShininess() const;
protected:
fbxsdk::FbxSurfaceMaterial* m_fbxMaterial = nullptr;
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
aiMaterial* m_assImpMaterial = nullptr;
#endif
};
} // namespace SDKMaterial
} // namespace AZ
@@ -0,0 +1,77 @@
/*
* 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/SDKWrapper/NodeWrapper.h>
namespace AZ
{
namespace SDKNode
{
NodeWrapper::NodeWrapper(fbxsdk::FbxNode* fbxNode)
:m_fbxNode(fbxNode)
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
, m_assImpNode(nullptr)
#endif
{
}
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
NodeWrapper::NodeWrapper(aiNode* aiNode)
:m_fbxNode(nullptr)
, m_assImpNode(aiNode)
{
}
#endif
NodeWrapper::~NodeWrapper()
{
m_fbxNode = nullptr;
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
m_assImpNode = nullptr;
#endif
}
fbxsdk::FbxNode* NodeWrapper::GetFbxNode()
{
return m_fbxNode;
}
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
aiNode* NodeWrapper::GetAssImpNode()
{
return m_assImpNode;
}
#endif
const char* NodeWrapper::GetName() const
{
return "";
}
AZ::u64 NodeWrapper::GetUniqueId() const
{
return 0;
}
int NodeWrapper::GetMaterialCount() const
{
return -1;
}
int NodeWrapper::GetChildCount()const
{
return -1;
}
const std::shared_ptr<NodeWrapper> NodeWrapper::GetChild([[maybe_unused]] int childIndex) const
{
return {};
}
}// namespace Node
}//namespace AZ
@@ -0,0 +1,63 @@
/*
* 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/RTTI/RTTI.h>
namespace fbxsdk
{
class FbxNode;
}
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
struct aiNode;
#endif
namespace AZ
{
namespace SDKNode
{
class NodeWrapper
{
public:
AZ_RTTI(NodeWrapper, "{5EB0897B-9728-44B7-B056-BA34AAF14715}");
NodeWrapper() = default;
NodeWrapper(fbxsdk::FbxNode* fbxNode);
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
NodeWrapper(aiNode* aiNode);
#endif
virtual ~NodeWrapper();
enum CurveNodeComponent
{
Component_X,
Component_Y,
Component_Z
};
fbxsdk::FbxNode* GetFbxNode();
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
aiNode* GetAssImpNode();
#endif
virtual const char* GetName() const;
virtual AZ::u64 GetUniqueId() const;
virtual int GetMaterialCount() const;
virtual int GetChildCount()const;
virtual const std::shared_ptr<NodeWrapper> GetChild(int childIndex) const;
fbxsdk::FbxNode* m_fbxNode = nullptr;
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
aiNode* m_assImpNode = nullptr;
#endif
};
} //namespace Node
} //namespace AZ
@@ -0,0 +1,11 @@
#
# 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.
#
@@ -0,0 +1,11 @@
#
# 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.
#
@@ -0,0 +1,21 @@
#
# 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.
#
set(FILES
../../AssImpSceneWrapper.cpp
../../AssImpNodeWrapper.cpp
../../AssImpSceneWrapper.h
../../AssImpNodeWrapper.h
../../AssImpMaterialWrapper.h
../../AssImpMaterialWrapper.cpp
../../AssImpTypeConverter.cpp
../../AssImpTypeConverter.h
)
@@ -0,0 +1,71 @@
/*
* 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/SDKWrapper/SceneWrapper.h>
namespace AZ
{
namespace SDKScene
{
const char* SceneWrapperBase::s_defaultSceneName = "myScene";
SceneWrapperBase::SceneWrapperBase(fbxsdk::FbxScene* fbxScene)
:m_fbxScene(fbxScene)
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
, m_assImpScene(nullptr)
#endif
{
}
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
SceneWrapperBase::SceneWrapperBase(aiScene* aiScene)
:m_fbxScene(nullptr)
, m_assImpScene(aiScene)
{
}
#endif
bool SceneWrapperBase::LoadSceneFromFile([[maybe_unused]] const char* fileName)
{
return false;
}
bool SceneWrapperBase::LoadSceneFromFile([[maybe_unused]] const AZStd::string& fileName)
{
return LoadSceneFromFile(fileName.c_str());
}
const std::shared_ptr<SDKNode::NodeWrapper> SceneWrapperBase::GetRootNode() const
{
return {};
}
std::shared_ptr<SDKNode::NodeWrapper> SceneWrapperBase::GetRootNode()
{
return {};
}
void SceneWrapperBase::Clear()
{
}
fbxsdk::FbxScene* SceneWrapperBase::GetFbxScene() const
{
return m_fbxScene;
}
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
const aiScene* SceneWrapperBase::GetAssImpScene() const
{
return m_assImpScene;
}
#endif
} //namespace Scene
}// namespace 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.
*
*/
#pragma once
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SDKWrapper/NodeWrapper.h>
namespace fbxsdk
{
class FbxScene;
}
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
struct aiScene;
#endif
namespace AZ
{
namespace SDKScene
{
class SceneWrapperBase
{
public:
AZ_RTTI(SceneWrapperBase, "{703CD344-2C75-4F30-8CE2-6BDEF2511AFD}");
SceneWrapperBase() = default;
SceneWrapperBase(fbxsdk::FbxScene* fbxScene);
virtual ~SceneWrapperBase() = default;
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
SceneWrapperBase(aiScene* aiScene);
#endif
virtual bool LoadSceneFromFile(const char* fileName);
virtual bool LoadSceneFromFile(const AZStd::string& fileName);
virtual const std::shared_ptr<SDKNode::NodeWrapper> GetRootNode() const;
virtual std::shared_ptr<SDKNode::NodeWrapper> GetRootNode();
virtual void Clear();
virtual fbxsdk::FbxScene* GetFbxScene() const;
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
virtual const aiScene* GetAssImpScene() const;
#endif
fbxsdk::FbxScene* m_fbxScene = nullptr;
#ifdef ASSET_IMPORTER_SDK_SUPPORTED_TRAIT
const aiScene* m_assImpScene = nullptr;
#endif
static const char* s_defaultSceneName;
};
} //namespace Scene
} //namespace AZ
@@ -0,0 +1,19 @@
#
# 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.
#
set(FILES
SceneWrapper.h
SceneWrapper.cpp
NodeWrapper.h
NodeWrapper.cpp
MaterialWrapper.h
MaterialWrapper.cpp
)