Plasma Engine  2.0
Loading...
Searching...
No Matches
BeamComponent.h
1#pragma once
2
3#include <RendererCore/RendererCoreDLL.h>
4
5#include <Core/Messages/EventMessage.h>
6#include <RendererCore/Components/RenderComponent.h>
7#include <RendererCore/Material/MaterialResource.h>
8#include <RendererCore/Meshes/MeshResource.h>
9
11
13class plGeometry;
15
22class PL_RENDERERCORE_DLL plBeamComponent : public plRenderComponent
23{
24 PL_DECLARE_COMPONENT_TYPE(plBeamComponent, plRenderComponent, plBeamComponentManager);
25
27 // plComponent
28
29public:
30 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
31 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
32
33protected:
34 virtual void OnActivated() override;
35 virtual void OnDeactivated() override;
36
38 // plRenderComponent
39
40public:
41 virtual plResult GetLocalBounds(plBoundingBoxSphere& ref_bounds, bool& ref_bAlwaysVisible, plMsgUpdateLocalBounds& ref_msg) override;
42
43
45 // plBeamComponent
46
47public:
50
52 void SetTargetObject(const char* szReference); // [ property ]
53
55 void SetWidth(float fWidth); // [ property ]
56 float GetWidth() const; // [ property ]
57
59 void SetUVUnitsPerWorldUnit(float fUVUnitsPerWorldUnit); // [ property ]
60 float GetUVUnitsPerWorldUnit() const; // [ property ]
61
63 void SetMaterialFile(const char* szFile); // [ property ]
64 const char* GetMaterialFile() const; // [ property ]
65
66 plMaterialResourceHandle GetMaterial() const;
67
70
72 plColor m_Color = plColor::White; // [ property ]
73
74protected:
75 void Update();
76
77 void OnMsgExtractRenderData(plMsgExtractRenderData& msg) const;
78
79 float m_fWidth = 0.1f; // [ property ]
80 float m_fUVUnitsPerWorldUnit = 1.0f; // [ property ]
81
82 plMaterialResourceHandle m_hMaterial; // [ property ]
83
84 const float m_fDistanceUpdateEpsilon = 0.02f;
85
87
88 plVec3 m_vLastOwnerPosition = plVec3::MakeZero();
89 plVec3 m_vLastTargetPosition = plVec3::MakeZero();
90
91 void CreateMeshes();
92 void BuildMeshResourceFromGeometry(plGeometry& Geometry, plMeshResourceDescriptor& MeshDesc) const;
93 void ReinitMeshes();
94 void Cleanup();
95
96 const char* DummyGetter() const { return nullptr; }
97};
Renders a thick line from its own location to the position of another game object.
Definition BeamComponent.h:23
plGameObjectHandle m_hTargetObject
The object to which to draw the beam.
Definition BeamComponent.h:69
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
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 DeserializeComponent(plWorldReader &inout_stream)
Override this to load the current state of the component from the given stream.
Definition Component.cpp:58
Simple component manager implementation that calls an update method on all components every frame.
Definition ComponentManager.h:142
Provides functions to generate standard geometric shapes, such as boxes, spheres, cylinders,...
Definition Geometry.h:17
Definition MeshResourceDescriptor.h:9
Base class for objects that should be rendered.
Definition RenderComponent.h:9
virtual void OnActivated() override
This method is called when the component gets activated.
Definition RenderComponent.cpp:33
virtual void OnDeactivated() override
This method is called when the component gets deactivated.
Definition RenderComponent.cpp:38
virtual plResult GetLocalBounds(plBoundingBoxSphere &ref_bounds, bool &ref_bAlwaysVisible, plMsgUpdateLocalBounds &ref_msg)=0
Called by plRenderComponent::OnUpdateLocalBounds(). If PL_SUCCESS is returned, bounds and bAlwaysVisi...
static plVec3Template< float > MakeZero()
Definition Vec3.h:38
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 handle to a game object.
Definition Declarations.h:76
Definition RenderData.h:116
Definition UpdateLocalBoundsMessage.h:9
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54