示例#1
0
        public Camera2D(PerspectiveCamera camera)
        {
            _originalCamera = camera;
            _originalCamera.LookDirection = new Vector3D(0, 0.25, -1);

            Focused = true;
        }
示例#2
0
 public CameraHelper(Player player, PerspectiveCamera camera, PerspectiveCamera cameraMap, MinimapHelper blips)
 {
     _player = player;
     _camera = camera;
     _cameraMap = cameraMap;
     _blips = blips;
 }
 public void SyncCamera(PerspectiveCamera camera)
 {
     this.Camera.Position = camera.Position;
     this.Camera.LookDirection = camera.LookDirection;
     this.Camera.UpDirection = camera.UpDirection;
     this.Camera.FieldOfView = camera.FieldOfView;
 }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 4 "..\..\MainWindow.xaml"
                ((Ch15_Triangulation_3DViewer.MainWindow)(target)).KeyDown += new System.Windows.Input.KeyEventHandler(this.KeyDownEventHandler);

            #line default
            #line hidden
                return;

            case 2:
                this.info = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 3:
                this.viewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 4:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 5:
                this.model = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 6:
                this.group = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#5
0
 PerspectiveCamera defineCamera(double maxLegLength) {
     var camera = new PerspectiveCamera();
     camera.Position = new Point3D(maxLegLength, maxLegLength, maxLegLength).Multiply(1.6);
     camera.LookDirection = new Vector3D(-100, -100, -100);
     camera.UpDirection = new Vector3D(0, 0, 1);
     return camera;
 }
示例#6
0
 public PerspectiveCamera(System.Windows.Media.Media3D.PerspectiveCamera cam)
 {
     CameraViewPoint  = new Point(cam.Position);
     CameraDirection  = new Direction(cam.LookDirection);
     CameraUpVector   = new Direction(cam.UpDirection);
     fieldOfViewField = cam.FieldOfView;
 }
示例#7
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 7 "..\..\..\Calendar\Calendar.xaml"
                ((WeatherCalendar.Calendar)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Calendar_OnLoaded);

            #line default
            #line hidden
                return;

            case 2:
                this.lastRow = ((System.Windows.Controls.RowDefinition)(target));
                return;

            case 3:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.aar = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#8
0
		public VisualTree3DView(Visual visual)
		{
			DirectionalLight directionalLight1 = new DirectionalLight(Colors.White, new Vector3D(0, 0, 1));
			DirectionalLight directionalLight2 = new DirectionalLight(Colors.White, new Vector3D(0, 0, -1));

			double z = 0;
			Model3D model = this.ConvertVisualToModel3D(visual, ref z);

			Model3DGroup group = new Model3DGroup();
			group.Children.Add(directionalLight1);
			group.Children.Add(directionalLight2);
			group.Children.Add(model);
			this.zScaleTransform = new ScaleTransform3D();
			group.Transform = this.zScaleTransform;

			ModelVisual3D modelVisual = new ModelVisual3D();
			modelVisual.Content = group;

			Rect3D bounds = model.Bounds;
			double fieldOfView = 45;
			Point3D lookAtPoint = new Point3D(bounds.X + bounds.SizeX / 2, bounds.Y + bounds.SizeY / 2, bounds.Z + bounds.SizeZ / 2);
			double cameraDistance = 0.5 * bounds.SizeX / Math.Tan(0.5 * fieldOfView * Math.PI / 180);
			Point3D position = lookAtPoint - new Vector3D(0, 0, cameraDistance);
			Camera camera = new PerspectiveCamera(position, new Vector3D(0, 0, 1), new Vector3D(0, -1, 0), fieldOfView);

			this.zScaleTransform.CenterZ = lookAtPoint.Z;

			this.Children.Add(modelVisual);
			this.Camera = camera;
			this.ClipToBounds = false;
			this.Width = 500;
			this.Height = 500;

			this.trackballBehavior = new TrackballBehavior(this, lookAtPoint);
		}
 public ItemSelectDragLogic(Map map, PerspectiveCamera camera, Viewport3D viewport, UIElement visual)
 {
     _map = map;
     _camera = camera;
     _viewport = viewport;
     _visual = visual;
 }
示例#10
0
                public ViewportOffline(Color background)
                {
                    this.Viewport = new Viewport3D();

                    //  The initial values don't really matter.  The camera will be moved before taking a picture
                    _camera = new PerspectiveCamera(new Point3D(0, 0, 25), new Vector3D(0, 0, -1), new Vector3D(0, 1, 0), 45d);
                    this.Viewport.Camera = _camera;

                    //  The lights need to be passed in as CameraPoolVisual objects
                    //Model3DGroup lightGroup = new Model3DGroup();
                    //lightGroup.Children.Add(new AmbientLight(UtilityWPF.ColorFromHex("808080")));
                    //lightGroup.Children.Add(new DirectionalLight(UtilityWPF.ColorFromHex("FFFFFF"), new Vector3D(1, -1, -1)));
                    //lightGroup.Children.Add(new DirectionalLight(UtilityWPF.ColorFromHex("303030"), new Vector3D(-1, 1, 1)));

                    //ModelVisual3D lightModel = new ModelVisual3D();
                    //lightModel.Content = lightGroup;

                    //this.Viewport.Children.Add(lightModel);

                    _background = background;

                    // Viewport3D won't render to a bitmap when it's not part of the visual tree, but a border containing a viewport will
                    Border border = new Border();
                    border.Background = new SolidColorBrush(_background);
                    border.Child = this.Viewport;
                    _control = border;
                }
示例#11
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.UserControl = ((PictureBrowserPanel.CoverFlow)(target));
                return;

            case 2:
                this.LayoutRoot = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.viewport3D = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 4:
                this.Camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 5:
                this.Title = ((System.Windows.Controls.TextBlock)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#12
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.myStoryboard = ((System.Windows.Media.Animation.BeginStoryboard)(target));
                return;

            case 2:
                this.myViewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 3:
                this.myCamera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.myModelView3D = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 5:
                this.rotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 6:
                this.rotation2 = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#13
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 4 "..\..\Carousel.xaml"
                ((Bornander.UI.TabCarousel.Carousel)(target)).SizeChanged += new System.Windows.SizeChangedEventHandler(this.HandleSizeChanged);

            #line default
            #line hidden
                return;

            case 2:
                this.Grid3D = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.MainCamera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.Ambient = ((System.Windows.Media.Media3D.AmbientLight)(target));
                return;

            case 5:
                this.Directional = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 6:
                this.CarouselContainer = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#14
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.listBox = ((System.Windows.Controls.ListBox)(target));

            #line 18 "..\..\..\3DControl.xaml"
                this.listBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.listBox_SelectionChanged);

            #line default
            #line hidden
                return;

            case 2:
                this.button5 = ((System.Windows.Controls.Button)(target));
                return;

            case 3:
                this.label1 = ((System.Windows.Controls.Label)(target));
                return;

            case 4:
                this.textBox1 = ((System.Windows.Controls.TextBox)(target));
                return;

            case 5:
                this.SenceGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 6:
                this.viewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 7:
                this.myPerspectiveCamera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 8:
                this.FurnitureContainer = ((System.Windows.Media.Media3D.ContainerUIElement3D)(target));
                return;

            case 9:
                this.viewportLightsModelVisual3D = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 10:
                this.ambientLight = ((System.Windows.Media.Media3D.AmbientLight)(target));
                return;

            case 11:
                this.directionalLight = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 12:
                this.spotLight = ((System.Windows.Media.Media3D.SpotLight)(target));
                return;
            }
            this._contentLoaded = true;
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.LeftSpinBeginStoryboard = ((System.Windows.Media.Animation.BeginStoryboard)(target));
                return;

            case 2:
                this.RightSpinBeginStoryboard = ((System.Windows.Media.Animation.BeginStoryboard)(target));
                return;

            case 3:
                this.UpwardSpinBeginStoryboard = ((System.Windows.Media.Animation.BeginStoryboard)(target));
                return;

            case 4:
                this.DownwardSpinBeginStoryboard = ((System.Windows.Media.Animation.BeginStoryboard)(target));
                return;

            case 5:
                this.myPerspectiveCamera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 6:
                this.myHorizontalRotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 7:
                this.myVerticalRotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="StructureControl"/> class and sets up visual elements for rendering.
        /// </summary>
        /// <param name="pdbViewer">The PDB viewer.</param>
        internal StructureControl(PdbViewer pdbViewer)
        {
            this.pdbViewer = pdbViewer;

            NameScope.SetNameScope(this, new NameScope());

            this.viewport = new Viewport3D();
            this.viewport.ClipToBounds = true;
            this.Children.Add(this.viewport);

            this.camera = new PerspectiveCamera();
            this.camera.Position = new Point3D(0, 0, cameraOffset);
            this.viewport.Camera = this.camera;

            ModelVisual3D lightingVisual = new ModelVisual3D();
            this.viewport.Children.Add(lightingVisual);

            Model3DGroup lightingModel = new Model3DGroup();
            lightingVisual.Content = lightingModel;

            PointLight pointLight = new PointLight(Colors.White, new Point3D(-4, 4, 8));
            lightingModel.Children.Add(pointLight);

            AmbientLight ambientLight = new AmbientLight(Color.FromRgb(32, 32, 32));
            lightingModel.Children.Add(ambientLight);

            this.moleculeVisual = new ModelVisual3D();
            viewport.Children.Add(this.moleculeVisual);

            Transform3DGroup transformGroup = new Transform3DGroup();
            this.moleculeVisual.Transform = transformGroup;

            this.translateTransform = new TranslateTransform3D();
            transformGroup.Children.Add(this.translateTransform);

            this.scaleTransform = new ScaleTransform3D();
            transformGroup.Children.Add(this.scaleTransform);

            this.rotateTransform = new RotateTransform3D();
            this.rotateTransform.Rotation = new QuaternionRotation3D();
            transformGroup.Children.Add(this.rotateTransform);

            this.selectionRectangle = new Rectangle();
            this.selectionRectangle.Stroke = Brushes.White;
            this.selectionRectangle.Fill = new SolidColorBrush(Color.FromArgb(32, 255, 255, 255));
            this.selectionRectangle.Visibility = Visibility.Hidden;
            this.Children.Add(this.selectionRectangle);

            this.testLabel = new Label();
            this.testLabel.Foreground = Brushes.White;
            this.testLabel.FontSize = 20;
            this.testLabel.HorizontalAlignment = HorizontalAlignment.Left;
            this.testLabel.VerticalAlignment = VerticalAlignment.Center;
            this.Children.Add(this.testLabel);

            this.clip = 1;
            this.slab = 0;
            this.UpdateClipping();
        }
示例#17
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 10 "..\..\Window3D.xaml"
                ((System.Windows.Controls.Grid)(target)).MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.Grid_MouseWheel);

            #line default
            #line hidden

            #line 11 "..\..\Window3D.xaml"
                ((System.Windows.Controls.Grid)(target)).MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.Grid_MouseDown);

            #line default
            #line hidden

            #line 11 "..\..\Window3D.xaml"
                ((System.Windows.Controls.Grid)(target)).MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Grid_MouseUp);

            #line default
            #line hidden

            #line 12 "..\..\Window3D.xaml"
                ((System.Windows.Controls.Grid)(target)).MouseMove += new System.Windows.Input.MouseEventHandler(this.Grid_MouseMove);

            #line default
            #line hidden
                return;

            case 2:
                this.button = ((System.Windows.Controls.Button)(target));

            #line 18 "..\..\Window3D.xaml"
                this.button.Click += new System.Windows.RoutedEventHandler(this.Button_Click);

            #line default
            #line hidden
                return;

            case 3:
                this.mainViewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 4:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 5:
                this.model = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 6:
                this.group = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#18
0
        public TrackBallRoam(PerspectiveCamera camera)
        {
            _camera = camera;

            _autoscroll = new AutoScrollEmulator();
            _autoscroll.AutoScroll += new AutoScrollHandler(Autoscroll_AutoScroll);
            _autoscroll.CursorChanged += new EventHandler(Autoscroll_CursorChanged);
        }
 public void UpdateCamera(PerspectiveCamera camera)
 {
     cameraDir.Text = camera.LookDirection.Format("f1");
     cameraEye.Text = camera.Position.Format("f1");
     cameraUp.Text = camera.UpDirection.Format("f1");
     nearPlane.Text = camera.NearPlaneDistance.ToString("f1");
     farPlane.Text = camera.FarPlaneDistance.ToString("f1");
     fov.Text = camera.FieldOfView.ToString("f1");
 }
示例#20
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 9 "..\..\MainWindow.xaml"
                ((ParallelBoids.MainWindow)(target)).MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.Window_MouseWheel);

            #line default
            #line hidden

            #line 9 "..\..\MainWindow.xaml"
                ((ParallelBoids.MainWindow)(target)).MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(this.Window_MouseDoubleClick);

            #line default
            #line hidden

            #line 9 "..\..\MainWindow.xaml"
                ((ParallelBoids.MainWindow)(target)).KeyDown += new System.Windows.Input.KeyEventHandler(this.Window_KeyDown);

            #line default
            #line hidden

            #line 9 "..\..\MainWindow.xaml"
                ((ParallelBoids.MainWindow)(target)).MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.Window_MouseDown);

            #line default
            #line hidden

            #line 9 "..\..\MainWindow.xaml"
                ((ParallelBoids.MainWindow)(target)).MouseMove += new System.Windows.Input.MouseEventHandler(this.Window_MouseMove);

            #line default
            #line hidden

            #line 9 "..\..\MainWindow.xaml"
                ((ParallelBoids.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.viewport3D = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 3:
                this.camMain = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.myAngleRotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
        public TrackballGrabber(FrameworkElement eventSource, Viewport3D viewport, double sphereRadius, Color hoverLightColor)
        {
            if (viewport.Camera == null || !(viewport.Camera is PerspectiveCamera))
            {
                throw new ArgumentException("This class requires a perspective camera to be tied to the viewport");
            }

            _eventSource = eventSource;
            _viewport = viewport;
            _camera = (PerspectiveCamera)viewport.Camera;

            this.SyncedLights = new List<Model3D>();

            this.HoverVisuals = new ObservableCollection<Visual3D>();
            this.HoverVisuals.CollectionChanged += HoverVisuals_CollectionChanged;

            _eventSource.MouseEnter += new System.Windows.Input.MouseEventHandler(EventSource_MouseEnter);
            _eventSource.MouseLeave += new System.Windows.Input.MouseEventHandler(EventSource_MouseLeave);
            _eventSource.MouseDown += new System.Windows.Input.MouseButtonEventHandler(EventSource_MouseDown);
            _eventSource.MouseUp += new System.Windows.Input.MouseButtonEventHandler(EventSource_MouseUp);
            _eventSource.MouseMove += new System.Windows.Input.MouseEventHandler(EventSource_MouseMove);

            #region Sphere

            // Material
            _sphereMaterials = new MaterialGroup();
            _sphereMaterials.Children.Add(new DiffuseMaterial(new SolidColorBrush(Color.FromArgb(25, 255, 255, 255))));

            // This gets added/removed on mouse enter/leave
            _sphereMaterialHover = new SpecularMaterial(new SolidColorBrush(Color.FromArgb(64, 128, 128, 128)), 33d);

            // Geometry Model
            GeometryModel3D geometry = new GeometryModel3D();
            geometry.Material = _sphereMaterials;
            geometry.BackMaterial = _sphereMaterials;
            geometry.Geometry = UtilityWPF.GetSphere_LatLon(20, sphereRadius);

            // Model Visual
            _sphereModel = new ModelVisual3D();
            _sphereModel.Content = geometry;

            // Add it
            _viewport.Children.Add(_sphereModel);

            #endregion
            #region Hover Light

            // Light
            PointLight hoverLight = new PointLight();
            hoverLight.Color = hoverLightColor;
            hoverLight.Range = sphereRadius * 10;

            _hoverLight = new ModelVisual3D();
            _hoverLight.Content = hoverLight;

            #endregion
        }
        public CameraManipulator(IScene scene)
        {
            this.scene = scene;

            this.camera = new PerspectiveCamera();
            this.UpDirection = new Vector3D(-1, -1, 2)/Math.Sqrt(6);
            this.SetCameraPosition(this.scene.Center +
                                   new Vector3D(1, 1, 1)*this.scene.Radius*4/Math.Sqrt(3));
        }
示例#23
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.tbValues = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 2:
                this.btnGo = ((System.Windows.Controls.Button)(target));

            #line 25 "..\..\Window1.xaml"
                this.btnGo.Click += new System.Windows.RoutedEventHandler(this.btnGo_Click);

            #line default
            #line hidden
                return;

            case 3:
                this.tbAccVals = ((System.Windows.Controls.TextBox)(target));
                return;

            case 4:
                this.viewport3D1 = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 5:
                this.camMain = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 6:
                this.dirLightMain = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 7:
                this.MyModel = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 8:
                this.meshMain = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 9:
                this.matDiffuseMain = ((System.Windows.Media.Media3D.DiffuseMaterial)(target));
                return;

            case 10:
                this.rotate = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 11:
                this.slider1 = ((System.Windows.Controls.Slider)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#24
0
		private void AddCamera() {
			PerspectiveCamera camera=new PerspectiveCamera();
			camera.Position=new Point3D(0,3.3,8);//in WPF, z axis is positive coming out from the screen toward the viewer.
			//camera.FarPlaneDistance=20;
			camera.LookDirection=new Vector3D(0,-.4,-1);
			//camera.UpDirection=new Vector3D(0,1,0);
			//camera.NearPlaneDistance=0;
			camera.FieldOfView=45;
			myViewport.Camera=camera;
		}
示例#25
0
        public static void SetFromWpfCamera(this DxCamera thisCamera, System.Windows.Media.Media3D.PerspectiveCamera wpfCamera)
        {
            thisCamera.At  = (wpfCamera.Position + wpfCamera.LookDirection).ToVector3();
            thisCamera.Eye = wpfCamera.Position.ToVector3();
            thisCamera.Up  = wpfCamera.UpDirection.ToVector3();

            thisCamera.NearDistance = (float)wpfCamera.NearPlaneDistance;
            thisCamera.FarDistance  = (float)wpfCamera.FarPlaneDistance;
            thisCamera.FOV          = (float)DegreeToRadian(wpfCamera.FieldOfView);
        }
示例#26
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 9 "..\..\Visualizer.xaml"
                ((VisualizerControl.Visualizer)(target)).MouseMove += new System.Windows.Input.MouseEventHandler(this.MyViewport_MouseMove);

            #line default
            #line hidden

            #line 10 "..\..\Visualizer.xaml"
                ((VisualizerControl.Visualizer)(target)).MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.MyViewport_MouseLeftButtonUp);

            #line default
            #line hidden

            #line 10 "..\..\Visualizer.xaml"
                ((VisualizerControl.Visualizer)(target)).MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.MyViewport_MouseWheel);

            #line default
            #line hidden

            #line 11 "..\..\Visualizer.xaml"
                ((VisualizerControl.Visualizer)(target)).KeyDown += new System.Windows.Input.KeyEventHandler(this.UserControl_KeyDown);

            #line default
            #line hidden
                return;

            case 2:
                this.myViewport = ((System.Windows.Controls.Viewport3D)(target));

            #line 17 "..\..\Visualizer.xaml"
                this.myViewport.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.MyViewport_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 3:
                this.Camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.ModelVisual_1 = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 5:
                this.Group = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;
            }
            this._contentLoaded = true;
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 25 "..\..\Materials.xaml"
                ((System.Windows.Controls.StackPanel)(target)).AddHandler(System.Windows.Controls.Primitives.ButtonBase.ClickEvent, new System.Windows.RoutedEventHandler(this.chk_Click));

            #line default
            #line hidden
                return;

            case 2:
                this.chkBackground = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 3:
                this.chkDiffuse = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 4:
                this.chkSpecular = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 5:
                this.chkEmissive = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 6:
                this.rect = ((System.Windows.Shapes.Rectangle)(target));
                return;

            case 7:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 8:
                this.Scene = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 9:
                this.ring = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 10:
                this.Torus01OR9GR10 = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 11:
                this.materialsGroup = ((System.Windows.Media.Media3D.MaterialGroup)(target));
                return;
            }
            this._contentLoaded = true;
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Window = ((Opdracht1.MainWindow)(target));
                return;

            case 2:
                this.Slider1 = ((System.Windows.Controls.Slider)(target));

            #line 19 "..\..\MainWindow.xaml"
                this.Slider1.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.Slider1_ValueChanged);

            #line default
            #line hidden
                return;

            case 3:
                this.Slider2 = ((System.Windows.Controls.Slider)(target));

            #line 22 "..\..\MainWindow.xaml"
                this.Slider2.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.Slider2_ValueChanged);

            #line default
            #line hidden
                return;

            case 4:
                this.viewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 5:
                this.Camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 6:
                this.Board = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 7:
                this.WallContainer = ((System.Windows.Media.Media3D.ContainerUIElement3D)(target));
                return;

            case 8:
                this.SphereContainer = ((System.Windows.Media.Media3D.ContainerUIElement3D)(target));
                return;

            case 9:
                this.Light = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#29
0
 /// <summary>
 /// Resets the specified perspective camera.
 /// </summary>
 /// <param name="camera">The camera.</param>
 public static void Reset(PerspectiveCamera camera)
 {
     if (camera == null)
         return;
     camera.Position = new Point3D(2, 16, 20);
     camera.LookDirection = new Vector3D(-2, -16, -20);
     camera.UpDirection = new Vector3D(0, 0, 1);
     camera.FieldOfView = 45;
     camera.NearPlaneDistance = 0.1;
     camera.FarPlaneDistance = 100000;
 }
        public WiggleView3D()
        {
            InitializeComponent();

            RightCamera = new PerspectiveCamera();
            BindViewports(View1, null, true, true);

            CompositionTarget.Rendering += CompositionTarget_Rendering;
            UpdateTimer();
            watch.Start();
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.PerspectiveCamera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 2:
                this.containerUIElement3D = ((System.Windows.Media.Media3D.ContainerUIElement3D)(target));
                return;

            case 3:
                this.FrontViewport2DVisual3D = ((System.Windows.Media.Media3D.Viewport2DVisual3D)(target));
                return;

            case 4:
                this.newS = ((System.Windows.Controls.Button)(target));

            #line 169 "..\..\..\Transform\Viewport3DTransform.xaml"
                this.newS.Click += new System.Windows.RoutedEventHandler(this.newS_Click);

            #line default
            #line hidden
                return;

            case 5:
                this.BackViewport2DVisual3D = ((System.Windows.Media.Media3D.Viewport2DVisual3D)(target));
                return;

            case 6:
                this.setS = ((System.Windows.Controls.Button)(target));

            #line 215 "..\..\..\Transform\Viewport3DTransform.xaml"
                this.setS.Click += new System.Windows.RoutedEventHandler(this.setS_Click);

            #line default
            #line hidden
                return;

            case 7:
                this.ViewLight = ((System.Windows.Media.Media3D.AmbientLight)(target));
                return;

            case 8:
                this.DisplayGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 9:
                this.DisPlayControl = ((System.Windows.Controls.UserControl)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#32
0
        public Viewport3D setupViewport(PerspectiveCamera p1, double height, double width)
        {
            vp = new Viewport3D();

            vp.IsHitTestVisible = false;
            vp.Camera = p1;
            vp.Height = height;
            vp.Width = width;

            return vp;
        }
 public static bool IsVisible(PerspectiveCamera camera, Point3D worldPoint)
 {
     var local = ProjectionCameraExtension.GetWorldToLocal(camera).Transform(worldPoint);
     // camera lookdirection is along -Z axis
     if (local.Z >= 0.0) return false;
     var deg2rad = 0.01745329;
     var distance = Abs(local.Z);
     var frustrumHeight = 2.0 * distance * Tan(camera.FieldOfView*deg2rad*0.5);
     if (Abs(local.X) > frustrumHeight / 2.0) return false;
     if(Abs(local.Y) > frustrumHeight/2.0) return false;
     return true;
 }
 public static PerspectiveCamera GetTransformedPerspectiveCamera(PerspectiveCamera camera, Transform3D transform)
 {
     return new PerspectiveCamera
     {
         LookDirection = transform.Transform(camera.LookDirection),
         UpDirection = transform.Transform(camera.UpDirection),
         FieldOfView = camera.FieldOfView,
         FarPlaneDistance = camera.FarPlaneDistance,
         NearPlaneDistance = camera.NearPlaneDistance,
         Position = transform.Transform(camera.Position)
     };
 }
示例#35
0
        /// <summary>
        /// Copies all members of the source <see cref="Camera"/>.
        /// </summary>
        /// <param name="source">Source camera.</param>
        /// <param name="dest">Destination camera.</param>
        public static void Copy(PerspectiveCamera source, PerspectiveCamera dest)
        {
            if (source == null || dest == null)
                return;

            dest.LookDirection = source.LookDirection;
            dest.Position = source.Position;
            dest.UpDirection = source.UpDirection;
            dest.FieldOfView = source.FieldOfView;
            dest.NearPlaneDistance = source.NearPlaneDistance;
            dest.FarPlaneDistance = source.FarPlaneDistance;
        }
示例#36
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.WorkG = ((System.Windows.Controls.Grid)(target));

            #line 9 "..\..\..\View\View.xaml"
                this.WorkG.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.WorkGrid_MouseWheel);

            #line default
            #line hidden

            #line 9 "..\..\..\View\View.xaml"
                this.WorkG.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.WorkGrid_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 2:
                this.port3d = ((System.Windows.Controls.Viewport3D)(target));

            #line 10 "..\..\..\View\View.xaml"
                this.port3d.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.WorkGrid_MouseWheel);

            #line default
            #line hidden

            #line 10 "..\..\..\View\View.xaml"
                this.port3d.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.port3d_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 3:
                this.Perspective = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.Trig = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 5:
                this.Trig2 = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#37
0
        public PerspectiveCamera setupCamera()
        {
            pc = new PerspectiveCamera();

            //Kinect defaults
            pc.FarPlaneDistance = 8000;
            pc.NearPlaneDistance = 100;
            pc.FieldOfView = 10;
            pc.Position = new Point3D(300, 200, -1000);
            pc.LookDirection = new Vector3D(0, 0, 1);
            pc.UpDirection = new Vector3D(0, -1, 0);

            return pc;
        }
示例#38
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Window = ((WPF三维图形.MainWindow)(target));
                return;

            case 2:
                this.LayoutRoot = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.viewport3d = ((System.Windows.Controls.Viewport3D)(target));

            #line 11 "..\..\MainWindow.xaml"
                this.viewport3d.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.viewport3d_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 11 "..\..\MainWindow.xaml"
                this.viewport3d.MouseMove += new System.Windows.Input.MouseEventHandler(this.viewport3d_MouseMove);

            #line default
            #line hidden

            #line 11 "..\..\MainWindow.xaml"
                this.viewport3d.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.viewport3d_MouseWheel);

            #line default
            #line hidden
                return;

            case 4:
                this.ppc = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 5:
                this.reset = ((System.Windows.Controls.Button)(target));

            #line 16 "..\..\MainWindow.xaml"
                this.reset.Click += new System.Windows.RoutedEventHandler(this.reset_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
示例#39
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.mainViewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 2:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 3:
                this.MyModel = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 4:
                this.scale = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 5:
                this.rotateY = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 6:
                this.rotateX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 7:
                this.translate = ((System.Windows.Media.Media3D.TranslateTransform3D)(target));
                return;

            case 8:
                this.model3DGroup = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 9:
                this.geometryModel = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 10:
                this.meshMain = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 11:
                this.meshBack = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
 public Vieport3DExt()
     : base()
 {
     _kaleidoscopes = new KaleidoscopeFactory<Node3D, Geometry3D, Transformation3D>();
     _light = new AmbientLight(Colors.White);
     SizeChanged += OnSizeChanged;
     DataContextChanged += OnDataContextChanged;
     _camera = new PerspectiveCamera()
     {
         Position= new Point3D(0, 0, 1067),
         LookDirection = new Vector3D(0, 0, -40),
         UpDirection = new Vector3D(0, -1, 0)
     };
     Camera = _camera;
 }
示例#41
0
        public Cube3D()
        {
            Canvas.SetLeft(this,0);
            Canvas.SetTop(this,0);
            this.Width=733;
            this.Height = 400;
            this.ClipToBounds = true;

            //add camera
            PerspectiveCamera myPCamera = new PerspectiveCamera();
            myPCamera.Position = new Point3D(0, 30, 90);
            myPCamera.LookDirection = new Vector3D(0, -20, -90);
            myPCamera.FieldOfView = 80;
            this.Camera = myPCamera;

            //add light
            ModelVisual3D mv3dLight = new ModelVisual3D();
            DirectionalLight myDirLight = new DirectionalLight();
            myDirLight.Color = Colors.White;
            myDirLight.Direction = new Vector3D(-2, -3, -1);
            mv3dLight.Content = myDirLight;
            this.Children.Add(mv3dLight);

            //add material and mesh geometry
            Viewport2DVisual3D vpMaterial = new Viewport2DVisual3D();
            DiffuseMaterial dm = new DiffuseMaterial();
            dm.Brush = Brushes.Transparent;
            vpMaterial.Material = dm;
            MeshGeometry3D vpg = new MeshGeometry3D();
            vpg.Positions.Add(new Point3D(-55,0,-30));
            vpg.Positions.Add(new Point3D(-55,0,30));
            vpg.Positions.Add(new Point3D(55,0,30));
            vpg.Positions.Add(new Point3D(55,0,-30));
            vpg.TextureCoordinates.Add(new Point(0,0));
            vpg.TextureCoordinates.Add(new Point(0,1));
            vpg.TextureCoordinates.Add(new Point(1,1));
            vpg.TextureCoordinates.Add(new Point(1,0));
            vpg.TriangleIndices.Add(0);
            vpg.TriangleIndices.Add(1);
            vpg.TriangleIndices.Add(2);
            vpg.TriangleIndices.Add(2);
            vpg.TriangleIndices.Add(3);
            vpg.TriangleIndices.Add(0);
            vpMaterial.Geometry = vpg;
            this.Children.Add(vpMaterial);

            this.Loaded += new RoutedEventHandler(OnLoad);
        }
示例#42
0
        public MainWindow()
        {
            InitializeComponent();
            Calculate();
            // Declare scene objects.

            Model3DGroup myModel3DGroup = new Model3DGroup();

            ModelVisual3D myModelVisual3D = new ModelVisual3D();
            // Defines the camera used to view the 3D object. In order to view the 3D object,
            // the camera must be positioned and pointed such that the object is within view
            // of the camera.
            PerspectiveCamera myPCamera = new PerspectiveCamera();

            // Specify where in the 3D scene the camera is.
            myPCamera.Position = new Point3D(0, 0, -80);

            // Specify the direction that the camera is pointing.
            myPCamera.LookDirection = new Vector3D(0, 0, 1);

            // Define camera's horizontal field of view in degrees.
            myPCamera.FieldOfView = 80;

            // Asign the camera to the viewport
            myViewport3D.Camera = myPCamera;
            // Define the lights cast in the scene. Without light, the 3D object cannot
            // be seen. Note: to illuminate an object from additional directions, create
            // additional lights.
            AmbientLight _ambLight = new AmbientLight(System.Windows.Media.Brushes.White.Color);
            myModel3DGroup.Children.Add(_ambLight);

            // Add the geometry model to the model group.
            myModel3DGroup.Children.Add(myGeometryModel);

            // Add the group of models to the ModelVisual3d.
            myModelVisual3D.Content = myModel3DGroup;

            //
            myViewport3D.Children.Add(myModelVisual3D);

            // Apply the viewport to the page so it will be rendered.
            this.Content = myViewport3D;

            System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 30);
            dispatcherTimer.Start();
        }
示例#43
0
        /// <summary>
        /// RenderKinectPointsTriangle - renders kinect point cloud data using triangle meshes
        /// </summary>
        /// <returns>rendered point cloud model</returns>
        public GeometryModel3D[] RenderKinectPointsTriangle()
        {
            DirectionalLight    DirLight1 = new DirectionalLight();
            PerspectiveCamera   Camera1 = new PerspectiveCamera();
            Model3DGroup        modelGroup = new Model3DGroup();
            ModelVisual3D       modelsVisual = new ModelVisual3D();
            Viewport3D          myViewport = new Viewport3D();

            //directional light
            DirLight1.Color = Colors.White;
            DirLight1.Direction = new Vector3D(1, 1, 1);

            //camera specification
            Camera1.FarPlaneDistance = 8000;
            Camera1.NearPlaneDistance = 100;
            Camera1.FieldOfView = 10;
            Camera1.Position = new Point3D(160, 120, -1000);
            Camera1.LookDirection = new Vector3D(0, 0, 1);
            Camera1.UpDirection = new Vector3D(0, -1, 0);

            //create triangle mesh
            int i = 0;
            for (int y = 0; y < 480; y += s)
            {
                for (int x = 0; x < 640; x += s)
                {
                    pts[i] = Triangle(x, y, s);
                    pts[i].Transform = new TranslateTransform3D(0, 0, 0);
                    modelGroup.Children.Add(pts[i]);
                    i++;
                }
            }

            modelGroup.Children.Add(DirLight1);
            modelsVisual.Content = modelGroup;
            myViewport.IsHitTestVisible = false;
            myViewport.Camera = Camera1;
            myViewport.Children.Add(modelsVisual);
            viewportCanvas.Children.Add(myViewport);

            myViewport.Height = viewportCanvas.Height;
            myViewport.Width = viewportCanvas.Width;
            Canvas.SetTop(myViewport, 0);
            Canvas.SetLeft(myViewport, 0);

            return pts;
        }
示例#44
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 2:
                this.light = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 3:
                this.magicCube = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 4:
                this.cube = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 5:
                this.F1 = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 6:
                this.F2 = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 7:
                this.F3 = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 8:
                this.F4 = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 9:
                this.F5 = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 10:
                this.F6 = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#45
0
        /// <summary>
        /// Updates the left and right camera based on a center camera.
        /// </summary>
        /// <param name="centerCamera">Center camera (input)</param>
        /// <param name="leftCamera">Left camera (is updated)</param>
        /// <param name="rightCamera">Right camera (is updated)</param>
        /// <param name="stereoBase">Stereo base</param>
        /// <param name="crossViewing">true for cross-viewingm false for parallel-viewing</param>
        /// <param name="sameUpDirection">use the same UpDirection for both cameras</param>
        /// <param name="sameDirection">use the same LookDirection for both cameras</param>
        public static void UpdateStereoCameras(PerspectiveCamera centerCamera, PerspectiveCamera leftCamera, PerspectiveCamera rightCamera, 
            double stereoBase, bool crossViewing, bool sameUpDirection, bool sameDirection)
        {
            if (centerCamera == null || leftCamera == null || rightCamera == null)
                return;

            double sb = stereoBase;
            if (crossViewing)
                sb *= -1;

            var lookAt = centerCamera.Position + centerCamera.LookDirection;
            var right = Vector3D.CrossProduct(centerCamera.LookDirection, centerCamera.UpDirection);
            right.Normalize();

            leftCamera.Position = centerCamera.Position - right * sb / 2;
            if (sameDirection)
                leftCamera.LookDirection = centerCamera.LookDirection;
            else
                leftCamera.LookDirection = lookAt - leftCamera.Position;

            rightCamera.Position = centerCamera.Position + right * sb / 2;
            if (sameDirection)
                rightCamera.LookDirection = centerCamera.LookDirection;
            else
                rightCamera.LookDirection = lookAt - rightCamera.Position;

            // TODO: not sure what is best here?
            if (sameUpDirection)
            {
                leftCamera.UpDirection = centerCamera.UpDirection;
                rightCamera.UpDirection = centerCamera.UpDirection;
            }
            else
            {
                leftCamera.UpDirection = Vector3D.CrossProduct(right, leftCamera.LookDirection);
                rightCamera.UpDirection = Vector3D.CrossProduct(right, rightCamera.LookDirection);
            }

            leftCamera.FieldOfView = centerCamera.FieldOfView;
            leftCamera.NearPlaneDistance = centerCamera.NearPlaneDistance;
            leftCamera.FarPlaneDistance = centerCamera.FarPlaneDistance;

            rightCamera.FieldOfView = centerCamera.FieldOfView;
            rightCamera.NearPlaneDistance = centerCamera.NearPlaneDistance;
            rightCamera.FarPlaneDistance = centerCamera.FarPlaneDistance;
        }
示例#46
0
        public ShellViewModel()
        {
            this.Title = "MvvmCameraDemo";
            this.Viewport1 = new ViewportViewModel();
            this.Viewport2 = new ViewportViewModel();

            var camera = new PerspectiveCamera()
            {
                Position = new Point3D(0, -10, 0),
                LookDirection = new Vector3D(0, 10, 0),
                UpDirection = new Vector3D(0, 0, 1),
                FieldOfView = 60,
            };

            this.Viewport1.Camera = camera;
            this.Viewport2.Camera = camera;
        }
示例#47
0
        public ShellViewModel()
        {
            Title = "Hello Caliburn.Micro";
            Viewport1 = new ViewportViewModel();
            Viewport2 = new ViewportViewModel();

            camera = new PerspectiveCamera()
            {
                Position = new Point3D(0, -10, 0),
                LookDirection = new Vector3D(0, 10, 0),
                UpDirection = new Vector3D(0, 0, 1),
                FieldOfView = 60,
            };

            Viewport1.Camera = camera;
            Viewport2.Camera = camera;
        }
示例#48
0
        public void DrawScene(Viewport3D mainViewport, ObservableCollection<Vehicle> selectedVehicles)
        {
            PerspectiveCamera cam = new PerspectiveCamera(new Point3D(9000, 5000, 24000),
            new Vector3D(-1, -2, -10), new Vector3D(0, -1, 0), 50000);
            mainViewport.Camera = cam;

            // Create another ModelVisual3D for light.
            ModelVisual3D modvis = new ModelVisual3D();
            modvis.Content = new AmbientLight(Colors.White);
            mainViewport.Children.Add(modvis);

            foreach (Vehicle v in selectedVehicles)
            {
                DrawVehicle3D(mainViewport, v);

            }
        }
示例#49
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.MyAnimatedObject = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 2:
                this.myPerspectiveCamera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 3:
                this.myRotateTransform3D = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#50
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.viewport = ((HelixToolkit.Wpf.HelixViewport3D)(target));
                return;

            case 2:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 3:
                this.Tool3D = ((HelixToolkit.Wpf.PipeVisual3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#51
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.myCube = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 2:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 3:
                this.light = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#52
0
        public BackgoundTiles(Canvas canvas, PerspectiveCamera camera, Brush brush, Tuple<double, double> standardSizeAtZoom = null, Tuple<double, double> maxSizeAtZoom = null)
        {
            _canvas = canvas;
            _camera = camera;
            _brush = brush;

            GetFixedScales(_camera.Position.Z, ref standardSizeAtZoom, ref maxSizeAtZoom, out _k, out _b);
            _standardSizeAtZoom = standardSizeAtZoom;
            _maxSizeAtZoom = maxSizeAtZoom;

            _initialOffset = Math3D.GetRandomVector(_standardSizeAtZoom.Item1).ToVector2D();

            _canvas.SizeChanged += Canvas_SizeChanged;
            _camera.Changed += Camera_Changed;

            _canvas.ClipToBounds = true;

            UpdateTiles();
        }
示例#53
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.viewport3D = ((System.Windows.Controls.Viewport3D)(target));

            #line 10 "..\..\MainWindow.xaml"
                this.viewport3D.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.viewport3D_MouseUp);

            #line default
            #line hidden

            #line 10 "..\..\MainWindow.xaml"
                this.viewport3D.MouseMove += new System.Windows.Input.MouseEventHandler(this.viewport3D_MouseMove);

            #line default
            #line hidden

            #line 10 "..\..\MainWindow.xaml"
                this.viewport3D.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.viewport3D_MouseDown);

            #line default
            #line hidden

            #line 11 "..\..\MainWindow.xaml"
                this.viewport3D.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.viewport3D_MouseWheel);

            #line default
            #line hidden
                return;

            case 2:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 3:
                this.axisAngle = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.window = ((Class.MainWindow)(target));

            #line 8 "..\..\MainWindow.xaml"
                this.window.KeyDown += new System.Windows.Input.KeyEventHandler(this.Window_KeyDown);

            #line default
            #line hidden

            #line 8 "..\..\MainWindow.xaml"
                this.window.KeyUp += new System.Windows.Input.KeyEventHandler(this.Window_KeyUp);

            #line default
            #line hidden

            #line 8 "..\..\MainWindow.xaml"
                this.window.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.Window_MouseDown);

            #line default
            #line hidden

            #line 8 "..\..\MainWindow.xaml"
                this.window.MouseMove += new System.Windows.Input.MouseEventHandler(this.Window_MouseMove);

            #line default
            #line hidden
                return;

            case 2:
                this.mainViewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 3:
                this.cam = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#55
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 8 "..\..\preMain.xaml"
                ((Gas_Simulator.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.MainViewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 3:
                this.Main = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.TopMostThing = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 5:
                this.LightMain = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 6:
                this.slider1 = ((System.Windows.Controls.Slider)(target));

            #line 53 "..\..\preMain.xaml"
                this.slider1.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.slider1_ValueChanged);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
示例#56
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.my3Dgrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 2:
                this.mainViewPort = ((System.Windows.Controls.Viewport3D)(target));

            #line 10 "..\..\UserControl1.xaml"
                this.mainViewPort.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.mainViewPort_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 10 "..\..\UserControl1.xaml"
                this.mainViewPort.MouseMove += new System.Windows.Input.MouseEventHandler(this.mainViewPort_MouseMove);

            #line default
            #line hidden

            #line 10 "..\..\UserControl1.xaml"
                this.mainViewPort.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.mainViewPort_MouseWheel);

            #line default
            #line hidden
                return;

            case 3:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.directionLightOfMainViewPort = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#57
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 17 "..\..\..\..\src\scenes\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.createSphere);

            #line default
            #line hidden
                return;

            case 2:

            #line 30 "..\..\..\..\src\scenes\MainWindow.xaml"
                ((System.Windows.Controls.Grid)(target)).MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.Grid_MouseWheel);

            #line default
            #line hidden
                return;

            case 3:
                this.viewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 4:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 5:
                this.model = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 6:
                this.group = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#58
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.viewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 2:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 3:
                this.ringVisual = ((System.Windows.Media.Media3D.ModelUIElement3D)(target));

            #line 16 "..\..\HitTesting.xaml"
                this.ringVisual.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.ringVisual_MouseDown);

            #line default
            #line hidden
                return;

            case 4:
                this.Scene = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 5:
                this.ringModel = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 6:
                this.ringMesh = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 7:
                this.axisRotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 2:
                this.Scene = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 3:
                this.ring = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 4:
                this.Torus01OR9GR10 = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#60
-1
        private Robot robot; //the robot to display!

        #endregion Fields

        #region Constructors

        public ViewPlatform(Viewport3D viewport, MotorManager motorManager, Robot robot)
        {
            this.robot = robot;
            robot.intialise(viewport);
            this.motorManager = motorManager;
            //Add myself as a listener for the motor manager:
            this.motorManager.addListener(this);
            //Create a focussed camera to watch the origin:
            focussedCamera = new FocussedCamera(200, 0, 0);
            //Create the perspective camera!
            camera = getCamera(focussedCamera.Location, focussedCamera.Direction);
            viewport.Camera = camera;
            //Now to construct the light:
            light = getLight(Colors.White,focussedCamera.Direction);
            ModelVisual3D visual = new ModelVisual3D();
            visual.Content = light;
            viewport.Children.Add(visual);
            ModelVisual3D visual2 = new ModelVisual3D();
            //Now add in the robot too!
            updateMotors();
            outerModel = new Model3DGroup();
            outerModel.Children.Add(robot.getRobot());
            currentMatTransform = (MatrixTransform3D)MatrixTransform3D.Identity;
            TranslateTransform3D trans = new TranslateTransform3D();
            outerModel.Children[0] = Transforms.applyTransform((Model3DGroup)outerModel.Children[0],currentMatTransform);
            visual2.Content = outerModel;
            viewport.Children.Add(visual2);
            //Phew! That should be it...
            viewport.ClipToBounds = true;
        }