當前位置: 首頁>>代碼示例>>C#>>正文


C# Media3D.PerspectiveCamera類代碼示例

本文整理匯總了C#中System.Windows.Media.Media3D.PerspectiveCamera的典型用法代碼示例。如果您正苦於以下問題:C# PerspectiveCamera類的具體用法?C# PerspectiveCamera怎麽用?C# PerspectiveCamera使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PerspectiveCamera類屬於System.Windows.Media.Media3D命名空間,在下文中一共展示了PerspectiveCamera類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: defineCamera

 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;
 }
開發者ID:HDRoby,項目名稱:3DOFLeg,代碼行數:7,代碼來源:MainWindow.xaml.cs

示例2: SyncCamera

 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;
 }
開發者ID:charlierix,項目名稱:AsteroidMiner,代碼行數:7,代碼來源:ShipCameraTester.xaml.cs

示例3: VisualTree3DView

		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);
		}
開發者ID:JonGonard,項目名稱:snoopwpf,代碼行數:35,代碼來源:VisualTree3DView.cs

示例4: ViewportOffline

                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;
                }
開發者ID:charlierix,項目名稱:AsteroidMiner,代碼行數:27,代碼來源:CameraPool.cs

示例5: ItemSelectDragLogic

 public ItemSelectDragLogic(Map map, PerspectiveCamera camera, Viewport3D viewport, UIElement visual)
 {
     _map = map;
     _camera = camera;
     _viewport = viewport;
     _visual = visual;
 }
開發者ID:charlierix,項目名稱:AsteroidMiner,代碼行數:7,代碼來源:ItemSelectDragLogic.cs

示例6: CameraHelper

 public CameraHelper(Player player, PerspectiveCamera camera, PerspectiveCamera cameraMap, MinimapHelper blips)
 {
     _player = player;
     _camera = camera;
     _cameraMap = cameraMap;
     _blips = blips;
 }
開發者ID:charlierix,項目名稱:AsteroidMiner,代碼行數:7,代碼來源:CameraHelper.cs

示例7: Camera2D

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

            Focused = true;
        }
開發者ID:bakerj76,項目名稱:RogueTyper,代碼行數:7,代碼來源:Camera2D.cs

示例8: StructureControl

        /// <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();
        }
開發者ID:alkampfergit,項目名稱:BaktunShell,代碼行數:63,代碼來源:StructureControl.cs

示例9: TrackBallRoam

        public TrackBallRoam(PerspectiveCamera camera)
        {
            _camera = camera;

            _autoscroll = new AutoScrollEmulator();
            _autoscroll.AutoScroll += new AutoScrollHandler(Autoscroll_AutoScroll);
            _autoscroll.CursorChanged += new EventHandler(Autoscroll_CursorChanged);
        }
開發者ID:charlierix,項目名稱:AsteroidMiner,代碼行數:8,代碼來源:TrackBall.cs

示例10: TrackballGrabber

        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
        }
開發者ID:charlierix,項目名稱:AsteroidMiner,代碼行數:57,代碼來源:TrackballGrabber.cs

示例11: CameraManipulator

        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));
        }
開發者ID:oleksadobrianskyy,項目名稱:ModelViewer3D,代碼行數:9,代碼來源:CameraManipulator.cs

示例12: UpdateCamera

 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");
 }
開發者ID:kobush,項目名稱:ManagedOpenNI,代碼行數:9,代碼來源:CameraPropertyView.xaml.cs

示例13: AddCamera

		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;
		}
開發者ID:mnisl,項目名稱:OD,代碼行數:10,代碼來源:Wpf3dControl.xaml.cs

示例14: WiggleView3D

        public WiggleView3D()
        {
            InitializeComponent();

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

            CompositionTarget.Rendering += CompositionTarget_Rendering;
            UpdateTimer();
            watch.Start();
        }
開發者ID:XiBeichuan,項目名稱:hydronumerics,代碼行數:11,代碼來源:WiggleView3D.xaml.cs

示例15: Reset

 /// <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;
 }
開發者ID:XiBeichuan,項目名稱:hydronumerics,代碼行數:15,代碼來源:CameraHelper.cs


注:本文中的System.Windows.Media.Media3D.PerspectiveCamera類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。