Reputation: 4670
I am writing a program in WPF. I am using HelixToolkit to load models from file (I need to load several models from files) like this:
var importer = new HelixToolkit.Wpf.ModelImporter();
Model3D triangle = importer.Load("hand.obj");
ModelVisual3D Model = new ModelVisual3D();
Model.Content = triangle;
MainViewPort.Children.Add(Model);
And I need the entire Model3D, which I am getting from HelixToolkit, to change color (for example, it should be either red or black). Also I need to do it in realtime.
I found this: http://csharphelper.com/blog/2014/10/apply-textures-to-triangles-using-wpf-and-c/, but in this case model is generated inside a program, and what I need to do is do the same to model from external file.
How can I do this?
Upvotes: 0
Views: 4420
Reputation: 4670
Finally figured out how to do it, thanks to @dominik! Here is my solution:
var importer = new HelixToolkit.Wpf.ModelImporter();
var point = importer.Load("hand.obj");
GeometryModel3D model = point.Children[0] as GeometryModel3D;
DiffuseMaterial material = new DiffuseMaterial(new SolidColorBrush(Colors.Black));
model.Material = material;
Upvotes: 5