Hi everyone,
after resolving my duplication problem, thanks to Sylvain, I encounter another problem with actor duplication and setTexture.
Here is the code that realise actor initialisation and texture initialisation.
TVActor newactor;
if (!_TVactor_namelist.ContainsKey(filename))
{
//this kind of mesh is not loaded, we load it
newactor = Core.graphic.scene.CreateActor(filename);
if (filename.EndsWith(".tva") || filename.EndsWith(".TVA"))
{
if (texture.Equals(""))
{
newactor.LoadTVA(Core.basepath + filename, true, true);
}
else
{
newactor.LoadTVA(Core.basepath + filename, false, true);
newactor.SetTexture(GraphicManager.textureman.get(texture));
}
}
else if (filename.EndsWith(".x") || filename.EndsWith(".X"))
{
if (texture.Equals(""))
{
newactor.LoadXFile(Core.basepath + filename, true, true);
}
else
{
newactor.LoadXFile(Core.basepath + filename, false, true);
newactor.SetTexture(GraphicManager.textureman.get(texture));
}
}
_TVactor_namelist.Add(filename, 1);
}
else
{
//this kind of mesh is already loaded, we duplicate it
TVActor original = Core.Global.GetActor(filename);
newactor = original.Duplicate();
if (!texture.Equals(""))
{
newactor.SetTexture(GraphicManager.textureman.get(texture));
}
_TVactor_namelist[filename] = _TVactor_namelist[filename] + 1;
}
My actors always have only 1 texture on them.
The problem is:
when I load the one I change the texture, the first actor loaded appears black after I loaded the second one that use the same mesh with a different texture.
You can check yourself in this screen:

One of my teammate think the problem should be a decrementation bug on the original texture I loaded at the first time.
The woman in black is the first one, the others are created by duplication of the mesh and texture loading. The problem is TV3D seems to have a bug when we duplicate mesh, it doesn't increase the texture ref count. However, when we do a setTexture, it thinks about updating ref counts (decrease of the old texture ref count, increase of the new one).
So, at each duplication+texture loading combo on the new mesh, the ref count of the original texture is deacreased and after reaching 0 is deleted by the textureManager at the next update.