Cogs.Core
CasingExtension.cpp
1
2#include "Context.h"
3#include "ExtensionRegistry.h"
4#include "Serialization/EntityReader.h"
5
6#include "LoftedCrossSectionsComponent.h"
7#include "LoftedCrossSectionsSystem.h"
8#include "TrajectoryCrossSectionsComponent.h"
9#include "TrajectoryCrossSectionsSystem.h"
10
11#include "Foundation/Logging/Logger.h"
12
13namespace Cogs::Core
14{
15
16 struct CasingExtension : public Extension
17 {
19 {
20 ExtensionRegistry::add(this, COGS_CORE_VERSION_STRING);
21 }
22
23 bool initializeStatic() override
24 {
25 LoftedCrossSectionsComponent::registerType();
26 TrajectoryCrossSectionsComponent::registerType();
27 return true;
28 }
29
30 bool initialize(Context * context) override
31 {
32
33 readEntityDefinition(R"(
34{
35 "name": "Casing",
36 "components": [
37 "TransformComponent",
38 "SceneComponent",
39 "LodComponent",
40 "TrajectoryCrossSectionsComponent",
41 "LoftedCrossSectionsComponent",
42 "TextureGeneratorComponent",
43 "MeshComponent",
44 "MeshRenderComponent",
45 "MaterialComponent"
46 ],
47 "defaults": [
48 { "TextureGeneratorComponent": { "diffuseMap": "None" } },
49 { "MaterialComponent": { "diffuseColor": [ 0.5, 0.5, 0.5, 1 ] } },
50 {
51 "TrajectoryCrossSectionsComponent": {
52 "parameterization": "CoordLengthOverCircumference",
53 "shape": "Hollow"
54 }
55 }
56 ]
57})", context->store);
58
59 readEntityDefinition(R"(
60{
61 "name": "TrajectoryCylinder",
62 "components": [
63 "TransformComponent",
64 "SceneComponent",
65 "LodComponent",
66 "TrajectoryCrossSectionsComponent",
67 "LoftedCrossSectionsComponent",
68 "TextureGeneratorComponent",
69 "MaterialComponent",
70 "MeshComponent",
71 "MeshRenderComponent"
72 ],
73 "defaults": [
74 { "TextureGeneratorComponent": { "diffuseMap": "None" } },
75 { "MaterialComponent": { "diffuseColor": [ 0.5, 0.5, 0.5, 1 ] } },
76 {
77 "TrajectoryCrossSectionsComponent": {
78 "parameterization": "CoordLengthOverCircumference",
79 "shape": "Solid"
80 }
81 }
82 ]
83})", context->store);
84
85 readEntityDefinition(R"(
86{
87 "name": "BoreHole",
88 "components": [
89 "TransformComponent",
90 "SceneComponent",
91 "LodComponent",
92 "TrajectoryCrossSectionsComponent",
93 "LoftedCrossSectionsComponent",
94 "TextureGeneratorComponent",
95 "MaterialComponent",
96 "MeshComponent",
97 "MeshRenderComponent"
98 ],
99 "defaults": [
100 { "TextureGeneratorComponent": { "diffuseMap": "Dirt" } },
101 {
102 "TrajectoryCrossSectionsComponent": {
103 "parameterization": "CoordLengthOverCircumference",
104 "shape": "Shell"
105 }
106 }
107 ]
108})", context->store);
109
110 ExtensionRegistry::registerExtensionSystem<TrajectoryCrossSectionsSystem>(context, SystemPriority::PostTransform, 128);
111 ExtensionRegistry::registerExtensionSystem<LoftedCrossSectionsSystem>(context, SystemPriority::Geometry, 128);
112 return true;
113 }
114
115 const char * getExtensionKey() const override
116 {
117 return "Casing";
118 }
119 } casingExtensionInstance;
120
121}
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
class EntityStore * store
Entity store.
Definition: Context.h:231
static void add(Extension *extension, StringView version)
Adds the given extension to the registry, ensuring the initialization methods are called at appropria...
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
bool initialize(Context *context) override
Initialize extension for the given context.
const char * getExtensionKey() const override
Get the extensions unique key, used to check for extension presence and retrieve extension specific d...
bool initializeStatic() override
Initialize extension statically.
Defines an extension to Cogs.Core and provides methods to override in order to initialize extension c...
@ Geometry
Run at the time geometry data is updated.
Definition: Engine.h:70
@ PostTransform
Run immediately after transformations are updated.
Definition: Engine.h:54