Closed TaaTT4 closed 3 years ago
this is incomplete, as the material is only uniquely identified by name and group.
Why dont you use mesh->getSubMesh(xx)->setMaterialName(...)
instead, to set the material after creation?
this is incomplete, as the material is only uniquely identified by name and group.
You're right. The habit of using a single resource group led me to forget it. I can integrate the PR if you're open to accept it.
Why dont you use
mesh->getSubMesh(xx)->setMaterialName(...)
instead, to set the material after creation?
I could, but setting the material at the mesh creation phase seems a nice convenience addition to me.
sorry, forgot about this.
instead of introducing the resource group, I would rather pass a MaterialPtr
to keep things simple.
However, this requires a update of ManualObject in ogre-next, adding MaterialPtr
overloads like in ogre1.
But MaterialPtr
in ogre-next represent an old style material whose use is mainly for compositor quad passes and/or Entity
. 99% of the times you use HlmsDatablock
for ManualObject
and or Item
.
The need to changing also OGRE source code to support this little convenience PR seems a bit overkill to me. So it's probably better to leave the world as it is. I'll keep using mesh->getSubMesh(...)->setMaterialName(...)
to change mesh material as I'm doing right now.
so you say
setMaterialName(String name)
, andsetMaterial(MaterialPtr mat)
have different results in ogre-next even if mat->getName() == name
?
Nope, I'm saying that in ogre-next 99% ot the times you call setDatablock
or setDatablockOrMaterialName
. MaterialPtr
is a material as we know it from OGRE 1.x. HlmsDatablock
is an HLMS material (PBS or Unlit). And 99% of the times you use this latter kind of materials on ogre-next.
but this particular PR is about setting the Material and not the Datablock!?
this implies
have different results in ogre-next even if mat->getName() == name
as if a Datablock with the same name exists, you get that instead of a material.
Of course results can differ depending on which Datablocks are available when you create an Mesh instance.
In Ogre1 I therefore got rid of all the name string caching and instead immediately resolve the resource.
Anyway.. implementing the feature of this PR would require different code-paths for ogre and ogre-next, thus diverging the branches. I do not think this is worth it. Therefore closing it.
As the title says, add support to choose meshes material during the invocation of
realizeMesh
andtransformToMesh
methods. Indeed, there's no way of doing it and the material name is hardcoded toBaseWhiteNoLighting
. The PR doesn't break the API since the material name is specified as a default parameter.With very little changes, the PR should be also applicable to master branch too.