Skylicht Engine
Loading...
Searching...
No Matches
CMesh.h
1/*
2!@
3MIT License
4
5Copyright (c) 2019 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "Entity/IEntityData.h"
28#include "Material/Shader/Instancing/IShaderInstancing.h"
29
30namespace Skylicht
31{
32 class CMaterial;
33
51 class SKYLICHT_API CBlendShape : public IReferenceCounted
52 {
53 public:
54 std::string Name;
55
56 float Weight;
57
58 // see function CSoftwareSkinningUtils::softwareBlendShape, CFBXMeshLoader::loadModel
59 core::array<u32> VtxId;
62
63 CBlendShape()
64 {
65 Weight = 1.0f;
66 }
67
68 ~CBlendShape()
69 {
70
71 }
72 };
73
74 class SKYLICHT_API CMesh : public IMesh
75 {
76 public:
77 CMesh();
78
79 virtual ~CMesh();
80
81 virtual CMesh* clone();
82
83 virtual u32 getMeshBufferCount() const;
84
85 virtual IMeshBuffer* getMeshBuffer(u32 nr) const;
86
87 virtual IMeshBuffer* getMeshBuffer(const video::SMaterial& material) const;
88
89 virtual const core::aabbox3d<f32>& getBoundingBox() const;
90
91 core::aabbox3d<f32>* getBoundingBoxPtr();
92
93 virtual void setBoundingBox(const core::aabbox3df& box);
94
95 virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue);
96
97 virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX);
98
99 virtual void setDirty(E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX);
100
101 public:
102 void recalculateBoundingBox();
103
104 void addMeshBuffer(IMeshBuffer* buf, const char* materialName = "", CMaterial* m = NULL);
105
106 void addBlendShape(CBlendShape* blendShape);
107
108 void removeAllMeshBuffer();
109
110 void removeMeshBuffer(IMeshBuffer* buf);
111
112 void removeHWBuffer();
113
114 void replaceMeshBuffer(int i, IMeshBuffer* buf);
115
116 video::E_VERTEX_TYPE getVertexType();
117
118 IMeshBuffer* getBufferByMaterialID(int materialID);
119
120 CMesh* detachAlphaMeshBuffer();
121
122 int getMeshBufferID(IMeshBuffer* buffer);
123
124 static void applyDoubleSided(IMeshBuffer* buffer);
125
126 core::array<IMeshBuffer*> MeshBuffers;
127
128 core::aabbox3d<f32> BoundingBox;
129
130 std::vector<std::string> MaterialName;
131
132 std::vector<CMaterial*> Materials;
133
134 core::array<CBlendShape*> BlendShape;
135
136 bool UseInstancing;
137
138 CMesh* IndirectLightingMesh;
139 };
140}
Represents a morph target (blend shape) for a mesh.
Definition CMesh.h:52
The object class describes material information such as which shader it's associated with,...
Definition CMaterial.h:84
IReferenceCounted()
Constructor.
Definition IReferenceCounted.h:50
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.h:22
Self reallocating template array (like stl vector) with additional features.
Definition irrArray.h:23
Struct for holding parameters for a material renderer.
Definition SMaterial.h:255
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition aabbox3d.h:351
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.h:19
E_MATERIAL_FLAG
Material flags.
Definition EMaterialFlags.h:15
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58