The issue is whichever resource is listed first in Jack.txt is never found. If it’s the second line, it works fine.
Created the file in visual studio by adding a new file. Edited the contents also in visual studio. Probably something to do with encoding or line endings.
But there is a workaround, and this is then to set the material using whatever was on the first line of the .txt file. That setting overrides the first line of the .txt, which isn’t set due to some issue reading the file.
Tried adding a space and a blank line to that first line. If a blank first line, both of the resources are found, but the body will be default material. In fact, no matter what I did with the Jack.txt file, never could get the body to paint through using ApplyMaterialsList(). This very well could be due to something in the SharpReality binding, or a bug in the reading of the .txt file contents in Urho.dll.
Finally, also tried @Dave82 's suggestion for .SetMaterial, though in my exerience, the sharpreality binding tends to throw a lot of exceptions with .SetMaterial, so I don’t like to use it.
But, this works with no exceptions or errors noted in my case:
modelObject.SetMaterial(0, Application.ResourceCache.GetMaterial("Materials/JackBody.xml"));
modelObject.SetMaterial(1, Application.ResourceCache.GetMaterial("Materials/JackHead.xml"));
And if creating a lot of models, for instance for the skeletal animation model, there the errors add quite a bit of delay lessening the user experience.
Also, @Egorbo could have made a Materials field rather than a Material field. That’s a purely SharpReality issue though, unrelated.
namespace Urho
{
partial class StaticModel
{
public Material Material
{
get { return GetMaterial(0); }
set { SetMaterial(0, value); }
}
}
partial class AnimatedModel
{
public Model Model
{
get { return base.Model; }
set { this.SetModel(value, true); }
}
}
}