Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Mesh.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_MESH_H_
34#define DVD_MESH_H_
35
51#include "Object3D.h"
53
54struct aiScene;
55namespace Divide {
56
59
60namespace Attorney {
61 class MeshImporter;
62}
63
64class MeshImporter;
65
67{
71 string _name;
72
73 bool serialize(ByteBuffer& dataOut) const;
74 bool deserialize(ByteBuffer& dataIn);
75};
76
78{
79 friend class Attorney::MeshImporter;
80
81 public:
82 struct MeshData {
83 Handle<SubMesh> _mesh{INVALID_HANDLE<SubMesh>};
84 U32 _index{0u};
85};
86
87 public:
88 explicit Mesh( const ResourceDescriptor<Mesh>& descriptor );
89
90 void postLoad(SceneGraphNode* sgn) override;
91 bool postLoad() override;
92 bool load( PlatformContext& context ) override;
93 bool unload() override;
94 void setMaterialTpl(Handle<Material> material) override;
95
96 void setAnimationCount(const size_t count);
97
98 [[nodiscard]] SceneAnimator* getAnimator() const noexcept;
99
100 PROPERTY_R(size_t, animationCount, 0u);
101
102 protected:
103 void addSubMesh(Handle<SubMesh> subMesh, U32 index);
104 void processNode(SceneGraphNode* parentNode, const MeshNodeData& node);
105 SceneGraphNode* addSubMeshNode(SceneGraphNode* parentNode, const U32 meshIndex);
106 void setNodeData(const MeshNodeData& nodeStructure);
107
108 protected:
109 U64 _lastTimeStamp = 0ull;
111 SceneAnimator_uptr _animator;
112 vector<MeshData> _subMeshList;
113 MeshNodeData _nodeStructure;
114};
115
116namespace Attorney {
118 static void setNodeData(Mesh& parentMesh, const MeshNodeData& nodeStructure)
119 {
120 parentMesh.setNodeData(nodeStructure);
121 }
122
123 static void addSubMesh(Mesh& parentMesh, const Handle<SubMesh> subMesh, const U32 index)
124 {
125 parentMesh.addSubMesh(subMesh, index);
126 }
127
129 };
130} //namespace Attorney
131
133
134}; // namespace Divide
135
136#endif //DVD_MESH_H_
#define PROPERTY_R(...)
Convenience method to add a class member with public read access but protected write access.
#define TYPEDEF_SMART_POINTERS_FOR_TYPE(T)
#define FWD_DECLARE_MANAGED_CLASS(T)
#define DEFINE_3D_OBJECT_TYPE(Name, Enum)
Definition: SceneNodeFwd.h:128
static void addSubMesh(Mesh &parentMesh, const Handle< SubMesh > subMesh, const U32 index)
Definition: Mesh.h:123
static void setNodeData(Mesh &parentMesh, const MeshNodeData &nodeStructure)
Definition: Mesh.h:118
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
bool load() override
bool unload() override
eastl::vector< Type > vector
Definition: Vector.h:42
uint32_t U32
uint64_t U64
bool deserialize(ByteBuffer &dataIn)
Definition: Mesh.cpp:194
vector< MeshNodeData > _children
Definition: Mesh.h:70
mat4< F32 > _transform
Definition: Mesh.h:68
vector< U32 > _meshIndices
Index into Mesh::MeshData.
Definition: Mesh.h:69
string _name
Definition: Mesh.h:71
bool serialize(ByteBuffer &dataOut) const
Definition: Mesh.cpp:182