Cogs.Core
VariableExtrusionSystem.h
1#pragma once
2
3#include "Systems/ComponentSystem.h"
4
5#include "Components/Geometry/VariableExtrusionComponent.h"
6#include "Components/Core/MeshComponent.h"
7
8#include "Resources/MeshManager.h"
9
10namespace Cogs
11{
12 namespace Core
13 {
14 class Context;
15
17 {
18 size_t pathLength = 0;
19 glm::vec3 primaryAxis;
20 size_t numSegments = 0;
21 bool useTexture = false;
22
23 std::vector<glm::vec3> positions;
24 std::vector<glm::vec3> directions;
25
26 std::vector<float> offsetDepths;
27
28 std::vector<glm::quat> rotations;
29
30 std::vector<glm::vec3> crossSection;
31 std::vector<glm::vec3> morphCrossSection;
32
33 std::vector<int32_t> indexes;
34
35 std::vector<glm::vec2> textureCoordinates;
36
37 EntityPtr sideShape;
38 };
39
40 class VariableExtrusionSystem : public ComponentSystemWithDataPool<VariableExtrusionComponent, VariableExtrusionData>
41 {
42 public:
43 VariableExtrusionSystem(Memory::Allocator * allocator, SizeType capacity) : ComponentSystemWithDataPool(allocator, capacity) {}
44
45 void update(Context * context);
46
47 void updatePath(Context * context, const VariableExtrusionComponent & component);
48 void updateSegmentCount(Context * context, const VariableExtrusionComponent & component);
49 void updateRotations(Context * context, const VariableExtrusionComponent & component);
50 void updateCrossSections(Context * context, const VariableExtrusionComponent & component);
51 void updateOffsets(Context * context, const VariableExtrusionComponent & component);
52 void updateTransformation(Context * context, const VariableExtrusionComponent & component);
53 void offsetCrossSections(Context * context, const VariableExtrusionComponent & component);
54 void updateTextureCoordinates(Context * context, const VariableExtrusionComponent & component);
55 void updateIndexes(Context * context, const VariableExtrusionComponent & component);
56 void updateSideShape(Context * context, const VariableExtrusionComponent & component);
57 void updateNormals(Context * context, const VariableExtrusionComponent & component);
58
59 Mesh * getMesh(Context * context, const VariableExtrusionComponent & component);
60 };
61 }
62}
Context * context
Pointer to the Context instance the system lives in.
void update()
Updates the system state to that of the current frame.
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 allocator implementation.
Definition: Allocator.h:30
std::shared_ptr< ComponentModel::Entity > EntityPtr
Smart pointer for Entity access.
Definition: EntityPtr.h:12
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
ComponentIndex SizeType
Type used to track the size of pools.
Definition: Component.h:19
Meshes contain streams of vertex data in addition to index data and options defining geometry used fo...
Definition: Mesh.h:265