Plasma Engine  2.0
Loading...
Searching...
No Matches
MeshResourceDescriptor.h
1#pragma once
2
3#include <Foundation/IO/Stream.h>
4#include <Foundation/Math/BoundingBoxSphere.h>
5#include <RendererCore/AnimationSystem/SkeletonResource.h>
6#include <RendererCore/Meshes/MeshBufferResource.h>
7
8class PL_RENDERERCORE_DLL plMeshResourceDescriptor
9{
10public:
11 struct SubMesh
12 {
13 PL_DECLARE_POD_TYPE();
14
15 plUInt32 m_uiPrimitiveCount;
16 plUInt32 m_uiFirstPrimitive;
17 plUInt32 m_uiMaterialIndex;
18
19 plBoundingBoxSphere m_Bounds;
20 };
21
22 struct Material
23 {
24 plString m_sPath;
25 };
26
28
29 void Clear();
30
31 plMeshBufferResourceDescriptor& MeshBufferDesc();
32
33 const plMeshBufferResourceDescriptor& MeshBufferDesc() const;
34
35 void UseExistingMeshBuffer(const plMeshBufferResourceHandle& hBuffer);
36
37 void AddSubMesh(plUInt32 uiPrimitiveCount, plUInt32 uiFirstPrimitive, plUInt32 uiMaterialIndex);
38
39 void SetMaterial(plUInt32 uiMaterialIndex, const char* szPathToMaterial);
40
41 void Save(plStreamWriter& inout_stream);
42 plResult Save(const char* szFile);
43
44 plResult Load(plStreamReader& inout_stream);
45 plResult Load(const char* szFile);
46
47 const plMeshBufferResourceHandle& GetExistingMeshBuffer() const;
48
49 plArrayPtr<const Material> GetMaterials() const;
50
51 plArrayPtr<const SubMesh> GetSubMeshes() const;
52
54 void CollapseSubMeshes();
55
56 void ComputeBounds();
57 const plBoundingBoxSphere& GetBounds() const;
58 void SetBounds(const plBoundingBoxSphere& bounds) { m_Bounds = bounds; }
59
60 struct BoneData
61 {
62 plMat4 m_GlobalInverseRestPoseMatrix;
63 plUInt16 m_uiBoneIndex = plInvalidJointIndex;
64
65 plResult Serialize(plStreamWriter& inout_stream) const;
66 plResult Deserialize(plStreamReader& inout_stream);
67 };
68
69 plSkeletonResourceHandle m_hDefaultSkeleton;
71 float m_fMaxBoneVertexOffset = 0.0f; // the maximum distance between any vertex and its influencing bones, can be used for adjusting the bounding box of a pose
72
73private:
75 plHybridArray<SubMesh, 8> m_SubMeshes;
76 plMeshBufferResourceDescriptor m_MeshBufferDescriptor;
77 plMeshBufferResourceHandle m_hMeshBuffer;
78 plBoundingBoxSphere m_Bounds;
79};
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition HashTable.h:333
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Definition MeshResourceDescriptor.h:9
Interface for binary in (read) streams.
Definition Stream.h:22
Interface for binary out (write) streams.
Definition Stream.h:107
Definition MeshBufferResource.h:33
Definition MeshResourceDescriptor.h:61
Definition MeshResourceDescriptor.h:23
Definition MeshResourceDescriptor.h:12
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54