Cogs.Core
TwinCadModelSystem.h
1#pragma once
2
3#include "Rendering/Common.h"
4
5#include "Resources/Resources.h"
6#include "Resources/Material.h"
7
8#include "Scene/RayPick.h"
9
10#include "Systems/ComponentSystem.h"
11
12#include "TwinCadModelComponent.h"
13#include "TwinVisualsSystem.h"
14
15namespace Cogs::Core {
16 class RenderSystem;
17 struct TwinCadModelSystem;
18
20 {
21 TwinCadModelRayPickExtension(RenderSystem* renderSystem, TwinCadModelSystem* cadModelSystem);
22
23 private:
24 bool pickImpl(Context* context,
25 const glm::mat4& worldPickMatrix,
26 const glm::mat4& rawViewProjection,
27 const glm::mat4& viewMatrix,
28 const RayPicking::RayPickFilter& filter,
29 PickingFlags pickingFlags,
30 PicksReturned returnFlag,
31 std::vector<RayPicking::RayPickHit>& hits) override;
32
33 RenderSystem* renderSystem = nullptr;
34 TwinCadModelSystem* cadModelSystem = nullptr;
35 };
36
38 {
39 MaterialInstanceHandle materialInstance;
40 TextureHandle attributeMap;
41 std::vector<uint8_t> attributeMapData;
42
43 std::string substance;
47
48 uint8_t attributeMapGen = 0;
49 bool needUpdate = false;
50 bool firstRun = true;
51 };
52
53 struct TwinCadModelSystem : public ComponentSystemWithDataPool<TwinCadModelComponent, TwinCadModelData>
54 {
55 public:
56 TwinCadModelSystem(Memory::Allocator* allocator, SizeType capacity) : ComponentSystemWithDataPool(allocator, capacity) {}
57
58 void preUpdate(Context * context) override;
59
60 void update(Context* context) override;
61
63
64 void destroyComponent(ComponentHandle handle) override;
65
66 private:
67 MaterialHandle material;
68
69 VariableKey attributeMapKey = NoProperty;
70 VariableKey emissiveColorKey = NoProperty;
71 VariableKey diffuseColorKey = NoProperty;
72 VariableKey specularColorKey = NoProperty;
73 VariableKey specularPowerKey = NoProperty;
74 VariableKey metallicKey = NoProperty;
75 VariableKey roughnessKey = NoProperty;
76 VariableKey substanceParamsKey = NoProperty;
77 VariableKey parametersKey = NoProperty;
78 VariableKey clippingKey = NoProperty;
79 VariableKey minClippingKey = NoProperty;
80 VariableKey maxClippingKey = NoProperty;
81 VariableKey hasAttributeDataKey = NoProperty;
82 VariableKey surfaceVarianceTextureKey = NoProperty;
83 VariableKey baseColorMapKey = NoProperty;
84 VariableKey normalMapKey = NoProperty;
85 VariableKey occlusionRoughnessMetallicMapKey = NoProperty;
86
87 size_t allowClippingVariantIndex = Material::NoVariantIndex;
88 size_t customEffectVariantIndex = Material::NoVariantIndex;
89 size_t selectionEffectVariantIndex = Material::NoVariantIndex;
90 size_t surfaceVarianceVariantIndex = Material::NoVariantIndex;
91 size_t lightModelVariantIndex = Material::NoVariantIndex;
92 size_t numSubstanceDefinitionMapsVariantIndex = Material::NoVariantIndex;
93
94 TwinCadModelRayPickExtension* rayPickExtension = nullptr;
95 bool componentsCreated = false; // Set to true each time a component has been created, handled and cleared in preUpdate which does entity init.
96 };
97}
Context * context
Pointer to the Context instance the system lives in.
void update()
Updates the system state to that of the current frame.
void preUpdate()
Run the pre-update method of the system.
Component system with parallel data per component stored in a pool similar to how the components them...
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
Base class for picking meshes.
Definition: RayPick.h:227
The mesh render system handles MeshRenderComponents.
Definition: RenderSystem.h:75
Base allocator implementation.
Definition: Allocator.h:30
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
PicksReturned
  * Options for returning picking hits.
Definition: PickingFlags.h:40
PickingFlags
Options for COGS picking.
Definition: PickingFlags.h:12
uint16_t VariableKey
Used to lookup material properties.
Definition: Resources.h:46
ComponentIndex SizeType
Type used to track the size of pools.
Definition: Component.h:19
Handle to a Component instance.
Definition: Component.h:67
bool pickImpl(Context *context, const glm::mat4 &worldPickMatrix, const glm::mat4 &rawViewProjection, const glm::mat4 &viewMatrix, const RayPicking::RayPickFilter &filter, PickingFlags pickingFlags, PicksReturned returnFlag, std::vector< RayPicking::RayPickHit > &hits) override
Each mesh rendering system should implement this function that goes through all components and calls ...
ComponentHandle createComponent() override
void destroyComponent(ComponentHandle handle) override