Cogs.Core
CommandHelpers.h
1#pragma once
2
3#include "EditorExtension.h"
4
5#include "Components/Core/SceneComponent.h"
6#include "Components/Core/MeshComponent.h"
7#include "Components/Core/MeshRenderComponent.h"
8#include "Components/Core/TransformComponent.h"
9
10#include "EditorState.h"
11
12#include "Foundation/ComponentModel/ComponentPtr.h"
13#include "Foundation/Memory/MemoryBuffer.h"
14
15#include <glm/glm.hpp>
16
17#include <vector>
18
20{
21 class Entity;
22}
23
24namespace Cogs::Core
25{
26 class Context;
27 class MeshComponent;
28 class TransformComponent;
29 class MeshRenderComponent;
30 struct MaterialInstance;
31
32 struct MeshRep {
38
39 MeshRep() = default;
40
41 MeshRep(const MeshRep&) = delete;
42 MeshRep& operator=(const MeshRep&) = delete;
43
44 MeshRep(MeshRep&&) = default;
45 MeshRep& operator=(MeshRep&&) = default;
46
47 void copy(const MeshRep & other);
48 };
49 typedef std::vector<MeshRep> MeshReps;
50
52 {
53 bool discardNormals = false;
54 bool discardTexCoords = false;
55 bool discardTangents = false;
56 bool forceIndexed = false;
57 };
58
60 {
62 uint32_t parent = ~0u;
63 };
64
65 struct MeshItem
66 {
67 MeshHandle mesh;
70 MaterialInstance* matlInst = nullptr;
71 uint32_t offset;
72 uint32_t count;
73 uint32_t parent = ~0u;
74 };
75
76 struct MeshItems {
77 std::vector<TransformItem> transforms;
78 std::vector<MeshItem> meshes;
79 };
80
81 COGSCORE_EDITOR_API void getMeshItems(Context* context, MeshItems& items, EntityPtr entity, uint32_t primitiveTypeMask = ~0u);
82
83 COGSCORE_EDITOR_API void getMeshItems(Context* context, MeshItems& items, Cogs::Core::EntityIds entities, uint32_t primitiveTypeMask = ~0u);
84
85 COGSCORE_EDITOR_API void remapVertices(Context* context, MeshRep& rep, const std::vector<uint32_t>& unique);
86
87 COGSCORE_EDITOR_API void remapIndices(Context* context, MeshRep& rep, const std::vector<uint32_t>& map);
88
89 COGSCORE_EDITOR_API void unpackMeshItems(Context* context, std::vector<MeshHandle>& originalMeshes, MeshReps& meshes, MeshItems& items, UnpackOptions options = UnpackOptions());
90
91 COGSCORE_EDITOR_API void packMeshItems(Context* context, std::vector<MeshHandle>& originalMeshes, MeshReps& meshes, MeshItems& items, bool update = true);
92
93 COGSCORE_EDITOR_API EntityPtr createNewMeshItems(Context* context, Cogs::ComponentModel::Entity* parent, std::vector<MeshHandle>& originalMeshes, MeshReps& meshes, MeshItems& items);
94
95 COGSCORE_EDITOR_API EntityPtr createAsSingleMeshItem(Context* context, Cogs::ComponentModel::Entity* parent, std::vector<MeshHandle>& originalMeshes, MeshReps& meshes, MeshItems& items);
96}
A shared_pointer type pointer to a component in an entity.
Definition: ComponentPtr.h:17
Container for components, providing composition of dynamic entities.
Definition: Entity.h:18
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
Contains code for composing and managing entities built from components.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
std::shared_ptr< ComponentModel::Entity > EntityPtr
Smart pointer for Entity access.
Definition: EntityPtr.h:12
Material instances represent a specialized Material combined with state for all its buffers and prope...