0
Apply Lights to HelixViewport3D ?
This discussion was imported from CodePlex
wa_dev wrote at 2012-12-26 21:00:
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 ...
wa_dev wrote at 2012-12-27 00:39:
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; }
Customer support service by UserEcho