0
load models
This discussion was imported from CodePlex
it_test wrote at 2013-02-05 09:06:
hello,
Can anyone provide a working code for loading one\group of models from .obj .mtl and some .jpg files and rendering them on screen? I was trying to load models, but I cannot load or apply textures, and it gets messy.
I looked at example folder, but it only loads model with no texture.
I'm probably not applying them correctly, but there might be other errors.
I think there is a problem with materials; first I load the model
also number of times I got
Can anyone provide a working code for loading one\group of models from .obj .mtl and some .jpg files and rendering them on screen? I was trying to load models, but I cannot load or apply textures, and it gets messy.
I looked at example folder, but it only loads model with no texture.
I'm probably not applying them correctly, but there might be other errors.
I think there is a problem with materials; first I load the model
model = ModelImporter.Load("filename.obj");
material = (MaterialGroup)((GeometryModel3D)model.Children[0]).Material;
then return that material: this.theMaterial = (MaterialGroup)faceNeutral.getMaterial();
where <GeometryModel3D.Material>
<MaterialGroup x:Name="theMaterial">
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
<LinearGradientBrush.GradientStops>
<GradientStop Color="LightBlue" Offset="0" />
<GradientStop Color="LightBlue" Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</MaterialGroup>
</GeometryModel3D.Material>
but object still renders as LightBlue.also number of times I got
//Unable to cast object of type 'System.Windows.Media.Media3D.MaterialGroup' to type 'System.Windows.Media.Media3D.DiffuseMaterial'.
thanksobjo wrote at 2013-02-10 16:43:
The casting error is in your code, right? If you want to replace the MaterialGroup with the material from faceNeutral, I think you should change the Material property of the GeometryModel3D instead. If you need to keep the MaterialGroup, try Children.Clear()
and Children.Add(faceNeutral.GetMaterial());
Customer support service by UserEcho