302 unsigned int count = this->SubMeshCount();
303 _material = (_unique && count > 0) ? _material->Clone() : _material;
305 for (
unsigned int i = 0; i < count; ++i)
308 subMesh->SetMaterial(_material,
false);
311 if (this->material && this->ownsMaterial)
314 this->ownsMaterial = _unique;
315 this->material = _material;
339 gzerr <<
"Cloning a mesh failed because the mesh to be "
340 <<
"cloned does not belong to a scene.\n";
343 else if (this->meshDescriptor.meshName.empty())
345 gzerr <<
"Cloning a geometry failed because the name of the mesh is "
356 result->SetMaterial(this->
Material());
362 for (
unsigned int i = 0; i < this->SubMeshCount(); ++i)
364 auto existingSubMeshMaterial = this->SubMeshByIndex(i)->Material();
365 if (existingSubMeshMaterial)
366 result->SubMeshByIndex(i)->SetMaterial(existingSubMeshMaterial);