Apply Lights to HelixViewport3D ?

Dec 26, 2012 at 8:00 PM
Edited Dec 26, 2012 at 11:38 PM

I'm trying to apply lights to an STL file I'm loading into the viewport, but all I get is black object. I've tried a few different things, and no luck so far. I saw a similar thread here ... 
Dec 26, 2012 at 11:39 PM

Here is the code I got working (in my experimental code)... seems I'm am just a newb here

 

	private void Window_Loaded(object sender, RoutedEventArgs e)
        {

            this.SetHelixViewport();
            this.HelixViewport.Children.Add(new DefaultLights());
            this.HelixViewport.Children.Add(new ModelVisual3D() { Content = this.GetStlGeometryModel() });

        }


        private GeometryModel3D GetStlGeometryModel()
        {
            MeshBuilder builder = new MeshBuilder(true, true);
            this.GetStlReader().Meshes.ToList().ForEach(m => builder.Append(m));

            DiffuseMaterial dm = new DiffuseMaterial(Brushes.Red);

            GeometryModel3D gm3d = new GeometryModel3D();
            gm3d.Geometry = builder.ToMesh();
            gm3d.Material = dm;
            return gm3d;
        }

        private void SetHelixViewport()
        {

            this.HelixViewport.IsHeadLightEnabled = true;
            this.HelixViewport.CameraRotationMode = CameraRotationMode.Trackball;
            this.HelixViewport.ZoomExtentsWhenLoaded = true;
            this.HelixViewport.Children.Clear();
        
        }

        private StLReader GetStlReader()
        {

            StLReader reader = new StLReader();
            reader.Read(SAMPLE_STL_FILEPATH);

            return reader;
        }