private void UpdateVisuals() { Children.Clear(); if (Light == null) { return; } var dl = Light as DirectionalLight; if (dl != null) { var arrow = new ArrowVisual3D(); double distance = 10; double length = 5; arrow.Point1 = new Point3D() + dl.Direction * distance; arrow.Point2 = arrow.Point1 - dl.Direction * length; arrow.Diameter = 0.1 * length; arrow.Fill = new SolidColorBrush(dl.Color); Children.Add(arrow); } var sl = Light as SpotLight; if (sl != null) { var sphere = new SphereVisual3D(); sphere.Center = sl.Position; sphere.Fill = new SolidColorBrush(sl.Color); Children.Add(sphere); var arrow = new ArrowVisual3D(); arrow.Point1 = sl.Position; arrow.Point2 = sl.Position + sl.Direction; arrow.Diameter = 0.1; Children.Add(arrow); } var pl = Light as PointLight; if (pl != null) { var sphere = new SphereVisual3D(); sphere.Center = pl.Position; sphere.Fill = new SolidColorBrush(pl.Color); Children.Add(sphere); } var al = Light as AmbientLight; }
private void UpdateVisuals() { Children.Clear(); if (Light == null) return; var dl = Light as DirectionalLight; if (dl != null) { var arrow = new ArrowVisual3D(); double distance = 10; double length = 5; arrow.Point1 = new Point3D() + dl.Direction*distance; arrow.Point2 = arrow.Point1 - dl.Direction*length; arrow.Diameter = 0.1*length; arrow.Fill = new SolidColorBrush(dl.Color); Children.Add(arrow); } var sl = Light as SpotLight; if (sl != null) { var sphere = new SphereVisual3D(); sphere.Center = sl.Position; sphere.Fill = new SolidColorBrush(sl.Color); Children.Add(sphere); var arrow = new ArrowVisual3D(); arrow.Point1 = sl.Position; arrow.Point2 = sl.Position + sl.Direction; arrow.Diameter = 0.1; Children.Add(arrow); } var pl = Light as PointLight; if (pl != null) { var sphere = new SphereVisual3D(); sphere.Center = pl.Position; sphere.Fill = new SolidColorBrush(pl.Color); Children.Add(sphere); } var al = Light as AmbientLight; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.From = ((System.Windows.Controls.ComboBox)(target)); #line 22 "..\..\..\MainWindow.xaml" this.From.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.FromPreviewKeyDown); #line default #line hidden #line 22 "..\..\..\MainWindow.xaml" this.From.KeyUp += new System.Windows.Input.KeyEventHandler(this.FromToChanged); #line default #line hidden return; case 2: this.To = ((System.Windows.Controls.ComboBox)(target)); #line 24 "..\..\..\MainWindow.xaml" this.To.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.ToPreviewKeyDown); #line default #line hidden #line 24 "..\..\..\MainWindow.xaml" this.To.KeyUp += new System.Windows.Input.KeyEventHandler(this.FromToChanged); #line default #line hidden return; case 3: this.list1 = ((System.Windows.Controls.ListView)(target)); #line 26 "..\..\..\MainWindow.xaml" this.list1.KeyDown += new System.Windows.Input.KeyEventHandler(this.ListViewKeyDown); #line default #line hidden return; case 4: this.view1 = ((HelixToolkit.HelixView3D)(target)); #line 40 "..\..\..\MainWindow.xaml" this.view1.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.OnMouseDown); #line default #line hidden #line 40 "..\..\..\MainWindow.xaml" this.view1.MouseMove += new System.Windows.Input.MouseEventHandler(this.OnMouseMove); #line default #line hidden return; case 5: this.earth = ((HelixToolkit.SphereVisual3D)(target)); return; case 6: this.text1 = ((System.Windows.Controls.TextBlock)(target)); return; case 7: this.text2 = ((System.Windows.Controls.TextBlock)(target)); return; } this._contentLoaded = true; }
private void UpdateVisuals() { Children.Clear(); if (WindTurbine == null) return; var baseTower = new TruncatedConeVisual3D { Fill = Brushes.Yellow, Origin = new Point3D(0, 0, -WindTurbine.BaseHeight) }; baseTower.Height = -baseTower.Origin.Z + 2; baseTower.BaseRadius = baseTower.TopRadius = WindTurbine.Diameter; var tower = new TruncatedConeVisual3D { Fill = Brushes.White, Origin = new Point3D(0, 0, 2), Height = WindTurbine.Height, BaseRadius = WindTurbine.Diameter }; tower.TopRadius = tower.BaseRadius * (1 - WindTurbine.Height * Math.Sin(WindTurbine.ShaftAngle / 180.0 * Math.PI)); var nacelle = new TruncatedConeVisual3D { Fill = Brushes.White, Origin = new Point3D(WindTurbine.Overhang, 0, tower.Origin.Z + tower.Height), Normal = new Vector3D(-1, 0, 0), TopRadius = WindTurbine.NacelleDiameter }; nacelle.BaseRadius = nacelle.TopRadius * 0.7; nacelle.Height = WindTurbine.NacelleLength; Children.Add(baseTower); Children.Add(tower); Children.Add(nacelle); var endcap = new SphereVisual3D { Center = new Point3D(WindTurbine.Overhang - WindTurbine.NacelleLength, 0, tower.Origin.Z + tower.Height), Radius = nacelle.TopRadius, Fill = Brushes.White }; Children.Add(endcap); var rotor = new ModelVisual3D(); for (int i = 0; i < WindTurbine.Blades; i++) { double angle = (double)i / WindTurbine.Blades * Math.PI * 2; // todo: the blade is simplified to a cone... it should be a real profile... var blade = new TruncatedConeVisual3D { Origin = nacelle.Origin, Normal = new Vector3D(0, Math.Cos(angle), Math.Sin(angle)), Height = WindTurbine.BladeLength, BaseRadius = WindTurbine.BladeRootChord, TopRadius = WindTurbine.BladeTipChord, Fill = Brushes.White }; rotor.Children.Add(blade); } var hub = new SphereVisual3D { Fill = Brushes.White, Center = nacelle.Origin, Radius = WindTurbine.HubDiameter / 2 }; rotor.Children.Add(hub); Children.Add(rotor); var rotation = new AxisAngleRotation3D(new Vector3D(1, 0, 0), 0); var rotorTransform = new RotateTransform3D(null, hub.Center) { Rotation = rotation }; rotor.Transform = rotorTransform; var b = new Binding("RotationAngle") { Source = this }; BindingOperations.SetBinding(rotation, AxisAngleRotation3D.AngleProperty, b); }
private VisualObjectData ParsePushTriggerObject(VisualObjectData obj) { var sphere = new SphereVisual3D(); double tempRadius = 0; if (!double.TryParse(obj.ObjectData.GetProperty("radius"), out tempRadius)) { tempRadius = 2.5 * 4; } tempRadius = tempRadius / 4; sphere.Radius = tempRadius; obj.Offset.Z += tempRadius / 2; sphere.Material = new DiffuseMaterial(new SolidColorBrush(Color.FromArgb(128,255,171,0))); obj.Model = sphere; return obj; }
// Ambient_Light private VisualObjectData ParseLightObject(VisualObjectData obj) { obj.Offset = new Vector3D(0, 0, 0); var sphere = new SphereVisual3D(); sphere.Radius = 2.5; var color = ColorFromArray(obj.ObjectData.Floats); // Black light, don't show so that we can see actual colors if (color.R == 0 && color.G == 0 && color.B == 0) return null; sphere.Material = new DiffuseMaterial(new SolidColorBrush(color)); obj.Model = sphere; return obj; }
public TexturedObject3D() { Sphere = new SphereVisual3D() { ThetaDiv = 60, PhiDiv = 30 }; Children.Add(Sphere); }