Cogs.Core
EntityDefinitions.cpp
1#include "EntityDefinitions.h"
2#include "EntityDefinition.h"
3
4#include "EntityStore.h"
5
6#include "Serialization/EntityReader.h"
7
9{
10 readEntityDefinition(R"(
11{ "name": "Default",
12 "components": [
13 "TransformComponent",
14 "SceneComponent",
15 "MeshComponent",
16 "MeshRenderComponent",
17 "MaterialComponent" ]
18})"
19, entityStore);
20
21 readEntityDefinition(R"(
22{ "name": "SphereMesh",
23 "components": [
24 "TransformComponent",
25 "SceneComponent",
26 "MeshGeneratorComponent",
27 "LodComponent",
28 "MeshComponent",
29 "MeshRenderComponent" ],
30 "defaults": [
31 { "MeshGeneratorComponent": { "shape": "SphereGeoTexSph" }},
32 { "LodComponent": { "policy": "None" }} ]
33})"
34, entityStore);
35
36 readEntityDefinition(R"(
37{ "name": "MarkerPointSet",
38 "components": [
39 "TransformComponent",
40 "SceneComponent",
41 "MarkerPointSetComponent",
42 "MeshComponent",
43 "InstancedMeshRenderComponent"
44 ]
45})", entityStore);
46
47 readEntityDefinition(R"(
48{ "name": "OceanRectangle",
49 "components": [
50 "AdaptivePlanarGridComponent",
51 "BasicOceanComponent",
52 "TransformComponent",
53 "SceneComponent",
54 "LodComponent",
55 ],
56 "defaults": [
57 { "LodComponent": { "policy": "GeometricTolerance", "geometricTolerance": 20.0 }},
58 { "SceneComponent" : { "pickable": false } },
59 ],
60})"
61, entityStore);
62
63 readEntityDefinition(R"(
64{ "name": "BasicTerrain",
65 "components": [
66 "AdaptivePlanarGridComponent",
67 "BasicTerrainComponent",
68 "TransformComponent",
69 "SceneComponent",
70 "MeshComponent",
71 "MeshRenderComponent",
72 "LodComponent",
73 ],
74 "defaults": [
75 { "LodComponent": { "policy": "GeometricTolerance", "geometricTolerance": 20.0 }},
76 { "SceneComponent" : { "pickable": false } },
77 ],
78})"
79, entityStore);
80
81 readEntityDefinition(R"(
82{
83 "name": "MeshPartWithMaterial",
84 "components": [
85 "TransformComponent",
86 "SceneComponent",
87 "MeshComponent",
88 "MeshRenderComponent",
89 "MaterialComponent" ],
90})"
91, entityStore);
92
93 readEntityDefinition(R"(
94{
95 "name": "Wellbore",
96 "components": [
97 "TransformComponent",
98 "SceneComponent",
99 "MeshComponent",
100 "MeshRenderComponent",
101 "ExtrusionComponent",
102 "MaterialComponent" ],
103})"
104, entityStore);
105
106 readEntityDefinition(R"(
107{
108 "name": "Extrusion",
109 "components": [
110 "TransformComponent",
111 "SceneComponent",
112 "MeshComponent",
113 "MeshRenderComponent",
114 "ExtrusionComponent",
115 "MaterialComponent" ],
116})"
117, entityStore);
118
119 readEntityDefinition(R"(
120{
121 "name": "ExtrudeShape",
122 "components": [
123 "TransformComponent",
124 "SceneComponent",
125 "MeshComponent",
126 "MeshRenderComponent",
127 "ExtrusionComponent",
128 "MaterialComponent" ],
129})"
130, entityStore);
131
132 readEntityDefinition(R"(
133{
134 "name": "Trajectory",
135 "components": [
136 "LodComponent",
137 "TransformComponent",
138 "SceneComponent",
139 "TrajectoryComponent" ],
140})"
141, entityStore);
142
143 readEntityDefinition(R"(
144{
145 "name": "TrajectoryLayout",
146 "components": [
147 "TransformComponent",
148 "SceneComponent",
149 "TrajectoryLayoutComponent" ],
150})"
151, entityStore);
152
153 readEntityDefinition(R"(
154{
155 "name": "ReflectionCamera",
156 "components": [
157 "TransformComponent",
158 "SceneComponent",
159 "CameraComponent",
160 "ReflectionComponent" ],
161})"
162, entityStore);
163
164 readEntityDefinition(R"(
165{
166 "name": "CogsMaterial",
167 "description": "Entity with only MaterialComponent. Can be used to supply master material, e.g. MaterialComponent.material",
168 "components": [
169 "MaterialComponent" ],
170})"
171, entityStore);
172
173 readEntityDefinition(R"(
174{
175 "name": "TextureGeneratorMaterial",
176 "components": [
177 "TextureGeneratorComponent",
178 "MaterialComponent" ],
179})"
180, entityStore);
181
182 readEntityDefinition(R"(
183{
184 "name": "PointSet",
185 "components": [
186 "TransformComponent",
187 "SceneComponent",
188 "ShapeComponent",
189 "MaterialComponent",
190 "MeshComponent",
191 "MeshRenderComponent" ],
192 "defaults": [
193 { "ShapeComponent": { "primitiveType": "PointList" } },
194 ],
195})"
196, entityStore);
197
198 readEntityDefinition(R"(
199{
200 "name": "DrillBit",
201 "components": [
202 "TransformComponent",
203 "SceneComponent",
204 "ModelComponent",
205 "TrajectoryAlignedComponent",
206 "MaterialComponent" ],
207})"
208, entityStore);
209
210 readEntityDefinition(R"(
211{
212 "name": "DataSet",
213 "components": [
214 "DataSetComponent" ],
215})"
216, entityStore);
217
218 readEntityDefinition(R"(
219{
220 "name": "LookupColorMap",
221 "description": "Colormap Entity. Store colormap as texture in MaterialComponent. Sample usage: HeightMapComponent.colorMap, ZipComponent.colorMap",
222 "components": [
223 "MaterialComponent" ],
224})"
225, entityStore);
226
227 readEntityDefinition(R"(
228{
229 "name": "SingleColorMap",
230 "components": [
231 "MaterialComponent" ],
232})"
233, entityStore);
234
235 readEntityDefinition(R"(
236{
237 "name": "VariableExtrusionShape",
238 "components": [
239 "TransformComponent",
240 "SceneComponent",
241 "MeshComponent",
242 "MeshRenderComponent",
243 "VariableExtrusionComponent",
244 "MaterialComponent" ],
245})"
246, entityStore);
247
248}
249
250void Cogs::Core::createEntityDefinition(const std::string & name, std::vector<std::string> components, EntityStore * entityStore)
251{
252 EntityDefinition definition;
253 definition.name = name;
254 definition.components = components;
255
256 entityStore->addEntityDefinition(definition);
257}
Stores top level entities for the engine.
Definition: EntityStore.h:50
void addEntityDefinition(const EntityDefinition &definition)
Add the given entity definition to the store.
Definition: EntityStore.cpp:59
void COGSCORE_DLL_API createDefaultEntityDefinitions(class EntityStore *entityStore)
Create the default entity definitions supported by Cogs.
void COGSCORE_DLL_API createEntityDefinition(const std::string &name, std::vector< std::string > components, class EntityStore *entityStore)
Create a simple entity definition with the given name and list of components.
Defines how to construct entities of a certain type by a list of components to instantiate and defaul...
std::vector< std::string > components
Names of the component types to instantiate when creating an entity from this definition.