Plasma Engine  2.0
Loading...
Searching...
No Matches
CustomMeshComponent.h
1#pragma once
2
3#include <RendererCore/Meshes/MeshComponentBase.h>
4#include <RendererCore/Pipeline/Renderer.h>
5
8
15class PL_RENDERERCORE_DLL plCustomMeshComponent : public plRenderComponent
16{
18
20 // plComponent
21
22public:
23 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
24 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
25
27 // plRenderComponent
28
29public:
30 virtual plResult GetLocalBounds(plBoundingBoxSphere& ref_bounds, bool& ref_bAlwaysVisible, plMsgUpdateLocalBounds& ref_msg) override;
31
33 // plCustomMeshComponent
34
35public:
38
42 plDynamicMeshBufferResourceHandle CreateMeshResource(plGALPrimitiveTopology::Enum topology, plUInt32 uiMaxVertices, plUInt32 uiMaxPrimitives, plGALIndexType::Enum indexType);
43
45 plDynamicMeshBufferResourceHandle GetMeshResource() const { return m_hDynamicMesh; }
46
51 void SetMeshResource(const plDynamicMeshBufferResourceHandle& hMesh);
52
54 void SetUsePrimitiveRange(plUInt32 uiFirstPrimitive = 0, plUInt32 uiNumPrimitives = plMath::MaxValue<plUInt32>());
55
60 void SetBounds(const plBoundingBoxSphere& bounds);
61
63 void SetMaterial(const plMaterialResourceHandle& hMaterial);
64
66 plMaterialResourceHandle GetMaterial() const;
67
68 void SetMaterialFile(const char* szMaterial); // [ property ]
69 const char* GetMaterialFile() const; // [ property ]
70
72 void SetColor(const plColor& color); // [ property ]
73
75 const plColor& GetColor() const; // [ property ]
76
77 void OnMsgSetMeshMaterial(plMsgSetMeshMaterial& ref_msg); // [ msg handler ]
78 void OnMsgSetColor(plMsgSetColor& ref_msg); // [ msg handler ]
79
80protected:
81 void OnMsgExtractRenderData(plMsgExtractRenderData& msg) const;
82
83 plMaterialResourceHandle m_hMaterial;
84 plColor m_Color = plColor::White;
85 plUInt32 m_uiFirstPrimitive = 0;
86 plUInt32 m_uiNumPrimitives = 0xFFFFFFFF;
87 plBoundingBoxSphere m_Bounds;
88
90
91 virtual void OnActivated() override;
92};
93
95class PL_RENDERERCORE_DLL plCustomMeshRenderData : public plRenderData
96{
97 PL_ADD_DYNAMIC_REFLECTION(plCustomMeshRenderData, plRenderData);
98
99public:
100 virtual void FillBatchIdAndSortingKey();
101
103 plMaterialResourceHandle m_hMaterial;
104 plColor m_Color = plColor::White;
105
106 plUInt32 m_uiFlipWinding : 1;
107 plUInt32 m_uiUniformScale : 1;
108
109 plUInt32 m_uiFirstPrimitive = 0;
110 plUInt32 m_uiNumPrimitives = 0xFFFFFFFF;
111
112 plUInt32 m_uiUniqueID = 0;
113};
114
116class PL_RENDERERCORE_DLL plCustomMeshRenderer : public plRenderer
117{
118 PL_ADD_DYNAMIC_REFLECTION(plCustomMeshRenderer, plRenderer);
119 PL_DISALLOW_COPY_AND_ASSIGN(plCustomMeshRenderer);
120
121public:
124
125 virtual void GetSupportedRenderDataCategories(plHybridArray<plRenderData::Category, 8>& ref_categories) const override;
126 virtual void GetSupportedRenderDataTypes(plHybridArray<const plRTTI*, 8>& ref_types) const override;
127 virtual void RenderBatch(const plRenderViewContext& renderContext, const plRenderPipelinePass* pPass, const plRenderDataBatch& batch) const override;
128};
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
This component is used to render custom geometry.
Definition CustomMeshComponent.h:16
plDynamicMeshBufferResourceHandle GetMeshResource() const
Returns the currently set mesh resource.
Definition CustomMeshComponent.h:45
Temporary data used to feed the plCustomMeshRenderer.
Definition CustomMeshComponent.h:96
A renderer that handles all plCustomMeshRenderData.
Definition CustomMeshComponent.h:117
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
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 plResult GetLocalBounds(plBoundingBoxSphere &ref_bounds, bool &ref_bAlwaysVisible, plMsgUpdateLocalBounds &ref_msg)=0
Called by plRenderComponent::OnUpdateLocalBounds(). If PL_SUCCESS is returned, bounds and bAlwaysVisi...
Definition RenderDataBatch.h:6
Base class for all render data. Render data must contain all information that is needed to render the...
Definition RenderData.h:14
Definition RenderPipelinePass.h:26
This is the base class for types that handle rendering of different object types.
Definition Renderer.h:9
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
constexpr TYPE MaxValue()
Returns the largest possible positive value (that is not infinity).
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 UpdateLocalBoundsMessage.h:9
Definition Declarations.h:51
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54