Hey Greg, it's been a while
I am trying to revive my old project now that I finally have more time. Hasn't been easy with six years of engine changes to go through. But I'm getting there.
What I am stuck with is mesh variations. The idea is that every player can pick his/her own color which will be applied to the player mesh. So making the materials in advance is not an option, and the old MaterialLock does not work anymore.
I understand that mesh variations are the way to go, but I cannot figure them out. I made an object to add variations to the mesh like this:
Code:
class charMaterials
{
private:
Memx<Material> list;
MeshPtr mesh;
public:
int addVariation(C Color & color)
{
if(mesh == null) mesh = ObjectPtr(UID(3325270568, 1322544433, 1615607710, 3014310042))->mesh();
Material & last = list.New();
last.reset();
last.reflect(0.05);
last.colorS(color);
last.technique = MTECH_OPAQUE;
last.validate();
mesh->variations(list.elms()+1);
REPA(mesh->parts)
{
mesh->parts[i].variations(list.elms()+1);
mesh->parts[i].variation(list.elms(), &last);
}
// this is the index for this variation
return list.elms();
}
}
charMaterials CharMaterials;
And this will be called when the player or peer is created:
Code:
void setColor(Vec4 &color)
{
color.w = 1.0;
T.color = color;
materialVariation = CharMaterials.addVariation(color);
}
Then, during drawprepare I set my variation and draw the mesh:
Code:
Virtual UInt drawPrepare()
{
UInt modes = super::drawPrepare();
SetVariation(materialVariation);
mesh->draw();
SetVariation();
return modes;
}
... but nothing happens. The player is drawn, but always with the original material. I did quit a bit of debugging. My addVariation code is executed, the index is returned and stored in materialVariation. But no avail. Am I doing this wrong?
Regards,
yvan