private void SetupScene() { RenderTechnique = new RenderTechnique("RenderCustom"); WhiteMaterial = new PhongMaterial { Name = "White", AmbientColor = PhongMaterials.ToColor(0.1, 0.1, 0.1, 1.0), DiffuseColor = defaultMaterialColor, SpecularColor = PhongMaterials.ToColor(0.0225, 0.0225, 0.0225, 1.0), EmissiveColor = PhongMaterials.ToColor(0.0, 0.0, 0.0, 1.0), SpecularShininess = 12.8f, }; SelectedMaterial = new PhongMaterial { Name = "White", AmbientColor = PhongMaterials.ToColor(0.1, 0.1, 0.1, 1.0), DiffuseColor = defaultSelectionColor, SpecularColor = PhongMaterials.ToColor(0.0225, 0.0225, 0.0225, 1.0), EmissiveColor = PhongMaterials.ToColor(0.0, 0.0, 0.0, 1.0), SpecularShininess = 12.8f, }; Model1Transform = new TranslateTransform3D(0, -0, 0); // camera setup Camera = new PerspectiveCamera(); SetCameraData(new CameraData()); DrawGrid(); }
public MainViewModel() { EffectsManager = new DefaultEffectsManager(); // titles Title = "Viewer"; SubTitle = "Marine Technology"; // camera setup Camera = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera { Position = new Point3D(0, -5, 5), LookDirection = new Vector3D(0, 10, 5),//z kamerą jest problem przy przybliżaniu prawdopodobnie przez ten LookDirection albo sposób poruszania kamerą UpDirection = new Vector3D(0, 0, 1), FarPlaneDistance = 5000000 }; // setup lighting AmbientLightColor = Colors.DimGray; DirectionalLightColor = Colors.White; // światełko musi być DirectionalLightDirection = Camera.LookDirection; MainView(); AddPointCloud(); UpXCommand = new RelayCommand(x => { UpDirection = new Vector3D(1, 0, 0); }); UpYCommand = new RelayCommand(x => { UpDirection = new Vector3D(0, 1, 0); }); UpZCommand = new RelayCommand(x => { UpDirection = new Vector3D(0, 0, 1); }); }
private void SetupScene() { var ptColor = (Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["PointColor"]; defaultPointColor = new Color4(ptColor.R / 255.0f, ptColor.G / 255.0f, ptColor.B / 255.0f, ptColor.A / 255.0f); var lineColor = (Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["EdgeColor"]; defaultLineColor = new Color4(lineColor.R / 255.0f, lineColor.G / 255.0f, lineColor.B / 255.0f, lineColor.A / 255.0f); directionalLightColor = new Color4(0.9f, 0.9f, 0.9f, 1.0f); directionalLightDirection = new Vector3(-0.5f, -1.0f, 0.0f); var matColor = (Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["MaterialColor"]; materialColor = new Color4(matColor.R / 255.0f, matColor.G / 255.0f, matColor.B / 255.0f, matColor.A / 255.0f); RenderTechnique = Techniques.RenderDynamo; WhiteMaterial = new PhongMaterial { Name = "White", AmbientColor = PhongMaterials.ToColor(0.1, 0.1, 0.1, 1.0), DiffuseColor = materialColor, SpecularColor = PhongMaterials.ToColor(0.0225, 0.0225, 0.0225, 1.0), EmissiveColor = PhongMaterials.ToColor(0.0, 0.0, 0.0, 1.0), SpecularShininess = 12.8f, }; var selColor = (Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["SelectionColor"]; selectionColor = new Color4(selColor.R / 255.0f, selColor.G / 255.0f, selColor.B / 255.0f, selColor.A / 255.0f); SelectedMaterial = new PhongMaterial { Name = "White", AmbientColor = PhongMaterials.ToColor(0.1, 0.1, 0.1, 1.0), DiffuseColor = selectionColor, SpecularColor = PhongMaterials.ToColor(0.0225, 0.0225, 0.0225, 1.0), EmissiveColor = PhongMaterials.ToColor(0.0, 0.0, 0.0, 1.0), SpecularShininess = 12.8f, }; Model1Transform = new TranslateTransform3D(0, -0, 0); // camera setup Camera = new PerspectiveCamera { UpDirection = new Vector3D(0, 1, 0), FarPlaneDistance = 10000000, }; ResetCamera(); DrawGrid(); }
//--------------------------------------------------------------------------------------------------------- /// <summary> /// Инициализация данных камеры /// </summary> //--------------------------------------------------------------------------------------------------------- protected void InitCamera() { mDefaultOrthographicCamera = new Helix.OrthographicCamera { Position = new Point3D(0, 0, 5), LookDirection = new Vector3D(-0, -0, -5), UpDirection = new Vector3D(0, 1, 0), NearPlaneDistance = 0.05, FarPlaneDistance = 5000 }; mDefaultPerspectiveCamera = new Helix.PerspectiveCamera { Position = new Point3D(0, 0, 5), LookDirection = new Vector3D(-0, -0, -5), UpDirection = new Vector3D(0, 1, 0), NearPlaneDistance = 0.05, FarPlaneDistance = 5000 }; // camera models CameraModelCollection = new List <String>() { OrthographicCameraName, PerspectiveCameraName, }; // on camera changed callback CameraModelChanged += (sender, args) => { if (mCameraModel == OrthographicCameraName) { if (!(Camera is Helix.OrthographicCamera)) { Camera = mDefaultOrthographicCamera; } } else if (mCameraModel == PerspectiveCameraName) { if (!(Camera is Helix.PerspectiveCamera)) { Camera = mDefaultPerspectiveCamera; } } else { //throw new Helix3D.("Camera Model Error."); } }; // default camera model CameraModel = PerspectiveCameraName; Camera = mDefaultPerspectiveCamera; }
public FullModelViewport3DViewModel(FullModelViewModel fmvm) { _modelViewModel = fmvm; Title = ""; SubTitle = ""; EffectsManager = new CustomEffectsManager(); Camera = new PerspectiveCamera(); BackgroundColor = Properties.Settings.Default.BG_Color; }
public static CameraData ToCameraData(this PerspectiveCamera camera, string name) { var camData = new CameraData { Name = name, LookDirection = camera.LookDirection, EyePosition = camera.Position, UpDirection = camera.UpDirection, NearPlaneDistance = camera.NearPlaneDistance, FarPlaneDistance = camera.FarPlaneDistance }; return(camData); }
public Plot3dViewModel(IMachineSimulator machineSimulator, ILoggerFacade logger) { OpenByDropCommand = new DelegateCommand <DragEventArgs>(OpenByDropCommandExecute); _machineSimulator = machineSimulator; _logger = logger; PlotCamera = new PerspectiveCamera(); _machineSimulator.FrameChanged += MachineFrameChanged; _machineSimulator.NewFileOpened += ClearPlotModel; _machineSimulator.ProgramOpened += OnProgramOpened; }
public void ZoomExtents(Viewport3DX viewport, Rect3D bounds) { var diagonal = new Vector3D(bounds.SizeX, bounds.SizeY, bounds.SizeZ); var center = bounds.Location + (diagonal * 0.5); double radius = diagonal.Length * 0.5; HelixToolkit.Wpf.SharpDX.PerspectiveCamera Camera = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera() { Position = new Point3D(center.X + 30, center.Y + 30, center.Z + 50), LookDirection = new Vector3D(-30, -30, -50), UpDirection = new Vector3D(0, 0, 1), FarPlaneDistance = 5000000, FieldOfView = 45, NearPlaneDistance = 0.1, }; viewport.Camera.Reset(); viewport.Camera = Camera; }
public MainWindow() { DataContext = this; EnvironmentMap = TextureHelper.LoadFileToMemory(@"Resources\skymap.dds"); LightColor = new Color { R = 255, G = 255, B = 255, A = 155 }; EffectsManager = new DefaultEffectsManager(); Camera = new PerspectiveCamera(); InitializeComponent(); Loaded += (sender, args) => InitCamera(); Viewport3DX.SizeChanged += OnSizeChanged; DataContext = this; }
public MainViewModel() { EffectsManager = new DefaultEffectsManager(); // titles Title = "Viewer"; SubTitle = "Marine Technology"; // camera setup Camera = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera { Position = new Point3D(0, 0, 0), LookDirection = new Vector3D(0, 0, 0), UpDirection = new Vector3D(2, 1, 0), FarPlaneDistance = 0 }; // setup lighting AmbientLightColor = Colors.DimGray; DirectionalLightColor = Colors.White; // light necessary DirectionalLightDirection = Camera.LookDirection; }
private void SetupScene() { var ptColor = (Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["PointColor"]; defaultPointColor = new Color4(ptColor.R/255.0f, ptColor.G/255.0f, ptColor.B/255.0f, ptColor.A/255.0f); var lineColor = (Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["EdgeColor"]; defaultLineColor = new Color4(lineColor.R/255.0f, lineColor.G/255.0f, lineColor.B/255.0f, lineColor.A/255.0f); directionalLightColor = new Color4(0.9f, 0.9f, 0.9f, 1.0f); directionalLightDirection = new Vector3(-0.5f, -1.0f, 0.0f); var matColor = (Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["MaterialColor"]; materialColor = new Color4(matColor.R/255.0f, matColor.G/255.0f, matColor.B/255.0f, matColor.A/255.0f); RenderTechnique = Techniques.RenderDynamo; WhiteMaterial = new PhongMaterial { Name = "White", AmbientColor = PhongMaterials.ToColor(0.1, 0.1, 0.1, 1.0), DiffuseColor = materialColor, SpecularColor = PhongMaterials.ToColor(0.0225, 0.0225, 0.0225, 1.0), EmissiveColor = PhongMaterials.ToColor(0.0, 0.0, 0.0, 1.0), SpecularShininess = 12.8f, }; var selColor = (Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["SelectionColor"]; selectionColor = new Color4(selColor.R/255.0f, selColor.G/255.0f, selColor.B/255.0f, selColor.A/255.0f); SelectedMaterial = new PhongMaterial { Name = "White", AmbientColor = PhongMaterials.ToColor(0.1, 0.1, 0.1, 1.0), DiffuseColor = selectionColor, SpecularColor = PhongMaterials.ToColor(0.0225, 0.0225, 0.0225, 1.0), EmissiveColor = PhongMaterials.ToColor(0.0, 0.0, 0.0, 1.0), SpecularShininess = 12.8f, }; Model1Transform = new TranslateTransform3D(0, -0, 0); // camera setup Camera = new PerspectiveCamera { UpDirection = new Vector3D(0, 1, 0), FarPlaneDistance = 10000000, }; ResetCamera(); DrawGrid(); }
public MainViewModel() { // titles Title = "Watch3DxNode"; // SubTitle = "SharpDX"; // camera setup Camera = new PerspectiveCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0), FarPlaneDistance = 5000000 }; // default render technique RenderTechniquesManager = new DefaultRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn]; EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); // Init RedMaterial = PhongMaterials.Red; // Choose the device -> BestAdapter is chosen here. // var text = EffectsManager.Device.DebugName; // setup lighting AmbientLightColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f); DirectionalLightColor = Color.White; DirectionalLightDirection = new Vector3(-2, -5, -2); var b1 = new MeshBuilder(); b1.AddSphere(new Vector3(0, 0, 0), 0.5); // floor plane grid // Grid = LineBuilder.GenerateGrid(); b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2, BoxFaces.All); // GridColor = Color.Black; // GridTransform = new Media3D.TranslateTransform3D(-5, -1, -5); var meshGeometry = b1.ToMeshGeometry3D(); // meshGeometry.Colors = new Color4Collection(meshGeometry.TextureCoordinates.Select(x => x.ToColor4())); // scene model3d Model = meshGeometry; // var b1 = new MeshBuilder(); // // b1.AddSphere(new Vector3(0, 0, 0), 0.5); // // b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2, BoxFaces.All); // // var meshGeometry = b1.ToMeshGeometry3D(); // meshGeometry.Colors = new Color4Collection(meshGeometry.TextureCoordinates.Select(x => x.ToColor4())); // Model = meshGeometry; // // lines model3d // var e1 = new LineBuilder(); // e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2); // Lines = e1.ToLineGeometry3D(); // // // model trafos // Model1Transform = new Media3D.TranslateTransform3D(0, 0, 0); // Model2Transform = new Media3D.TranslateTransform3D(-2, 0, 0); // Model3Transform = new Media3D.TranslateTransform3D(+2, 0, 0); // // // model materials // GreenMaterial = PhongMaterials.Green; // BlueMaterial = PhongMaterials.Blue; // // // var mat = new PhongMaterial(); // // mat.AmbientColor = new Color4(new Color3()); // // //var diffColor = this.RedMaterial.DiffuseColor; // //diffColor.Alpha = 0.5f; // //this.RedMaterial.DiffuseColor = diffColor; // // Points = new PointGeometry3D(); // var ptPos = new Vector3Collection(); // var ptIdx = new IntCollection(); // // for (int x = 0; x < 100; x++) // { // for (int y = 0; y < 100; y++) // { // for (int z = 0; z < 100; z++) // { // ptIdx.Add(ptPos.Count); // ptPos.Add(new Vector3(x, y, z)); // } // } // } // // Points.Positions = ptPos; // Points.Indices = ptIdx; // // Text = new BillboardText3D(); // // for (var i = 0; i < 50; i++) // { // for (var j = 0; j < 50; j++) // { // Text.TextInfo.Add(new TextInfo("Hello World", new Vector3(i,j,0))); // } // } }
public static void AddPointCloud(Dictionary <KeyValuePair <int, int>, double> PointCollection, out PointModel Points, out GridModel Grid, out AxisModel Axis, out HelixToolkit.Wpf.SharpDX.Camera Camera, bool cameraType = false) { Camera = null; Points = null; Grid = null; Axis = null; var points = new PointGeometry3D(); var col = new Color4Collection(); // color gradient var ptPos = new Vector3Collection(); // point positions var ptIdx = new IntCollection(); // point indexes if (PointCollection != null && PointCollection.Count() > 1) { //newdataFromTxt(path, positionX, positionY, positionZ); var maxX = PointCollection.Max(x => x.Key.Key); // X var minX = PointCollection.Min(x => x.Key.Key); // X var maxY = PointCollection.Max(x => x.Key.Value); // Y var minY = PointCollection.Min(x => x.Key.Value); // Y var maxZ = PointCollection.Max(x => x.Value); // Z var minZ = PointCollection.Min(x => x.Value); // Z var minYObj = PointCollection.First(x => x.Key.Value == minY); Trace.WriteLine($"{maxX} {minX} {maxY} {minY} {maxZ} {minZ}"); if (PointCollection.Count() <= 0) { return; } foreach (var point in PointCollection) { var positionToColour = point.Value; ptIdx.Add(ptPos.Count); ptPos.Add(new Vector3((float)point.Key.Key, ((float)point.Key.Value), (float)point.Value)); col.Add(new Color4(RedBlueScale((float)minZ, (float)maxZ, (float)positionToColour))); } Points = new PointModel { // indexes and color gradient PointsGeometry = new PointGeometry3D { Positions = ptPos, Indices = ptIdx, Colors = col }, PointsColor = Colors.White, PointsTransform = new TranslateTransform3D(-minX, -minY, -minZ) }; // floor plane grid LineBuilder gridLines = new LineBuilder(); VisualizationTools.CreateGrid(gridLines, maxX, minX, maxY, minY, minZ); Grid = new GridModel { GridGeometry = gridLines.ToLineGeometry3D(), GridColor = new Color4(153 / 255.0f, 204 / 255.0f, 255 / 255.0f, 0.3f).ToColor(), GridTransform = new TranslateTransform3D(0, 0, 0) }; // lines LineBuilder arrows = new LineBuilder(); VisualizationTools.CreateAxes(arrows, (float)maxX, (float)minX, (float)maxY, (float)minY, (float)maxZ, (float)minZ); Axis = new AxisModel { AxisGeometry = arrows.ToLineGeometry3D(), AxisColor = new Color4(0, 255 / 255.0f, 255 / 255.0f, 0.5f).ToColor(), AxisTransform = new TranslateTransform3D(0, 0, 0) }; if (cameraType == false) { Camera = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera { Position = new Point3D(0, 0, Math.Abs(minZ * 100)), LookDirection = new Vector3D(((float)maxX - (float)minX) / 2, ((float)maxY - (float)minY) / 2, -Math.Abs(minZ * 100)),//z kamerą jest problem przy przybliżaniu prawdopodobnie przez ten LookDirection albo sposób poruszania kamerą UpDirection = new Vector3D(0, 1, 0), FarPlaneDistance = 5000000 }; } else { Camera = new HelixToolkit.Wpf.SharpDX.OrthographicCamera { Position = new Point3D(0, 0, Math.Abs(minZ * 100)), LookDirection = new Vector3D(((float)maxX - (float)minX) / 2, ((float)maxY - (float)minY) / 2, -Math.Abs(minZ * 100)),//z kamerą jest problem przy przybliżaniu prawdopodobnie przez ten LookDirection albo sposób poruszania kamerą UpDirection = new Vector3D(0, 1, 0), FarPlaneDistance = 5000000 }; } } }
public MainViewModel() { // titles Title = "Watch3DxNode"; // SubTitle = "SharpDX"; // camera setup Camera = new PerspectiveCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0), FarPlaneDistance = 5000000 }; // default render technique RenderTechniquesManager = new DefaultRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn]; EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); // Init RedMaterial = PhongMaterials.Red; // Choose the device -> BestAdapter is chosen here. // var text = EffectsManager.Device.DebugName; // setup lighting AmbientLightColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f); DirectionalLightColor = Color.White; DirectionalLightDirection = new Vector3(-2, -5, -2); var b1 = new MeshBuilder(); b1.AddSphere(new Vector3(0, 0, 0), 0.5);// floor plane grid // Grid = LineBuilder.GenerateGrid(); b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2, BoxFaces.All);// GridColor = Color.Black; // GridTransform = new Media3D.TranslateTransform3D(-5, -1, -5); var meshGeometry = b1.ToMeshGeometry3D();// meshGeometry.Colors = new Color4Collection(meshGeometry.TextureCoordinates.Select(x => x.ToColor4()));// scene model3d Model = meshGeometry; // var b1 = new MeshBuilder(); // // b1.AddSphere(new Vector3(0, 0, 0), 0.5); // // b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2, BoxFaces.All); // // var meshGeometry = b1.ToMeshGeometry3D(); // meshGeometry.Colors = new Color4Collection(meshGeometry.TextureCoordinates.Select(x => x.ToColor4())); // Model = meshGeometry; // // lines model3d // var e1 = new LineBuilder(); // e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2); // Lines = e1.ToLineGeometry3D(); // // // model trafos // Model1Transform = new Media3D.TranslateTransform3D(0, 0, 0); // Model2Transform = new Media3D.TranslateTransform3D(-2, 0, 0); // Model3Transform = new Media3D.TranslateTransform3D(+2, 0, 0); // // // model materials // GreenMaterial = PhongMaterials.Green; // BlueMaterial = PhongMaterials.Blue; // // // var mat = new PhongMaterial(); // // mat.AmbientColor = new Color4(new Color3()); // // //var diffColor = this.RedMaterial.DiffuseColor; // //diffColor.Alpha = 0.5f; // //this.RedMaterial.DiffuseColor = diffColor; // // Points = new PointGeometry3D(); // var ptPos = new Vector3Collection(); // var ptIdx = new IntCollection(); // // for (int x = 0; x < 100; x++) // { // for (int y = 0; y < 100; y++) // { // for (int z = 0; z < 100; z++) // { // ptIdx.Add(ptPos.Count); // ptPos.Add(new Vector3(x, y, z)); // } // } // } // // Points.Positions = ptPos; // Points.Indices = ptIdx; // // Text = new BillboardText3D(); // // for (var i = 0; i < 50; i++) // { // for (var j = 0; j < 50; j++) // { // Text.TextInfo.Add(new TextInfo("Hello World", new Vector3(i,j,0))); // } // } }
private void SetupScene() { var ptColor = (System.Windows.Media.Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["PointColor"]; defaultPointColor = new Color4(ptColor.R / 255.0f, ptColor.G / 255.0f, ptColor.B / 255.0f, ptColor.A / 255.0f); var lineColor = (System.Windows.Media.Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["EdgeColor"]; defaultLineColor = new Color4(lineColor.R / 255.0f, lineColor.G / 255.0f, lineColor.B / 255.0f, lineColor.A / 255.0f); ShadowMapResolution = new Vector2(2048, 2048); ShowShadows = false; // setup lighting AmbientLightColor = new Color4(0.0f, 0.0f, 0.0f, 1.0f); DirectionalLightColor = new Color4(0.9f, 0.9f, 0.9f, 1.0f); DirectionalLightDirection = new Vector3(-0.5f, -1.0f, 0.0f); FillLightColor = new Color4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f)); FillLightDirection = new Vector3(0.5f, 1.0f, 0f); var matColor = (System.Windows.Media.Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["MaterialColor"]; materialColor = new Color4(matColor.R / 255.0f, matColor.G / 255.0f, matColor.B / 255.0f, matColor.A / 255.0f); RenderTechnique = Techniques.RenderPhong; WhiteMaterial = new PhongMaterial { Name = "White", AmbientColor = PhongMaterials.ToColor(0.1, 0.1, 0.1, 1.0), DiffuseColor = materialColor, SpecularColor = PhongMaterials.ToColor(0.0225, 0.0225, 0.0225, 1.0), EmissiveColor = PhongMaterials.ToColor(0.0, 0.0, 0.0, 1.0), SpecularShininess = 12.8f, }; var selColor = (System.Windows.Media.Color)SharedDictionaryManager.DynamoColorsAndBrushesDictionary["SelectionColor"]; selectionColor = new Color4(selColor.R / 255.0f, selColor.G / 255.0f, selColor.B / 255.0f, selColor.A / 255.0f); SelectedMaterial = new PhongMaterial { Name = "White", AmbientColor = PhongMaterials.ToColor(0.1, 0.1, 0.1, 1.0), DiffuseColor = selectionColor, SpecularColor = PhongMaterials.ToColor(0.0225, 0.0225, 0.0225, 1.0), EmissiveColor = PhongMaterials.ToColor(0.0, 0.0, 0.0, 1.0), SpecularShininess = 12.8f, }; Model1Transform = new TranslateTransform3D(0, -0, 0); // camera setup Camera = new PerspectiveCamera { Position = new Point3D(10, 15, 10), LookDirection = new Vector3D(-10, -10, -10), UpDirection = new Vector3D(0, 1, 0), NearPlaneDistance = 1, FarPlaneDistance = 2000000, }; DrawGrid(); }
public void Init() { EM = EVEData.EveManager.Instance; universeSysLinksCache = new List <GateHelper>(); activeJumpSpheres = new List <KeyValuePair <string, double> >(); universeXMin = 0; universeXMax = 0; universeZMin = 0; universeZMax = 0; universeYMin = 0; universeYMax = 0; uiRefreshTimer = new System.Windows.Threading.DispatcherTimer(); uiRefreshTimer.Tick += UiRefreshTimer_Tick; uiRefreshTimer.Interval = new TimeSpan(0, 0, 5); uiRefreshTimer.Start(); PropertyChanged += Universe3DControl_PropertyChanged; DataContext = this; foreach (EVEData.System sys in EM.Systems) { foreach (string jumpTo in sys.Jumps) { EVEData.System to = EM.GetEveSystem(jumpTo); bool NeedsAdd = true; foreach (GateHelper gh in universeSysLinksCache) { if (((gh.from == sys) || (gh.to == sys)) && ((gh.from == to) || (gh.to == to))) { NeedsAdd = false; break; } } if (NeedsAdd) { GateHelper g = new GateHelper(); g.from = sys; g.to = to; g.RegionalGate = sys.Region != to.Region; universeSysLinksCache.Add(g); } } if (sys.ActualX < universeXMin) { universeXMin = sys.ActualX; } if (sys.ActualX > universeXMax) { universeXMax = sys.ActualX; } if (sys.ActualZ < universeZMin) { universeZMin = sys.ActualZ; } if (sys.ActualZ > universeZMax) { universeZMax = sys.ActualZ; } if (sys.ActualY < universeYMin) { universeYMin = sys.ActualY; } if (sys.ActualY > universeYMax) { universeYMax = sys.ActualY; } } universeWidth = universeXMax - universeXMin; universeDepth = universeZMax - universeZMin; universeHeight = universeYMax - universeYMin; List <EVEData.System> globalSystemList = new List <EVEData.System>(EM.Systems); globalSystemList.Sort((a, b) => string.Compare(a.Name, b.Name)); GlobalSystemDropDownAC.ItemsSource = globalSystemList; UniverseMain3DViewPort.EffectsManager = new DefaultEffectsManager(); HelixToolkit.Wpf.SharpDX.PerspectiveCamera pc = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera(); pc.NearPlaneDistance = 0.1; pc.FarPlaneDistance = 100000; pc.Position = new Point3D(4000, 4000, 10000); pc.UpDirection = new Vector3D(0, 0, 1); pc.LookDirection = new Vector3D(-1, 0, 0); pc.LookAt(new Point3D(4000, 4000, 4000), 1); UniverseMain3DViewPort.Camera = pc; ReDrawMap(true); }
protected BaseViewModel() { // camera models CameraModelCollection = new List<string>() { Orthographic, Perspective, }; // on camera changed callback CameraModelChanged += (s, e) => { if (cameraModel == Orthographic) { if (this.Camera != null) { var newCamera = new OrthographicCamera(); this.Camera.CopyTo(newCamera); newCamera.NearPlaneDistance = 1; newCamera.FarPlaneDistance = 100; this.Camera = newCamera; } else { Camera = defaultOrthographicCamera; } } else if (cameraModel == Perspective) { if (this.Camera != null) { var newCamera = new PerspectiveCamera(); this.Camera.CopyTo(newCamera); newCamera.NearPlaneDistance = 1; newCamera.FarPlaneDistance = 100; this.Camera = newCamera; } else { Camera = defaultPerspectiveCamera; } } else { throw new HelixToolkitException("Camera Model Error."); } }; // default camera model CameraModel = Perspective; Title = "Demo (HelixToolkitDX)"; SubTitle = "Default Base View Model"; }
public void ZoomExtents(Viewport3DX viewport, Rect3D bounds) { var diagonal = new Vector3D(bounds.SizeX, bounds.SizeY, bounds.SizeZ); var center = bounds.Location + (diagonal * 0.5); double radius = diagonal.Length * 0.5; HelixToolkit.Wpf.SharpDX.PerspectiveCamera Camera = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera() { Position = new Point3D(center.X + 30, center.Y + 30, center.Z + 50), LookDirection = new Vector3D(-30, -30, -50), UpDirection = new Vector3D(0, 0, 1), FarPlaneDistance = 5000000, FieldOfView = 45, NearPlaneDistance = 0.1, }; viewport.Camera.Reset(); viewport.Camera = Camera; }
private void SetupScene() { RenderTechnique = Techniques.RenderDynamo; WhiteMaterial = new PhongMaterial { Name = "White", AmbientColor = PhongMaterials.ToColor(0.1, 0.1, 0.1, 1.0), DiffuseColor = defaultMaterialColor, SpecularColor = PhongMaterials.ToColor(0.0225, 0.0225, 0.0225, 1.0), EmissiveColor = PhongMaterials.ToColor(0.0, 0.0, 0.0, 1.0), SpecularShininess = 12.8f, }; SelectedMaterial = new PhongMaterial { Name = "White", AmbientColor = PhongMaterials.ToColor(0.1, 0.1, 0.1, 1.0), DiffuseColor = defaultSelectionColor, SpecularColor = PhongMaterials.ToColor(0.0225, 0.0225, 0.0225, 1.0), EmissiveColor = PhongMaterials.ToColor(0.0, 0.0, 0.0, 1.0), SpecularShininess = 12.8f, }; Model1Transform = new TranslateTransform3D(0, -0, 0); // camera setup Camera = new PerspectiveCamera(); SetCameraData(new CameraData()); DrawGrid(); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { ////if (IsInDesignMode) ////{ //// // Code runs in Blend --> create design time data. ////} ////else ////{ //// // Code runs "for real" ////} //GenerateFibonacciSphereCommand = new RelayCommand(() => CreateFibonacciSphereMesh(),() => true,true); EffectsManager = new DefaultEffectsManager(); // titles // camera setup Camera = new PerspectiveCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0), FarPlaneDistance = 5000000 }; // setup lighting AmbientLightColor = Color.White; DirectionalLightColor = Color.White; DirectionalLightDirection = new Vector3D(-2, -5, -2); //// scene model3d //var b1 = new MeshBuilder(); //b1.AddSphere(new Vector3(0, 0, 0), 0.5); //b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2, BoxFaces.All); //var meshGeometry = b1.ToMeshGeometry3D(); //meshGeometry.Colors = new Color4Collection(meshGeometry.TextureCoordinates.Select(x => x.ToColor4())); //Model = meshGeometry; //// lines model3d var e1 = new LineBuilder(); e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2); VertexColorMaterial = new VertColorMaterial(); RedMaterial = PhongMaterials.BlackPlastic; //var diffColor = this.RedMaterial.DiffuseColor; //diffColor.Alpha = 0.5f; //this.RedMaterial.DiffuseColor = diffColor; Points = new PointGeometry3D(); BackgroundTexture = BitmapExtensions.CreateLinearGradientBitmapStream(EffectsManager, 128, 128, Direct2DImageFormat.Bmp, new Vector2(0, 0), new Vector2(0, 128), new SharpDX.Direct2D1.GradientStop[] { new SharpDX.Direct2D1.GradientStop() { Color = Color.DarkGray, Position = 0f }, new SharpDX.Direct2D1.GradientStop() { Color = Color.Black.ToColor4(), Position = 1.0f } }); SubdividedIcosahedronCommand = new RelayCommand(CreateSubdividedIcosahedron); }