Plasma Engine  2.0
Loading...
Searching...
No Matches
RopeRenderComponent.h
1#pragma once
2
3#include <RendererCore/Components/RenderComponent.h>
4#include <RendererCore/Meshes/MeshResource.h>
5#include <RendererCore/Meshes/SkinnedMeshComponent.h>
6#include <memory>
7
9struct plMsgSetColor;
13
15
21class PL_RENDERERCORE_DLL plRopeRenderComponent : public plRenderComponent
22{
24
26 // plComponent
27
28public:
29 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
30 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
31
32protected:
33 virtual void OnActivated() override;
34 virtual void OnDeactivated() override;
35
37 // plRenderComponent
38
39protected:
40 virtual plResult GetLocalBounds(plBoundingBoxSphere& bounds, bool& bAlwaysVisible, plMsgUpdateLocalBounds& msg) override;
41 void OnMsgExtractRenderData(plMsgExtractRenderData& msg) const; // [ msg handler ]
42
44 // plRopeRenderComponent
45
46public:
49
50 plColor m_Color = plColor::White; // [ property ]
51
52 void SetMaterialFile(const char* szFile); // [ property ]
53 const char* GetMaterialFile() const; // [ property ]
54
55 void SetMaterial(const plMaterialResourceHandle& hMaterial) { m_hMaterial = hMaterial; }
56 plMaterialResourceHandle GetMaterial() const { return m_hMaterial; }
57
59 void SetThickness(float fThickness); // [ property ]
60 float GetThickness() const { return m_fThickness; } // [ property ]
61
63 void SetDetail(plUInt32 uiDetail); // [ property ]
64 plUInt32 GetDetail() const { return m_uiDetail; } // [ property ]
65
67 void SetSubdivide(bool bSubdivide); // [ property ]
68 bool GetSubdivide() const { return m_bSubdivide; } // [ property ]
69
71 void SetUScale(float fUScale); // [ property ]
72 float GetUScale() const { return m_fUScale; } // [ property ]
73
74 void OnMsgSetColor(plMsgSetColor& ref_msg); // [ msg handler ]
75 void OnMsgSetMeshMaterial(plMsgSetMeshMaterial& ref_msg); // [ msg handler ]
76
77private:
78 void OnRopePoseUpdated(plMsgRopePoseUpdated& msg); // [ msg handler ]
79 void GenerateRenderMesh(plUInt32 uiNumRopePieces);
80 void UpdateSkinningTransformBuffer(plArrayPtr<const plTransform> skinningTransforms);
81
82 plBoundingBoxSphere m_LocalBounds;
83
84 plSkinningState m_SkinningState;
85
87 plMaterialResourceHandle m_hMaterial;
88
89 float m_fThickness = 0.05f;
90 plUInt32 m_uiDetail = 6;
91 bool m_bSubdivide = false;
92
93 float m_fUScale = 1.0f;
94};
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
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
Definition ComponentManager.h:88
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...
Used to render a rope or cable.
Definition RopeRenderComponent.h:22
A wrapper class that converts a plTransform into the correct data layout for shaders.
Definition Types.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
Definition RenderData.h:116
Used by components that do rope simulation and rendering.
Definition Declarations.h:89
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 UpdateLocalBoundsMessage.h:9
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
Definition SkinnedMeshComponent.h:21