1#include "ExportGltfCommand.h"
2#include "Serialization/GltfWriter.h"
3#include "Components/Core/ModelComponent.h"
4#include "Components/Core/MeshComponent.h"
5#include "Components/Core/SceneComponent.h"
6#include "Components/Core/StaticModelComponent.h"
8#include "Foundation/Logging/Logger.h"
16 if (entity ==
nullptr)
return;
18 if (
auto result = std::find_if(entities.begin(), entities.end(), [e = entity](
Cogs::ComponentModel::Entity*& x) { return x->getId() == e->getId(); });
19 result != entities.end()) {
24 if (!sceneComp)
return;
28 if (!meshComp && !staticModelComp)
return;
30 LOG_DEBUG(logger,
"export entity id: %zu", entity->
getId());
31 entities.push_back(entity);
39 std::vector<ComponentModel::Entity*> entities;
41 const std::unordered_map<EntityId, EntityPtr>& entityMap = context->
store->
getEntities();
43 for (
const auto& e : entityMap) {
45 getEntity(context, entities, entity);
49 for (
auto id : state->selected) {
58 if (exportAsGlb ==
true) {
59 ok = GltfWriter::writeGlb(entities, filePath, fileName);
62 ok = GltfWriter::writeGltf(entities, filePath, fileName);
66 LOG_ERROR(logger,
"Save %s failed. Path: %s", (exportAsGlb ?
"GLB" :
"GLTF"), filePath.c_str());
73void Cogs::Core::ExportGltfCommand::undo()
Container for components, providing composition of dynamic entities.
T * getComponent() const
Get a pointer to the first component implementing the given type in the entity.
constexpr size_t getId() const noexcept
Get the unique identifier of this entity.
A Context instance contains all the services, systems and runtime components needed to use Cogs.
class EntityStore * store
Entity store.
ComponentModel::Entity * getEntityPtr(const EntityId entityId)
Get a raw pointer to the entity with the given id.
const std::unordered_map< EntityId, EntityPtr > & getEntities() const
Return map of entities with global ownership.
virtual void apply() override
Run the command.
Contains a handle to a Mesh resource to use when rendering using the MeshRenderComponent.
Contains information on how the entity behaves in the scene.
Log implementation class.
constexpr Log getLogger(const char(&name)[LEN]) noexcept