Exemplo n.º 1
0
        // Add a random path.
        private void CreateRandomPath()
        {
            var path  = new Path3F();
            var point = new Vector3F(0, 0, 0);

            path.Add(new PathKey3F
            {
                Interpolation = SplineInterpolation.CatmullRom,
                Parameter     = 0,
                Point         = point
            });
            for (int i = 1; i < 10; i++)
            {
                point += RandomHelper.Random.NextQuaternionF().Rotate(new Vector3F(0, 0.5f, 0));
                path.Add(new PathKey3F
                {
                    Interpolation = SplineInterpolation.CatmullRom,
                    Parameter     = i,
                    Point         = point
                });
            }
            var pathFigure = new PathFigure3F();

            pathFigure.Segments.Add(path);

            var pathLineNode = new FigureNode(pathFigure)
            {
                Name              = "RandomPath",
                PoseLocal         = new Pose(new Vector3F(4, 1, 2)),
                StrokeThickness   = 3,
                StrokeColor       = new Vector3F(0.5f, 0.3f, 1),
                StrokeAlpha       = 1f,
                DashInWorldSpace  = true,
                StrokeDashPattern = new Vector4F(10, 1, 1, 1) / 100,
            };

            _scene.Children.Add(pathLineNode);
        }
Exemplo n.º 2
0
        // Add a grid with thick major grid lines and thin stroked minor grid lines.
        private void CreateGrid()
        {
            var majorGridLines = new PathFigure3F();

            for (int i = 0; i <= 10; i++)
            {
                majorGridLines.Segments.Add(new LineSegment3F
                {
                    Point1 = new Vector3F(-5, 0, -5 + i),
                    Point2 = new Vector3F(5, 0, -5 + i),
                });
                majorGridLines.Segments.Add(new LineSegment3F
                {
                    Point1 = new Vector3F(-5 + i, 0, -5),
                    Point2 = new Vector3F(-5 + i, 0, 5),
                });
            }

            var minorGridLines = new PathFigure3F();

            for (int i = 0; i < 10; i++)
            {
                minorGridLines.Segments.Add(new LineSegment3F
                {
                    Point1 = new Vector3F(-5, 0, -4.5f + i),
                    Point2 = new Vector3F(5, 0, -4.5f + i),
                });
                minorGridLines.Segments.Add(new LineSegment3F
                {
                    Point1 = new Vector3F(-4.5f + i, 0, -5),
                    Point2 = new Vector3F(-4.5f + i, 0, 5),
                });
            }

            var majorLinesNode = new FigureNode(majorGridLines)
            {
                Name            = "Major grid lines",
                PoseLocal       = Pose.Identity,
                StrokeThickness = 2,
                StrokeColor     = new Vector3F(0.1f),
                StrokeAlpha     = 1f,
            };
            var minorLinesNode = new FigureNode(minorGridLines)
            {
                Name              = "Minor grid lines",
                PoseLocal         = Pose.Identity,
                StrokeThickness   = 1,
                StrokeColor       = new Vector3F(0.1f),
                StrokeAlpha       = 1f,
                DashInWorldSpace  = true,
                StrokeDashPattern = new Vector4F(10, 4, 0, 0) / 200,
            };
            var gridNode = new SceneNode
            {
                Name      = "Grid",
                Children  = new SceneNodeCollection(),
                PoseLocal = new Pose(new Vector3F(0, -0.5f, 0)),
            };

            gridNode.Children.Add(majorLinesNode);
            gridNode.Children.Add(minorLinesNode);
            _scene.Children.Add(gridNode);
        }