Plasma Engine  2.0
Loading...
Searching...
No Matches
ProcVolumeComponent.h
1#pragma once
2
3#include <Core/ResourceManager/ResourceHandle.h>
4#include <Core/World/World.h>
5#include <ProcGenPlugin/Declarations.h>
6
10
12
13class PL_PROCGENPLUGIN_DLL plProcVolumeComponent : public plComponent
14{
15 PL_DECLARE_ABSTRACT_COMPONENT_TYPE(plProcVolumeComponent, plComponent);
16
17public:
20
21 virtual void OnActivated() override;
22 virtual void OnDeactivated() override;
23
24 void SetValue(float fValue);
25 float GetValue() const { return m_fValue; }
26
27 void SetSortOrder(float fOrder);
28 float GetSortOrder() const { return m_fSortOrder; }
29
30 void SetBlendMode(plEnum<plProcGenBlendMode> blendMode);
31 plEnum<plProcGenBlendMode> GetBlendMode() const { return m_BlendMode; }
32
33 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
34 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
35
36 void OnTransformChanged(plMsgTransformChanged& ref_msg);
37
38 static const plEvent<const plProcGenInternal::InvalidatedArea&>& GetAreaInvalidatedEvent() { return s_AreaInvalidatedEvent; }
39
40protected:
41 float m_fValue = 1.0f;
42 float m_fSortOrder = 0.0f;
44
45 void InvalidateArea();
46 void InvalidateArea(const plBoundingBox& area);
47
48 static plEvent<const plProcGenInternal::InvalidatedArea&> s_AreaInvalidatedEvent;
49};
50
52
54
55class PL_PROCGENPLUGIN_DLL plProcVolumeSphereComponent : public plProcVolumeComponent
56{
58
59public:
62
63 float GetRadius() const { return m_fRadius; }
64 void SetRadius(float fRadius);
65
66 float GetFalloff() const { return m_fFalloff; }
67 void SetFalloff(float fFalloff);
68
69 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
70 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
71
72 void OnUpdateLocalBounds(plMsgUpdateLocalBounds& ref_msg) const;
73 void OnExtractVolumes(plMsgExtractVolumes& ref_msg) const;
74
75protected:
76 float m_fRadius = 5.0f;
77 float m_fFalloff = 0.5f;
78};
79
81
83
84class PL_PROCGENPLUGIN_DLL plProcVolumeBoxComponent : public plProcVolumeComponent
85{
87
88public:
91
92 const plVec3& GetExtents() const { return m_vExtents; }
93 void SetExtents(const plVec3& vExtents);
94
95 const plVec3& GetFalloff() const { return m_vFalloff; }
96 void SetFalloff(const plVec3& vFalloff);
97
98 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
99 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
100
101 void OnUpdateLocalBounds(plMsgUpdateLocalBounds& ref_msg) const;
102 void OnExtractVolumes(plMsgExtractVolumes& ref_msg) const;
103
104protected:
105 plVec3 m_vExtents = plVec3(10.0f);
106 plVec3 m_vFalloff = plVec3(0.5f);
107};
108
110
112
113class PL_PROCGENPLUGIN_DLL plProcVolumeImageComponent : public plProcVolumeBoxComponent
114{
116
117public:
120
121 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
122 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
123
124 void OnExtractVolumes(plMsgExtractVolumes& ref_msg) const;
125
126 void SetImageFile(const char* szFile); // [ property ]
127 const char* GetImageFile() const; // [ property ]
128
129 void SetImage(const plImageDataResourceHandle& hResource);
130 plImageDataResourceHandle GetImage() const { return m_hImage; }
131
132protected:
134};
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 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 Event.h:177
Definition ProcVolumeComponent.h:85
Definition ProcVolumeComponent.h:14
Definition ProcVolumeComponent.h:114
Definition ProcVolumeComponent.h:56
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 VolumeCollection.h:86
Definition TransformChangedMessage.h:7
Definition UpdateLocalBoundsMessage.h:9