Plasma Engine  2.0
Loading...
Searching...
No Matches
KrautTreeComponent.h
1#pragma once
2
3#include <Core/ResourceManager/ResourceHandle.h>
4#include <KrautPlugin/KrautDeclarations.h>
5#include <KrautPlugin/Renderer/KrautRenderData.h>
6#include <RendererCore/Components/RenderComponent.h>
7#include <RendererCore/Meshes/MeshResource.h>
8#include <RendererCore/Pipeline/RenderData.h>
9#include <RendererCore/Utils/WorldGeoExtractionUtil.h>
10
13struct plResourceEvent;
16
19
20class PL_KRAUTPLUGIN_DLL plKrautTreeComponentManager : public plComponentManager<class plKrautTreeComponent, plBlockStorageType::Compact>
21{
22public:
24
26 : SUPER(pWorld)
27 {
28 }
29
30 void Update(const plWorldModule::UpdateContext& context);
31 void EnqueueUpdate(plComponentHandle hComponent);
32
33private:
34 void ResourceEventHandler(const plResourceEvent& e);
35
36 mutable plMutex m_Mutex;
37 plDeque<plComponentHandle> m_RequireUpdate;
38
39protected:
40 virtual void Initialize() override;
41 virtual void Deinitialize() override;
42};
43
45class PL_KRAUTPLUGIN_DLL plKrautTreeComponent : public plRenderComponent
46{
48
50 // plComponent
51
52public:
53 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
54 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
55
56protected:
57 virtual void OnActivated() override;
58
60 // plRenderComponent
61
62protected:
63 virtual plResult GetLocalBounds(plBoundingBoxSphere& bounds, bool& bAlwaysVisible, plMsgUpdateLocalBounds& msg) override;
64 void OnMsgExtractRenderData(plMsgExtractRenderData& msg) const;
65
67 // plKrautTreeComponent
68
69public:
72
73 // see plKrautTreeComponent::GetLocalBounds for details
74 static const int s_iLocalBoundsScale = 3;
75
77 void OnMsgExtractGeometry(plMsgExtractGeometry& ref_msg) const;
79 void OnBuildStaticMesh(plMsgBuildStaticMesh& ref_msg) const;
80
81 void SetKrautFile(const char* szFile); // [ property ]
82 const char* GetKrautFile() const; // [ property ]
83
92 void SetVariationIndex(plUInt16 uiIndex); // [ property ]
93 plUInt16 GetVariationIndex() const; // [ property ]
94
98 void SetCustomRandomSeed(plUInt16 uiSeed); // [ property ]
99 plUInt16 GetCustomRandomSeed() const; // [ property ]
100
102 void SetKrautGeneratorResource(const plKrautGeneratorResourceHandle& hTree);
103 const plKrautGeneratorResourceHandle& GetKrautGeneratorResource() const { return m_hKrautGenerator; }
104
105private:
107 plResult CreateGeometry(plGeometry& geo, plWorldGeoExtractionUtil::ExtractionMode mode) const;
108 void EnsureTreeIsGenerated();
109
110 plUInt16 m_uiVariationIndex = 0xFFFF;
111 plUInt16 m_uiCustomRandomSeed = 0xFFFF;
112 plKrautTreeResourceHandle m_hKrautTree;
113 plKrautGeneratorResourceHandle m_hKrautGenerator;
114
115 void ComputeWind() const;
116
117 mutable plUInt64 m_uiLastWindUpdate = (plUInt64)-1;
118 mutable plVec3 m_vWindSpringPos;
119 mutable plVec3 m_vWindSpringVel;
120};
Definition AbstractObjectGraph.h:17
Definition ComponentManager.h:88
Definition Deque.h:270
Provides functions to generate standard geometric shapes, such as boxes, spheres, cylinders,...
Definition Geometry.h:17
Definition KrautRenderData.h:12
Instantiates a Kraut tree model.
Definition KrautTreeComponent.h:46
Definition KrautTreeComponent.h:21
Provides a simple mechanism for mutual exclusion to prevent multiple threads from accessing a shared ...
Definition Mutex.h:13
Base class for objects that should be rendered.
Definition RenderComponent.h:9
ExtractionMode
Describes what the geometry is needed for.
Definition WorldGeoExtractionUtil.h:31
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
virtual void Initialize()
This method is called after the constructor. A derived type can override this method to do initializa...
Definition WorldModule.h:98
virtual void Deinitialize()
This method is called before the destructor. A derived type can override this method to do deinitiali...
Definition WorldModule.h:101
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 component.
Definition Declarations.h:138
Definition PhysicsWorldModule.h:263
Sent by plWorldGeoExtractionUtil to gather geometry information about objects in a world.
Definition WorldGeoExtractionUtil.h:56
Definition RenderData.h:116
Definition UpdateLocalBoundsMessage.h:9
These events may be sent by a specific plResource or by the plResourceManager.
Definition Declarations.h:22
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
Definition WorldModule.h:33