1

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>
Sribin
  • 307
  • 4
  • 16
  • All depends on your code, the model and the material. The question does not contain any of these. Please add them or close the question. – Emond Dec 29 '18 at 10:15
  • @ErnodeWeerd Hi I have added the code.The Model is opening properly in the 3D viewer in Windows 10. – Sribin Dec 29 '18 at 10:40
  • Please check the obj file and see if it refers to a mtl file and if the mtl file is available for the program: https://stackoverflow.com/questions/32324748/how-to-load-textures-and-materials-using-helix-toolkit – Emond Dec 29 '18 at 12:02

0 Answers0