Convert OpenGL materials to WPF
#2
Good find Arthur!

You can use the following code to convert the samples from the web site you found to WPF:

Code:
//Brass
//float[] mat_ambient  = { 0.329412f, 0.223529f, 0.027451f, 1.0f };
//float[] mat_diffuse  = { 0.780392f, 0.568627f, 0.113725f, 1.0f };
//float[] mat_specular = { 0.992157f, 0.941176f, 0.807843f, 1.0f };
//float shine = 27.8974f;

var diffuseMaterial = new DiffuseMaterial(new SolidColorBrush(Color.FromScRgb(1, 0.329412f, 0.223529f, 0.027451f)));
diffuseMaterial.AmbientColor = Color.FromScRgb(1, 0.329412f, 0.223529f, 0.027451f);

var specularMaterial = new SpecularMaterial(new SolidColorBrush(Color.FromScRgb(1, 0.992157f, 0.941176f, 0.807843f)), 27.8974);

var materialGroup = new MaterialGroup();
materialGroup.Children.Add(diffuseMaterial);
materialGroup.Children.Add(specularMaterial);

After that you can assign materialGroup to a Material property.

You get better results when you also add some AmbientLight to the scene - for example the following xaml does that:

Code:
<ModelVisual3D>
   <ModelVisual3D.Content>
       <Model3DGroup>
           <AmbientLight Color="#333333"/>
       </Model3DGroup>
   </ModelVisual3D.Content>
</ModelVisual3D>
Andrej Benedik
  


Messages In This Thread
Convert OpenGL materials to WPF - by abutler77 - 07-02-2018, 09:02 AM
RE: Convert OpenGL materials to WPF - by abenedik - 07-02-2018, 04:35 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)