Plasma Engine  2.0
Loading...
Searching...
No Matches
GreyBoxComponent.h
1#pragma once
2
3#include <Core/ResourceManager/ResourceHandle.h>
4#include <Core/World/Component.h>
5#include <Core/World/World.h>
6#include <GameEngine/GameEngineDLL.h>
7#include <RendererCore/Components/RenderComponent.h>
8#include <RendererCore/Pipeline/RenderData.h>
9#include <RendererCore/Rasterizer/RasterizerObject.h>
10
12class plGeometry;
18struct plMsgSetColor;
23
25
26struct PL_GAMEENGINE_DLL plGreyBoxShape
27{
28 using StorageType = plUInt8;
29
30 enum Enum
31 {
32 Box,
33 RampX,
34 RampY,
35 Column,
36 StairsX,
37 StairsY,
38 ArchX,
39 ArchY,
40 SpiralStairs,
41
42 Default = Box
43 };
44};
45
46PL_DECLARE_REFLECTABLE_TYPE(PL_GAMEENGINE_DLL, plGreyBoxShape)
47
48
51class PL_GAMEENGINE_DLL plGreyBoxComponent : public plRenderComponent
52{
54
56 // plComponent
57
58public:
59 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
60 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
61
62protected:
63 virtual void OnActivated() override;
64
66 // plRenderComponent
67protected:
68 virtual plResult GetLocalBounds(plBoundingBoxSphere& bounds, bool& bAlwaysVisible, plMsgUpdateLocalBounds& msg) override;
69 void OnMsgExtractRenderData(plMsgExtractRenderData& msg) const;
70
72 // plGreyBoxComponent
73
74public:
77
79 void SetShape(plEnum<plGreyBoxShape> shape); // [ property ]
80 plEnum<plGreyBoxShape> GetShape() const { return m_Shape; } // [ property ]
81
83 void SetMaterialFile(const char* szFile); // [ property ]
84 const char* GetMaterialFile() const; // [ property ]
85
87 void SetSizeNegX(float f); // [ property ]
88 float GetSizeNegX() const { return m_fSizeNegX; } // [ property ]
89
91 void SetSizePosX(float f); // [ property ]
92 float GetSizePosX() const { return m_fSizePosX; } // [ property ]
93
95 void SetSizeNegY(float f); // [ property ]
96 float GetSizeNegY() const { return m_fSizeNegY; } // [ property ]
97
99 void SetSizePosY(float f); // [ property ]
100 float GetSizePosY() const { return m_fSizePosY; } // [ property ]
101
103 void SetSizeNegZ(float f); // [ property ]
104 float GetSizeNegZ() const { return m_fSizeNegZ; } // [ property ]
105
107 void SetSizePosZ(float f); // [ property ]
108 float GetSizePosZ() const { return m_fSizePosZ; } // [ property ]
109
111 void SetDetail(plUInt32 uiDetail); // [ property ]
112 plUInt32 GetDetail() const { return m_uiDetail; } // [ property ]
113
115 void SetCurvature(plAngle curvature); // [ property ]
116 plAngle GetCurvature() const { return m_Curvature; } // [ property ]
117
119 void SetSlopedTop(bool b); // [ property ]
120 bool GetSlopedTop() const { return m_bSlopedTop; } // [ property ]
121
123 void SetSlopedBottom(bool b); // [ property ]
124 bool GetSlopedBottom() const { return m_bSlopedBottom; } // [ property ]
125
127 void SetThickness(float f); // [ property ]
128 float GetThickness() const { return m_fThickness; } // [ property ]
129
131 void SetGenerateCollision(bool b); // [ property ]
132 bool GetGenerateCollision() const { return m_bGenerateCollision; } // [ property ]
133
137 void SetIncludeInNavmesh(bool b); // [ property ]
138 bool GetIncludeInNavmesh() const { return m_bIncludeInNavmesh; } // [ property ]
139
141 void SetMaterial(const plMaterialResourceHandle& hMaterial) { m_hMaterial = hMaterial; }
142 plMaterialResourceHandle GetMaterial() const { return m_hMaterial; }
143
144protected:
145 void OnBuildStaticMesh(plMsgBuildStaticMesh& msg) const;
146 void OnMsgExtractGeometry(plMsgExtractGeometry& msg) const;
147 void OnMsgExtractOccluderData(plMsgExtractOccluderData& msg) const;
148 void OnMsgSetMeshMaterial(plMsgSetMeshMaterial& ref_msg); // [ msg handler ]
149 void OnMsgSetColor(plMsgSetColor& ref_msg); // [ msg handler ]
150
152 plMaterialResourceHandle m_hMaterial;
153 plColor m_Color = plColor::White;
154 float m_fSizeNegX = 0;
155 float m_fSizePosX = 0;
156 float m_fSizeNegY = 0;
157 float m_fSizePosY = 0;
158 float m_fSizeNegZ = 0;
159 float m_fSizePosZ = 0;
160 plUInt32 m_uiDetail = 16;
161 plAngle m_Curvature;
162 float m_fThickness = 0.5f;
163 bool m_bSlopedTop = false;
164 bool m_bSlopedBottom = false;
165 bool m_bGenerateCollision = true;
166 bool m_bIncludeInNavmesh = true;
167 bool m_bUseAsOccluder = true;
168
169 void InvalidateMesh();
170 void BuildGeometry(plGeometry& geom, plEnum<plGreyBoxShape> shape, bool bOnlyRoughDetails) const;
171
172 template <typename ResourceType>
173 plTypedResourceHandle<ResourceType> GenerateMesh() const;
174
175 void GenerateMeshName(plStringBuilder& out_sName) const;
176 void GenerateMeshResourceDescriptor(plMeshResourceDescriptor& desc) const;
177
178 plMeshResourceHandle m_hMesh;
179
180 mutable plSharedPtr<const plRasterizerObject> m_pOccluderObject;
181};
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
plColor represents an RGBA color in linear color space. Values are stored as float,...
Definition Color.h:44
static const plColor White
#FFFFFF
Definition Color.h:194
Definition ComponentManager.h:88
Provides functions to generate standard geometric shapes, such as boxes, spheres, cylinders,...
Definition Geometry.h:17
Creates basic geometry for prototyping levels.
Definition GreyBoxComponent.h:52
void SetMaterial(const plMaterialResourceHandle &hMaterial)
Sets the plMaterialResource to use for rendering.
Definition GreyBoxComponent.h:141
Definition MeshComponentBase.h:13
Definition MeshResourceDescriptor.h:9
Base class for objects that should be rendered.
Definition RenderComponent.h:9
A Shared ptr manages a shared object and destroys that object when no one references it anymore....
Definition SharedPtr.h:10
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
Reads a world description from a stream. Allows to instantiate that world multiple times in different...
Definition WorldReader.h:47
Stores an entire plWorld in a stream.
Definition WorldWriter.h:13
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Definition GreyBoxComponent.h:27
Definition PhysicsWorldModule.h:263
Sent by plWorldGeoExtractionUtil to gather geometry information about objects in a world.
Definition WorldGeoExtractionUtil.h:56
Definition RenderData.h:141
Definition RenderData.h:116
A message to modify the main color of some thing.
Definition SetColorMessage.h:32
This message is used to replace the material on a mesh.
Definition MeshComponentBase.h:49
Definition TransformChangedMessage.h:7
Definition UpdateLocalBoundsMessage.h:9
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54