17 #ifndef GZ_RENDERING_BASE_BASEMESH_HH_
18 #define GZ_RENDERING_BASE_BASEMESH_HH_
22 #include <unordered_map>
32 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
67 bool _enabled,
bool _loop =
true,
float _weight = 1.0)
override;
75 std::chrono::steady_clock::duration _time)
override;
95 bool _unique =
true)
override;
99 bool _unique =
true)
override;
119 protected:
bool ownsMaterial =
false;
143 bool _unique =
true)
override;
147 bool _unique =
true)
override;
160 protected:
bool ownsMaterial =
false;
216 gzerr <<
"SetSkeletonWeights not supported for render engine: "
237 std::chrono::steady_clock::duration)
245 return this->SubMeshes()->Size();
252 return this->SubMeshes()->Contains(_subMesh);
259 return this->SubMeshes()->ContainsName(_name);
266 return this->SubMeshes()->GetByName(_name);
273 return this->SubMeshes()->GetByIndex(_index);
280 unsigned int count = this->SubMeshCount();
281 return (count > 0) ? this->SubMeshByIndex(0)->Material() :
290 if (mat) this->SetMaterial(mat, _unique);
299 unsigned int count = this->SubMeshCount();
300 _material = (_unique && count > 0) ? _material->Clone() : _material;
302 for (
unsigned int i = 0; i < count; ++i)
305 subMesh->SetMaterial(_material,
false);
308 if (this->material && this->ownsMaterial)
311 this->ownsMaterial = _unique;
312 this->material = _material;
319 unsigned int count = this->SubMeshCount();
321 for (
unsigned int i = 0; i < count; ++i)
324 subMesh->PreRender();
336 gzerr <<
"Cloning a mesh failed because the mesh to be "
337 <<
"cloned does not belong to a scene.\n";
340 else if (this->meshDescriptor.meshName.empty())
342 gzerr <<
"Cloning a geometry failed because the name of the mesh is "
353 result->SetMaterial(this->
Material());
359 for (
unsigned int i = 0; i < this->SubMeshCount(); ++i)
361 auto existingSubMeshMaterial = this->SubMeshByIndex(i)->Material();
362 if (existingSubMeshMaterial)
363 result->SubMeshByIndex(i)->SetMaterial(existingSubMeshMaterial);
375 return this->meshDescriptor;
382 this->meshDescriptor = _desc;
390 this->SubMeshes()->DestroyAll();
391 if (this->material && this->ownsMaterial)
393 this->material.reset();
416 if (this->material && this->ownsMaterial)
418 this->material.reset();
427 if (mat) this->SetMaterial(mat, _unique);
434 _material = (_unique) ? _material->Clone() : _material;
437 bool origUnique = this->ownsMaterial;
439 this->SetMaterialImpl(_material);
441 if (origMaterial && origUnique)
444 this->material = _material;
445 this->ownsMaterial = _unique;
452 return this->material;