Plasma Engine  2.0
Loading...
Searching...
No Matches
KrautTreeResource.h
1#pragma once
2
3#include <Core/ResourceManager/Resource.h>
4#include <Foundation/Containers/StaticArray.h>
5#include <Foundation/Math/BoundingBoxSphere.h>
6#include <KrautPlugin/KrautDeclarations.h>
7
12
13struct PL_KRAUTPLUGIN_DLL plKrautTreeResourceDetails
14{
15 plBoundingBoxSphere m_Bounds;
16 plVec3 m_vLeafCenter;
17 float m_fStaticColliderRadius;
18 plString m_sSurfaceResource;
19};
20
21struct PL_KRAUTPLUGIN_DLL plKrautTreeResourceDescriptor
22{
23 void Save(plStreamWriter& inout_stream) const;
24 plResult Load(plStreamReader& inout_stream);
25
27 {
28 PL_DECLARE_POD_TYPE();
29
30 plVec3 m_vPosition;
31 plVec3 m_vTexCoord; // U,V and Q
32 float m_fAmbientOcclusion = 1.0f;
33 plVec3 m_vNormal;
34 plVec3 m_vTangent;
35 plUInt8 m_uiColorVariation = 0;
36
37 // to compute wind
38 plUInt8 m_uiBranchLevel = 0; // 0 = trunk, 1 = main branches, 2 = twigs, ...
39 plUInt8 m_uiFlutterPhase = 0; // phase shift for the flutter effect
40 plVec3 m_vBendAnchor;
41 float m_fAnchorBendStrength = 0;
42 float m_fBendAndFlutterStrength = 0;
43 };
44
46 {
47 PL_DECLARE_POD_TYPE();
48
49 plUInt32 m_uiVertexIndex[3];
50 };
51
53 {
54 plUInt16 m_uiFirstTriangle = 0;
55 plUInt16 m_uiNumTriangles = 0;
56 plUInt8 m_uiMaterialIndex = 0xFF;
57 };
58
59 struct LodData
60 {
61 float m_fMinLodDistance = 0;
62 float m_fMaxLodDistance = 0;
63 plKrautLodType m_LodType = plKrautLodType::None;
64
68 };
69
71 {
72 plKrautMaterialType m_MaterialType;
73 plString m_sMaterial;
74 plColorGammaUB m_VariationColor = plColor::White; // currently done through the material
75 };
76
80};
81
82class PL_KRAUTPLUGIN_DLL plKrautTreeResource : public plResource
83{
84 PL_ADD_DYNAMIC_REFLECTION(plKrautTreeResource, plResource);
85 PL_RESOURCE_DECLARE_COMMON_CODE(plKrautTreeResource);
86 PL_RESOURCE_DECLARE_CREATEABLE(plKrautTreeResource, plKrautTreeResourceDescriptor);
87
88public:
90
91 const plKrautTreeResourceDetails& GetDetails() const { return m_Details; }
92
93 struct TreeLod
94 {
96 float m_fMinLodDistance = 0;
97 float m_fMaxLodDistance = 0;
98 plKrautLodType m_LodType = plKrautLodType::None;
99 };
100
101 plArrayPtr<const TreeLod> GetTreeLODs() const { return m_TreeLODs.GetArrayPtr(); }
102
103private:
104 virtual plResourceLoadDesc UnloadData(Unload WhatToUnload) override;
105 virtual plResourceLoadDesc UpdateContent(plStreamReader* Stream) override;
106 virtual void UpdateMemoryUsage(MemoryUsage& out_NewMemoryUsage) override;
107
109 plStaticArray<TreeLod, 5> m_TreeLODs;
110};
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
A 8bit per channel unsigned normalized (values interpreted as 0-1) color storage format that represen...
Definition Color8UNorm.h:99
static const plColor White
#FFFFFF
Definition Color.h:194
Definition DynamicArray.h:81
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Definition KrautTreeResource.h:83
The base class for all resources.
Definition Resource.h:10
Wraps a C-style array, which has a fixed size at compile-time, with a more convenient interface.
Definition StaticArray.h:13
Interface for binary in (read) streams.
Definition Stream.h:22
Interface for binary out (write) streams.
Definition Stream.h:107
Definition KrautTreeResource.h:94
Definition KrautTreeResource.h:60
Definition KrautTreeResource.h:71
Definition KrautTreeResource.h:53
Definition KrautTreeResource.h:46
Definition KrautTreeResource.h:27
Definition KrautTreeResource.h:22
Definition KrautTreeResource.h:14
Describes in which loading state a resource currently is, and how many different quality levels there...
Definition Declarations.h:102
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54