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);
312 if (!_unique && _material == this->material)
315 if (this->material && this->ownsMaterial)
318 this->ownsMaterial = _unique;
319 this->material = _material;
326 unsigned int count = this->SubMeshCount();
328 for (
unsigned int i = 0; i < count; ++i)
331 subMesh->PreRender();
343 gzerr <<
"Cloning a mesh failed because the mesh to be "
344 <<
"cloned does not belong to a scene.\n";
347 else if (this->meshDescriptor.meshName.empty())
349 gzerr <<
"Cloning a geometry failed because the name of the mesh is "
360 result->SetMaterial(this->
Material());
366 for (
unsigned int i = 0; i < this->SubMeshCount(); ++i)
368 auto existingSubMeshMaterial = this->SubMeshByIndex(i)->Material();
369 if (existingSubMeshMaterial)
370 result->SubMeshByIndex(i)->SetMaterial(existingSubMeshMaterial);
382 return this->meshDescriptor;
389 this->meshDescriptor = _desc;
397 this->SubMeshes()->DestroyAll();
398 if (this->material && this->ownsMaterial)
400 this->material.reset();
423 if (this->material && this->ownsMaterial)
425 this->material.reset();
434 if (mat) this->SetMaterial(mat, _unique);
441 _material = (_unique) ? _material->Clone() : _material;
444 bool origUnique = this->ownsMaterial;
446 this->SetMaterialImpl(_material);
452 if (!_unique && _material == origMaterial)
455 if (origMaterial && origUnique)
458 this->material = _material;
459 this->ownsMaterial = _unique;
466 return this->material;