Berserk
ResMesh.hpp
Go to the documentation of this file.
1 /**********************************************************************************/
2 /* This file is part of Berserk Engine project */
3 /* https://github.com/EgorOrachyov/Berserk */
4 /**********************************************************************************/
5 /* MIT License */
6 /* */
7 /* Copyright (c) 2018 - 2021 Egor Orachyov */
8 /* */
9 /* Permission is hereby granted, free of charge, to any person obtaining a copy */
10 /* of this software and associated documentation files (the "Software"), to deal */
11 /* in the Software without restriction, including without limitation the rights */
12 /* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
13 /* copies of the Software, and to permit persons to whom the Software is */
14 /* furnished to do so, subject to the following conditions: */
15 /* */
16 /* The above copyright notice and this permission notice shall be included in all */
17 /* copies or substantial portions of the Software. */
18 /* */
19 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
20 /* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
21 /* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
22 /* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
23 /* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
24 /* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
25 /* SOFTWARE. */
26 /**********************************************************************************/
27 
28 #ifndef BERSERK_RESMESH_HPP
29 #define BERSERK_RESMESH_HPP
30 
31 #include <resource/ResMaterial.hpp>
32 #include <resource/ResTexture.hpp>
33 #include <resource/Resource.hpp>
35 
36 #include <render/mesh/Mesh.hpp>
38 
40 
51 public:
53  BRK_API ~ResMeshImportOptions() override = default;
54 
57  bool flipUVs = true;
58  bool triangulate = true;
59  bool indexed = true;
60 };
61 
66 class ResMesh final : public Resource {
67 public:
69  struct SubMesh {
77  };
78 
79  BRK_API ResMesh() = default;
80  BRK_API ~ResMesh() override = default;
81 
82  BRK_API const StringName &GetResourceType() const override;
84 
85  BRK_API void CreateFromArrays(MeshFormat format, uint32 verticesCount, const MeshArrays &arrays);
86  BRK_API void CreateFromData(MeshFormat format, uint32 verticesCount, const Ref<Data> &vertexData, const Ref<Data> &attributeData, const Ref<Data> &skinningData);
87  BRK_API void AddSubMesh(const StringName &name, RHIPrimitivesType primitivesType, const Aabbf &aabb, uint32 baseVertex, RHIIndexType indexType, uint32 indicesCount, const Ref<Data> &indexData);
88  BRK_API void SetAabb(const Aabbf &aabb);
89 
90  BRK_API const Ref<Mesh> &GetMesh() const { return mMesh; }
91  BRK_API const std::vector<SubMesh> &GetSubMeshes() const { return mSubMeshes; }
92 
93 private:
94  Ref<Mesh> mMesh;
95  std::vector<SubMesh> mSubMeshes;
96 };
97 
103 
104 #endif//BERSERK_RESMESH_HPP
#define BRK_NS_END
Definition: Config.hpp:48
#define BRK_API
Definition: Config.hpp:32
std::uint32_t uint32
Definition: Typedefs.hpp:44
Mask defining mesh format (composed from attributes)
Texture import options.
Definition: ResMesh.hpp:50
BRK_API ~ResMeshImportOptions() override=default
BRK_API ResMeshImportOptions()=default
bool indexed
Definition: ResMesh.hpp:59
bool flipUVs
Definition: ResMesh.hpp:57
MeshFormat meshFormat
Definition: ResMesh.hpp:55
bool triangulate
Definition: ResMesh.hpp:58
3d mesh geometry for rendering
Definition: ResMesh.hpp:66
BRK_API void AddSubMesh(const StringName &name, RHIPrimitivesType primitivesType, const Aabbf &aabb, uint32 baseVertex, RHIIndexType indexType, uint32 indicesCount, const Ref< Data > &indexData)
Definition: ResMesh.cpp:56
BRK_API ResMesh()=default
BRK_API void SetAabb(const Aabbf &aabb)
Definition: ResMesh.cpp:73
BRK_API void CreateFromArrays(MeshFormat format, uint32 verticesCount, const MeshArrays &arrays)
Definition: ResMesh.cpp:42
BRK_API const StringName & GetResourceType() const override
Definition: ResMesh.cpp:33
BRK_API ~ResMesh() override=default
BRK_API const Ref< Mesh > & GetMesh() const
Definition: ResMesh.hpp:90
BRK_API void CreateFromData(MeshFormat format, uint32 verticesCount, const Ref< Data > &vertexData, const Ref< Data > &attributeData, const Ref< Data > &skinningData)
Definition: ResMesh.cpp:49
static BRK_API const StringName & GetResourceTypeStatic()
Definition: ResMesh.cpp:37
BRK_API const std::vector< SubMesh > & GetSubMeshes() const
Definition: ResMesh.hpp:91
Base class for import options to import specific resource.
Definition: ResourceImporter.hpp:48
Base class for any engine resource object.
Definition: Resource.hpp:48
Cached shared utf-8 string id.
Definition: StringName.hpp:61
RHIIndexType
Definition: RHIDefs.hpp:57
RHIPrimitivesType
Definition: RHIDefs.hpp:220
Definition: GLDevice.cpp:46
Struct describing mesh data per attribute.
Definition: Mesh.hpp:105
Single sub-mesh info.
Definition: ResMesh.hpp:69
RHIPrimitivesType primitivesType
Definition: ResMesh.hpp:74
uint32 baseVertex
Definition: ResMesh.hpp:70
uint32 verticesCount
Definition: ResMesh.hpp:71
RHIIndexType indexType
Definition: ResMesh.hpp:73
Aabbf aabb
Definition: ResMesh.hpp:76
uint32 indicesCount
Definition: ResMesh.hpp:72
Ref< ResMaterial > material
Definition: ResMesh.hpp:75