I have displayed the 3D object by referring the following Link Display 3D Model using Window Presentation Foundation .Everything is working fine except the object is displaying in plain blue.can any one help me out to display it in the original color?. This link is referred but still no go.Any help is appreciated.
My code is like
namespace Display3DModel
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
//Path to the model file
private const string MODEL_PATH = "Model/Model2.obj";
public MainWindow()
{
InitializeComponent();
ModelVisual3D device3D = new ModelVisual3D();
device3D.Content = Display3d(MODEL_PATH);
// Add to view port
viewPort3d.Children.Add(device3D);
}
/// <summary>
/// Display 3D Model
/// </summary>
/// <param name="model">Path to the Model file</param>
/// <returns>3D Model Content</returns>
private Model3D Display3d(string model)
{
Model3D device = null;
try
{
//Adding a gesture here
viewPort3d.RotateGesture = new MouseGesture(MouseAction.LeftClick);
//Import 3D model file
ModelImporter import = new ModelImporter();
//Load the 3D model file
device = import.Load(model);
}
catch (Exception e)
{
// Handle exception in case can not file 3D model
MessageBox.Show("Exception Error : " + e.StackTrace);
}
return device;
}
}
}
And in XAML
<Window x:Class="Display3DModel.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:helix="http://helix-toolkit.org/wpf"
Title="MainWindow" Height="350" Width="525">
<Grid>
<helix:HelixViewport3D x:Name="viewPort3d" ZoomExtentsWhenLoaded="true" Grid.RowSpan="2" >
<!-- Remember to add light to the scene -->
<helix:DefaultLights/>
</helix:HelixViewport3D>
</Grid>
</Window>