0

Change materials at runtime

Anonymous 10 years ago 0
This discussion was imported from CodePlex

Tottel wrote at 2013-11-14 18:04:

Hi,

I've been using the Helix toolkit for a day now, and I just can't get my head wrapped around it.
I have my own WPF interface, and I can load and display a model into my scene. However, I just can't figure out how to change the materials on the model after loading the model from file.

Does anyone know?

Thanks!

Tottel wrote at 2013-11-19 20:18:

No one has any suggestions on how to do this?

objo wrote at 2013-11-19 22:22:

Did you try changing the Material property?
http://msdn.microsoft.com/en-us/library/system.windows.media.media3d.geometrymodel3d.material(v=vs.110).aspx

Also, make sure the model is not frozen.

Tottel wrote at 2013-11-20 00:11:

I didn't realize you could do that in XAML :D

I'll give that a try, thanks!

objo wrote at 2013-11-20 08:12:

I think you need to change the material programatically if you load a model into the scene at runtime!

Tottel wrote at 2013-11-23 14:31:

objo wrote:
I think you need to change the material programatically if you load a model into the scene at runtime!
And how exactly would I access that material? I use a Model3D after loading in the mesh, but I really don't see where I can change the material anywhere.. :/

a5r wrote at 2013-11-24 10:48:

you can try setting the Material property of a GeometryModel3D to an instance of Material , for instance DiffuseMaterial

Tottel wrote at 2013-11-28 10:34:

Working great now; thanks a lot! :)