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,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/SerializeContext.h>
#include <SceneAPI/SceneCore/Components/BehaviorComponent.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneCore
{
void BehaviorComponent::Activate()
{
}
void BehaviorComponent::Deactivate()
{
}
void BehaviorComponent::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<BehaviorComponent, AZ::Component>()->Version(1);
}
}
} // namespace SceneCore
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,44 @@
/*
* 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/Component/Component.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneCore
{
// Behavior components are small logic units that exist as long as the SceneAPI is
// initialized and active. These components can react to various events that
// happen to a scene and make appropriate changes, additions or removals. These
// components are also responsible to register their associated data with the
// reflect context.
class SCENE_CORE_CLASS BehaviorComponent
: public AZ::Component
{
public:
AZ_COMPONENT(BehaviorComponent, "{DA66AE07-9ECF-4108-9CCC-9BFF618DD4AD}");
~BehaviorComponent() override = default;
SCENE_CORE_API void Activate() override;
SCENE_CORE_API void Deactivate() override;
static void Reflect(ReflectContext* context);
};
} // namespace SceneCore
} // namespace SceneAPI
} // 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.
*
*/
#include <AzCore/Serialization/SerializeContext.h>
#include <SceneAPI/SceneCore/Components/ExportingComponent.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneCore
{
void ExportingComponent::Activate()
{
ActivateBindings();
}
void ExportingComponent::Deactivate()
{
DeactivateBindings();
}
void ExportingComponent::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<ExportingComponent, AZ::Component>()->Version(2);
}
}
} // namespace SceneCore
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,48 @@
/*
* 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/Component/Component.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBinder.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneCore
{
// Exporting components are small logic units that exist only during exporting. Each of
// these components take care of a small piece of the exporting process, allowing
// multiple components to use the same graph and manifest to collect data.
// Use the BindToCall from the CallProcessorBinder to be able to react to specific
// loading contexts/events.
class SCENE_CORE_CLASS ExportingComponent
: public AZ::Component
, public Events::CallProcessorBinder
{
public:
AZ_COMPONENT(ExportingComponent, "{0CB2327A-EAB7-4F16-8204-861530C3A077}", Events::CallProcessorBinder);
ExportingComponent() = default;
~ExportingComponent() override = default;
SCENE_CORE_API void Activate() override;
SCENE_CORE_API void Deactivate() override;
static void Reflect(ReflectContext* context);
};
} // namespace SceneCore
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,36 @@
/*
* 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/SerializeContext.h>
#include <SceneAPI/SceneCore/Components/GenerationComponent.h>
namespace AZ::SceneAPI::SceneCore
{
void GenerationComponent::Activate()
{
ActivateBindings();
}
void GenerationComponent::Deactivate()
{
DeactivateBindings();
}
void GenerationComponent::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<GenerationComponent, AZ::Component, Events::CallProcessorBinder>()->Version(1);
}
}
} // namespace AZ::SceneAPI::SceneCore
@@ -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 <AzCore/Component/Component.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBinder.h>
namespace AZ::SceneAPI::SceneCore
{
// Generation components are small logic units that exist only during scene generation. Each of
// these components take care of a piece of the generation process, allowing
// multiple components to do runtime creation of scene graph objects.
// Use the BindToCall from the CallProcessorBinder to be able to react to specific
// loading contexts/events.
class SCENE_CORE_CLASS GenerationComponent
: public AZ::Component
, public Events::CallProcessorBinder
{
public:
AZ_COMPONENT(GenerationComponent, "{3DBA42C1-894E-4437-B046-BC399E34366B}", Events::CallProcessorBinder);
SCENE_CORE_API void Activate() override;
SCENE_CORE_API void Deactivate() override;
static void Reflect(ReflectContext* context);
};
} // namespace AZ::SceneAPI::SceneCore
@@ -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.
*
*/
#include <AzCore/Serialization/SerializeContext.h>
#include <SceneAPI/SceneCore/Components/LoadingComponent.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneCore
{
void LoadingComponent::Activate()
{
ActivateBindings();
}
void LoadingComponent::Deactivate()
{
DeactivateBindings();
}
void LoadingComponent::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<LoadingComponent, AZ::Component>()->Version(2);
}
}
} // namespace SceneCore
} // namespace SceneAPI
} // 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 <AzCore/Component/Component.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBinder.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneCore
{
// Loading components are small logic units that exist only during loading. Each of
// these components take care of a small piece of the loading process, allowing
// multiple components to use the same sources to collect data.
// Use the BindToCall from the CallProcessorBinder to be able to react to specific
// loading contexts/events.
class SCENE_CORE_CLASS LoadingComponent
: public AZ::Component
, public Events::CallProcessorBinder
{
public:
AZ_COMPONENT(LoadingComponent, "{335A696D-38DA-4A4F-B3F3-DBAD1FE86888}", Events::CallProcessorBinder);
LoadingComponent() = default;
~LoadingComponent() override = default;
SCENE_CORE_API void Activate() override;
SCENE_CORE_API void Deactivate() override;
static void Reflect(ReflectContext* context);
};
} // namespace SceneCore
} // namespace SceneAPI
} // 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.
*
*/
#include <AzCore/Serialization/SerializeContext.h>
#include <SceneAPI/SceneCore/Components/RCExportingComponent.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneCore
{
void RCExportingComponent::Activate()
{
ActivateBindings();
}
void RCExportingComponent::Deactivate()
{
DeactivateBindings();
}
void RCExportingComponent::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<RCExportingComponent, AZ::Component>()->Version(2);
}
}
} // namespace SceneCore
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,45 @@
/*
* 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/Component/Component.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBinder.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneCore
{
// Component used to support legacy systems. Use ExportingComponent for any new
// development.
class SCENE_CORE_CLASS RCExportingComponent
: public AZ::Component
, public Events::CallProcessorBinder
{
public:
AZ_COMPONENT(RCExportingComponent, "{128286A3-41EF-4910-8C62-E9EECA43C4EF}", Events::CallProcessorBinder);
RCExportingComponent() = default;
~RCExportingComponent() override = default;
SCENE_CORE_API void Activate() override;
SCENE_CORE_API void Deactivate() override;
static void Reflect(ReflectContext* context);
};
} // namespace SceneCore
} // namespace SceneAPI
} // namespace 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/SerializeContext.h>
#include <SceneAPI/SceneCore/Components/SceneSystemComponent.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneCore
{
void SceneSystemComponent::Activate()
{
}
void SceneSystemComponent::Deactivate()
{
}
void SceneSystemComponent::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<SceneSystemComponent, AZ::Component>()->Version(1);
}
}
} // namespace SceneCore
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,43 @@
/*
* 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/Component/Component.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneCore
{
// Scene system components are components that can be used to create system components
// in situations where the full initialization and/or construction of regular
// system components don't apply such as in the Project Configurator's advanced
// settings and the ResourceCompilerScene.
class SCENE_CORE_CLASS SceneSystemComponent
: public AZ::Component
{
public:
AZ_COMPONENT(SceneSystemComponent, "{480FE393-A6BE-4AB9-AF91-11468AAFDB36}");
~SceneSystemComponent() override = default;
SCENE_CORE_API void Activate() override;
SCENE_CORE_API void Deactivate() override;
static void Reflect(ReflectContext* context);
};
} // namespace SceneCore
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,106 @@
/*
* 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/Component/ComponentApplication.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Component/Entity.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/Module/ModuleManager.h>
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/ObjectStream.h>
#include <SceneAPI/SceneCore/Components/SceneSystemComponent.h>
#include <SceneAPI/SceneCore/Components/Utilities/EntityConstructor.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
namespace AZ
{
namespace SceneAPI
{
namespace SceneCore
{
namespace EntityConstructor
{
EntityPointer BuildEntity(const char* entityName, const AZ::Uuid& baseComponentType)
{
return EntityPointer(BuildEntityRaw(entityName, baseComponentType), [](AZ::Entity* entity)
{
entity->Deactivate();
delete entity;
});
}
Entity* BuildEntityRaw(const char* entityName, const AZ::Uuid& baseComponentType)
{
SerializeContext* context = nullptr;
ComponentApplicationBus::BroadcastResult(context, &ComponentApplicationBus::Events::GetSerializeContext);
Entity* entity = aznew AZ::Entity(entityName);
if (context)
{
context->EnumerateDerived(
[entity](const AZ::SerializeContext::ClassData* data, const AZ::Uuid& /*typeId*/) -> bool
{
entity->CreateComponent(data->m_typeId);
return true;
}, baseComponentType, baseComponentType);
}
entity->Init();
entity->Activate();
return entity;
}
Entity* BuildSceneSystemEntity()
{
SerializeContext* context = nullptr;
ComponentApplicationBus::BroadcastResult(context, &ComponentApplicationBus::Events::GetSerializeContext);
if (!context)
{
AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Unable to retrieve serialize context.");
return nullptr;
}
// Starting all system components would be too expensive for a builder/ResourceCompiler, so only the system components needed
// for the SceneAPI will be created.
AZStd::unique_ptr<Entity> entity(aznew AZ::Entity("Scene System"));
const Uuid sceneSystemComponentType = azrtti_typeid<AZ::SceneAPI::SceneCore::SceneSystemComponent>();
context->EnumerateDerived(
[&entity](const AZ::SerializeContext::ClassData* data, const AZ::Uuid& typeId) -> bool
{
AZ_UNUSED(typeId);
// Before adding a new instance of a SceneSystemComponent, first check if the entity already has
// a component of the same type. Just like regular system components, there should only ever be
// a single instance of a SceneSystemComponent.
bool alreadyAdded = false;
for (const Component* component : entity->GetComponents())
{
if (component->RTTI_GetType() == data->m_typeId)
{
alreadyAdded = true;
break;
}
}
if (!alreadyAdded)
{
entity->CreateComponent(data->m_typeId);
}
return true;
}, sceneSystemComponentType, sceneSystemComponentType);
return entity.release();
}
} // namespace EntityConstructor
} // namespace SceneCore
} // namespace SceneAPI
} // 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 <AzCore/std/smart_ptr/unique_ptr.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
namespace AZ
{
class Entity;
struct Uuid;
namespace SceneAPI
{
namespace SceneCore
{
namespace EntityConstructor
{
using EntityPointer = AZStd::unique_ptr<AZ::Entity, void(*)(AZ::Entity*)>;
SCENE_CORE_API EntityPointer BuildEntity(const char* entityName, const AZ::Uuid& baseComponentType);
SCENE_CORE_API Entity* BuildEntityRaw(const char* entityName, const AZ::Uuid& baseComponentType);
SCENE_CORE_API Entity* BuildSceneSystemEntity();
} // namespace EntityConstructor
} // namespace SceneCore
} // namespace SceneAPI
} // namespace AZ