Plasma Engine  2.0
Loading...
Searching...
No Matches
WindVolumeComponent.h
1#pragma once
2
3#include <Core/Interfaces/WindWorldModule.h>
4#include <Core/World/Component.h>
5#include <Core/World/Declarations.h>
6#include <Core/World/World.h>
7#include <GameEngine/GameEngineDLL.h>
8
12
16class PL_GAMEENGINE_DLL plWindVolumeComponent : public plComponent
17{
18 PL_DECLARE_ABSTRACT_COMPONENT_TYPE(plWindVolumeComponent, plComponent);
19
21 // plComponent
22
23public:
24 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
25 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
26
27protected:
28 virtual void OnActivated() override;
29 virtual void OnDeactivated() override;
30 virtual void OnSimulationStarted() override;
31
33 // plWindVolumeComponent
34
35public:
38
41
43 plTime m_BurstDuration; // [ property ]
44
47
49 float m_fStrengthFactor = 1.0f;
50
54 plSimdVec4f ComputeForceAtGlobalPosition(const plSimdVec4f& vGlobalPos) const;
55
56 virtual plSimdVec4f ComputeForceAtLocalPosition(const plSimdVec4f& vLocalPos) const = 0;
57
60
61protected:
62 void OnTriggered(plMsgComponentInternalTrigger& msg);
63 void OnMsgDeleteGameObject(plMsgDeleteGameObject& msg);
64
65 float GetWindInMetersPerSecond() const;
66};
67
71
73
77class PL_GAMEENGINE_DLL plWindVolumeSphereComponent : public plWindVolumeComponent
78{
80
82 // plComponent
83
84public:
85 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
86 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
87
89 // plWindVolumeSphereComponent
90
91public:
94
95 virtual plSimdVec4f ComputeForceAtLocalPosition(const plSimdVec4f& vLocalPos) const override;
96
97 float GetRadius() const { return m_fRadius; } // [ property ]
98 void SetRadius(float fVal); // [ property ]
99
100private:
101 void OnUpdateLocalBounds(plMsgUpdateLocalBounds& msg);
102
103 float m_fRadius = 1.0f;
104 plSimdFloat m_fOneDivRadius;
105};
106
110
113{
114 using StorageType = plUInt8;
115
116 enum Enum
117 {
120
121 Default = Directional
122 };
123};
124
125PL_DECLARE_REFLECTABLE_TYPE(PL_GAMEENGINE_DLL, plWindVolumeCylinderMode);
126
128
133{
135
137 // plComponent
138
139public:
140 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
141 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
142
144 // plWindVolumeCylinderComponent
145
146public:
149
150 virtual plSimdVec4f ComputeForceAtLocalPosition(const plSimdVec4f& vLocalPos) const override;
151
152 float GetRadius() const { return m_fRadius; } // [ property ]
153 void SetRadius(float fVal); // [ property ]
154
155 float GetRadiusFalloff() const { return m_fRadiusFalloff; } // [ property ]
156 void SetRadiusFalloff(float fVal); // [ property ]
157
158 float GetLength() const { return m_fLength; } // [ property ]
159 void SetLength(float fVal); // [ property ]
160
161 float GetPositiveFalloff() const { return m_fPositiveFalloff; } // [ property ]
162 void SetPositiveFalloff(float fVal); // [ property ]
163
164 float GetNegativeFalloff() const { return m_fNegativeFalloff; } // [ property ]
165 void SetNegativeFalloff(float fVal); // [ property ]
166
167 plEnum<plWindVolumeCylinderMode> m_Mode; // [ property ]
168
169private:
170 void OnUpdateLocalBounds(plMsgUpdateLocalBounds& msg);
171
172 void ComputeScaleBiasValues();
173
174 float m_fRadius = 1.0f;
175 float m_fRadiusFalloff = 0.0f;
176 float m_fLength = 5.0f;
177 float m_fPositiveFalloff = 0.0f;
178 float m_fNegativeFalloff = 0.0f;
179
180 plSimdVec4f m_vScaleValues;
181 plSimdVec4f m_vBiasValues;
182};
183
187
189
194class PL_GAMEENGINE_DLL plWindVolumeConeComponent : public plWindVolumeComponent
195{
197
199 // plComponent
200
201public:
202 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
203 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
204
206 // plWindVolumeCylinderComponent
207
208public:
211
212 virtual plSimdVec4f ComputeForceAtLocalPosition(const plSimdVec4f& vLocalPos) const override;
213
214 float GetLength() const { return m_fLength; } // [ property ]
215 void SetLength(float fVal); // [ property ]
216
217 plAngle GetAngle() const { return m_Angle; } // [ property ]
218 void SetAngle(plAngle val); // [ property ]
219
220private:
221 void OnUpdateLocalBounds(plMsgUpdateLocalBounds& msg);
222
223 float m_fLength = 1.0f;
224 plAngle m_Angle = plAngle::MakeFromDegree(45);
225};
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
static constexpr plAngle MakeFromDegree(float fDegree)
Creates an instance of plAngle that was initialized from degree. (Performs a conversion)
Definition Angle_inl.h:33
Base class of all component types.
Definition Component.h:25
virtual void SerializeComponent(plWorldWriter &inout_stream) const
Override this to save the current state of the component to the given stream.
Definition Component.cpp:54
virtual void OnDeactivated()
This method is called when the component gets deactivated.
Definition Component.cpp:142
virtual void OnSimulationStarted()
This method is called once for active components, at the start of the next world update,...
Definition Component.cpp:144
virtual void DeserializeComponent(plWorldReader &inout_stream)
Override this to load the current state of the component from the given stream.
Definition Component.cpp:58
virtual void OnActivated()
This method is called when the component gets activated.
Definition Component.cpp:140
Definition ComponentManager.h:88
Definition SimdFloat.h:7
A 4-component SIMD vector class.
Definition SimdVec4f.h:8
Base class for components that define wind volumes.
Definition WindVolumeComponent.h:17
plEnum< plWindStrength > m_Strength
How strong the wind shall blow at the strongest point of the volume.
Definition WindVolumeComponent.h:46
plEnum< plOnComponentFinishedAction > m_OnFinishedAction
What happens after the wind burst is over.
Definition WindVolumeComponent.h:59
plTime m_BurstDuration
If non-zero, the wind will only last for a limited amount of time.
Definition WindVolumeComponent.h:43
static plSpatialData::Category SpatialDataCategory
The spatial category to use to find all wind volume components through the spatial system.
Definition WindVolumeComponent.h:40
A conical shape in which wind shall be applied to objects.
Definition WindVolumeComponent.h:195
A cylindrical volume in which wind shall be applied.
Definition WindVolumeComponent.h:133
A spherical shape in which wind shall be applied to objects.
Definition WindVolumeComponent.h:78
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
For internal use by components to trigger some known behavior. Usually components will post this mess...
Definition TriggerMessage.h:26
Definition DeleteObjectMessage.h:7
Definition UpdateLocalBoundsMessage.h:9
Definition SpatialData.h:27
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
How the wind direction shall be calculated in a cylindrical wind volume.
Definition WindVolumeComponent.h:113
Enum
Definition WindVolumeComponent.h:117
@ Directional
The wind direction is outwards from the cylinder.
Definition WindVolumeComponent.h:118
@ Vortex
The wind direction is tangential, moving in a circular fashion around the cylinder like in a tornado.
Definition WindVolumeComponent.h:119