To load an .obj file I use the HelixToolkit.Wpf.SharpDX.Assimp.Importer. This loads the 3d model and applies the default material as defined in the mtl.
var loader = new Importer();
return loader.Load(path); // returns HelixToolkitScene
This works as expected.
I can change the material of the model by using
public static void ApplyMaterial(HelixToolkitScene scene, Material material)
{
if (material != null)
{
if (scene != null)
{
if (scene.Root != null)
{
foreach (var node in scene.Root.Traverse())
{
if (node is MaterialGeometryNode m)
{
m.Material = material;
}
}
}
}
}
}
At some point, I want to remove any materials and display the model in its initial state (after loading, with the default materials defined in the .mtl file).
How can I reload the original .mtl file? Do I have to reload the entire model (import from the .obj) again?
Normally you have to set the property for the imported asset in the used View-Model of helix and it should re-create the model data.
If you want to avoid this you can just access the specific material-property directly. For instance:
Material mat = ((GeometryModel3D)asset.Children[0]).Material;