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


C# Controls.Viewport3D類代碼示例

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


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

示例1: Create3DViewPort

        private void Create3DViewPort()
        {
            var hvp3d = new HelixViewport3D();
            Viewport3D vp3d = new Viewport3D();
            var lights = new DefaultLights();
            var tp = new Teapot();

            hvp3d.Children.Add(lights);
            hvp3d.Children.Add(tp);

            vp3d = hvp3d.Viewport;
            tata.Children.Add(vp3d); // comenter ca pour test

            /* MEGA TEST DE L'ESPACE SUBSAHARIEN */

            RenderTargetBitmap bmp = new RenderTargetBitmap(800, 800, 96, 96, PixelFormats.Pbgra32);
            var rect = new Rect(0, 0, 800, 800);
            vp3d.Measure(new Size(800, 800));
            vp3d.Arrange(rect);
            vp3d.InvalidateVisual();
            
            bmp.Render(vp3d);

            PngBitmapEncoder png = new PngBitmapEncoder();
            png.Frames.Add(BitmapFrame.Create(bmp));

            String filepath = "C:\\Users\\Remi\\Desktop\\canardmasque.png";
            using (Stream stm = File.Create(filepath))
            {
                png.Save(stm);
            }
        }
開發者ID:remi-hernandez,項目名稱:renderHelixViewPort3d,代碼行數:32,代碼來源:MainWindow.xaml.cs

示例2: AddVehiclePoints

        private ScreenSpaceLines3D AddVehiclePoints(Viewport3D mainViewport, Point3D[] pointsArray)
        {
            ScreenSpaceLines3D wireVehicle=new ScreenSpaceLines3D();
            Color color = Colors.Red;
            const int width = 1;

            wireVehicle.Thickness = width;
            wireVehicle.Color = color;
            wireVehicle.Points.Add(pointsArray[0]);
            wireVehicle.Points.Add(pointsArray[1]);
            wireVehicle.Points.Add(pointsArray[1]);
            wireVehicle.Points.Add(pointsArray[2]);
            wireVehicle.Points.Add(pointsArray[2]);
            wireVehicle.Points.Add(pointsArray[3]);
            wireVehicle.Points.Add(pointsArray[3]);
            wireVehicle.Points.Add(pointsArray[0]);
            wireVehicle.Points.Add(pointsArray[4]);
            wireVehicle.Points.Add(pointsArray[5]);
            wireVehicle.Points.Add(pointsArray[5]);
            wireVehicle.Points.Add(pointsArray[6]);
            wireVehicle.Points.Add(pointsArray[6]);
            wireVehicle.Points.Add(pointsArray[7]);
            wireVehicle.Points.Add(pointsArray[7]);
            wireVehicle.Points.Add(pointsArray[4]);
            wireVehicle.Points.Add(pointsArray[0]);
            wireVehicle.Points.Add(pointsArray[4]);
            wireVehicle.Points.Add(pointsArray[1]);
            wireVehicle.Points.Add(pointsArray[5]);
            wireVehicle.Points.Add(pointsArray[2]);
            wireVehicle.Points.Add(pointsArray[6]);
            wireVehicle.Points.Add(pointsArray[3]);
            wireVehicle.Points.Add(pointsArray[7]);
            return wireVehicle;
        }
開發者ID:RadSt,項目名稱:WPF-App-For-Ref,代碼行數:34,代碼來源:Calculation3D.cs

示例3: render

        public GeometryModel3D[] render()
        {
            Model3DGroup modelGroup     = new Model3DGroup();
            Viewport3D visualisation    = new Viewport3D();
            ModelVisual3D modelsVisual  = new ModelVisual3D();
            int depthPoint              = 0;

            //Setup viewport environment
            init = new ViewportCalibrator(this.cp);
            visualisation = init.setupViewport(init.setupCamera(), this.cp.ActualHeight, this.cp.ActualWidth);

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

            //Add mesh to visualisation and viewport/canvas
            modelGroup.Children.Add(init.setupDirectionalLights(Colors.White));
            modelsVisual.Content = modelGroup;
            visualisation.Children.Add(modelsVisual);
            cp.Children.Add(visualisation);

            Canvas.SetTop(visualisation, 0);
            Canvas.SetLeft(visualisation, 0);

            return pts;
        }
開發者ID:robinj,項目名稱:parse-client,代碼行數:34,代碼來源:TriangularPointCloud.cs

示例4: JuegoPiano

        public JuegoPiano(Viewport3D viewport3D)
        {
            Jugadores = new Dictionary<int,Jugador>();
            //Se inicializa el teclado con el número de octavas
            Teclado = new Teclado(2);
            Teclado.Draw3D(viewport3D);
            this.Viewport3D = viewport3D;
            //init WS
            pianoWSDuplexClient = new PianoWSDuplexClient();
            pianoWSDuplexClient.SetEjecutarNotaAction(delegate(string nota) {
                Tecla tecla = Teclado.Teclas[nota];
                tecla.UpdatePosition(new Point3D(0, - tecla.Dimensiones.Alto, 0));
                tecla.Sonar();

                //Timer para regresar la tecla a su lugar original
                DispatcherTimer dispatcherTimer = new DispatcherTimer();
                dispatcherTimer.Tick += new EventHandler((Action<object, EventArgs>)delegate(object sender, EventArgs e)
                {
                    tecla.UpdatePosition(new Point3D(0, 0, 0));
                    (sender as DispatcherTimer).Stop();
                });
                dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1);
                dispatcherTimer.Start();
            });
        }
開發者ID:hongo2001,項目名稱:PianoVirtual-Kinect,代碼行數:25,代碼來源:JuegoPiano.cs

示例5: PointVisualizer

        // These are used by the 2 constructor overloads that don't take int
        //private ModelVisual3D _dotModel = null;
        //private ModelVisual3D _velocityModel = null;
        //private ModelVisual3D _accelerationModel = null;

        #endregion

        #region Constructor

        public PointVisualizer(Viewport3D viewport, SharedVisuals sharedVisuals)
        {
            _viewport = viewport;
            _sharedVisuals = sharedVisuals;

            _items = new ItemProperties[3];

            // Position
            _items[INDEX_POSITION] = new ItemProperties();
            _items[INDEX_POSITION].IsPoint = true;
            _items[INDEX_POSITION].Color = Colors.Magenta;
            _items[INDEX_POSITION].SizeMultiplier = 1d;

            // Velocity
            _items[INDEX_VELOCITY] = new ItemProperties();
            _items[INDEX_VELOCITY].IsPoint = false;
            _items[INDEX_VELOCITY].Color = Colors.Chartreuse;
            _items[INDEX_VELOCITY].SizeMultiplier = 1d;

            // Acceleration
            _items[INDEX_ACCELERATION] = new ItemProperties();
            _items[INDEX_ACCELERATION].IsPoint = false;
            _items[INDEX_ACCELERATION].Color = Colors.Gold;
            _items[INDEX_ACCELERATION].SizeMultiplier = 1d;
        }
開發者ID:charlierix,項目名稱:AsteroidMiner,代碼行數:34,代碼來源:PointVisualizer.cs

示例6: Export_SimpleModel_ValidOutput

        public void Export_SimpleModel_ValidOutput()
        {
            string path = "temp.x3d";

            var runner = new CrossThreadTestRunner();
            runner.RunInSTA(
              delegate
              {
                  Console.WriteLine(Thread.CurrentThread.GetApartmentState());

                  var vp = new Viewport3D();
                  vp.Camera = CameraHelper.CreateDefaultCamera();
                  vp.Width = 1280;
                  vp.Height = 720;
                  vp.Children.Add(new DefaultLightsVisual3D());
                  var box = new BoxVisual3D();
                  box.UpdateModel();
                  vp.Children.Add(box);

                  using (var e = new X3DExporter(path))
                  {
                      e.Export(vp);
                  }
              });

            var result = Validate(path);
            Assert.IsNull(result, result);
        }
開發者ID:XiBeichuan,項目名稱:hydronumerics,代碼行數:28,代碼來源:X3DExporterTests.cs

示例7: Point3DtoPoint2D

 /// <summary>
 /// Code adapted from HelixToolkit.Wpf.Viewport3DHelper.Point3DtoPoint2D obtained from http://github.com/helix-toolkit/helix-toolkit
 /// License: helix-toolkit.LICENSE.txt 
 /// </summary>
 /// <param name="viewport"></param>
 /// <param name="point"></param>
 /// <returns></returns>
 public static Point Point3DtoPoint2D(Viewport3D viewport, Point3D point)
 {
     var matrix = GetTotalTransform(viewport);
     var pointTransformed = matrix.Transform(point);
     var pt = new Point(pointTransformed.X, pointTransformed.Y);
     return pt;
 }
開發者ID:node-net,項目名稱:Node.Net,代碼行數:14,代碼來源:Viewport3D.Extension.cs

示例8: FlipTransition

        public FlipTransition()
        {
            _viewport = TransitionResources["3DCube"] as Viewport3D;

            _rootModel = (_viewport.Children[0] as ModelVisual3D).Content as Model3DGroup;
            _cubeModelContainer = _rootModel.Children[1] as Model3DGroup;
        }
開發者ID:slytsal,項目名稱:nmtmdz,代碼行數:7,代碼來源:FlipTransition.cs

示例9: StereoControl

 public StereoControl()
 {
     viewport = new Viewport3D();
     Camera = CameraHelper.CreateDefaultCamera();
     Camera.Changed += Camera_Changed;
     Children = new ObservableCollection<Visual3D>();
 }
開發者ID:XiBeichuan,項目名稱:hydronumerics,代碼行數:7,代碼來源:StereoControl.cs

示例10: Export

        /// <summary>
        /// Exports the specified viewport.
        /// </summary>
        /// <param name="viewport">
        /// The viewport.
        /// </param>
        public void Export(Viewport3D viewport)
        {
            int m = this.OversamplingMultiplier;

            var background = this.Background;
            if (background == null)
            {
                background = Brushes.Transparent;
            }

            var bmp = Viewport3DHelper.RenderBitmap(viewport, background, m);
            BitmapEncoder encoder;
            string ext = Path.GetExtension(this.FileName);
            switch (ext.ToLower())
            {
                case ".jpg":
                    var jpg = new JpegBitmapEncoder();
                    jpg.Frames.Add(BitmapFrame.Create(bmp));
                    encoder = jpg;
                    break;
                case ".png":
                    var png = new PngBitmapEncoder();
                    png.Frames.Add(BitmapFrame.Create(bmp));
                    encoder = png;
                    break;
                default:
                    throw new InvalidOperationException("Not supported file format.");
            }

            using (Stream stm = File.Create(this.FileName))
            {
                encoder.Save(stm);
            }
        }
開發者ID:sivarajankumar,項目名稱:dentalsmile,代碼行數:40,代碼來源:BitmapExporter.cs

示例11: drawTor

        public static void drawTor(Point3D center, double R, double r, int N, int n, Color color, Viewport3D mainViewport)
        {
            if (n < 2 || N < 2)
              {
            return;
              }

              Model3DGroup tor = new Model3DGroup();
              Point3D[,] points = new Point3D[N, n];

              for (int i = 0; i < N; i++)
              {
            for (int j = 0; j < n; j++)
            {
              points[i, j] = getPositionTor(R, r, i * 360 / (N - 1), j * 360 / (n - 1));
              points[i, j] += (Vector3D)center;
            }
              }

              Point3D[] p = new Point3D[4];
              for (int i = 0; i < N - 1; i++)
              {
            for (int j = 0; j < n - 1; j++)
            {
              p[0] = points[i, j];
              p[1] = points[i + 1, j];
              p[2] = points[i + 1, j + 1];
              p[3] = points[i, j + 1];
              drawTriangle(p[0], p[1], p[2], color, mainViewport);
              drawTriangle(p[2], p[3], p[0], color, mainViewport);

            }
              }
        }
開發者ID:Mexahoid,項目名稱:CSF,代碼行數:34,代碼來源:LoTVLogics.cs

示例12: ExplosionWithVisual

 public ExplosionWithVisual(Point3D centerPoint, double waveSpeed, double forceAtCenter, double maxRadius, Viewport3D viewport, double visualStartRadius)
     : base(centerPoint, waveSpeed, forceAtCenter, maxRadius)
 {
     _viewport = viewport;
     _visualStartRadius = visualStartRadius;
     CreateVisual();
 }
開發者ID:charlierix,項目名稱:AsteroidMiner,代碼行數:7,代碼來源:Explosion.cs

示例13: 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

示例14: Draw

 public void Draw(Viewport3D mainViewport)
 {
     foreach (PianoKey pk in _PianoKeys)
     {
         pk.Draw(mainViewport);
     }
 }
開發者ID:hempnall,項目名稱:pianokeyboard,代碼行數:7,代碼來源:Piano.cs

示例15: ExportSimpleModel

        /// <summary>
        /// Exports a simple model in a STA.
        /// </summary>
        /// <param name="e">The exporter.</param>
        /// <param name="stream">The stream.</param>
        protected void ExportSimpleModel(IExporter e, Stream stream)
        {
            Exception exception = null;
            CrossThreadTestRunner.RunInSTA(
                () =>
                {
                    var vp = new Viewport3D { Camera = CameraHelper.CreateDefaultCamera(), Width = 1280, Height = 720 };
                    vp.Children.Add(new DefaultLights());
                    var box = new BoxVisual3D();
                    box.UpdateModel();
                    vp.Children.Add(box);
                    try
                    {
                        e.Export(vp, stream);
                    }
                    catch (Exception ex)
                    {
                        exception = ex;
                    }
                });

            if (exception != null)
            {
                throw exception;
            }
        }
開發者ID:JeremyAnsel,項目名稱:helix-toolkit,代碼行數:31,代碼來源:ExporterTests.cs


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