public override void Do(IDemoChartControl chartControl)
        {
            var random = new Random(DateTime.Now.Millisecond);

            // Generate demo structured surface.
            Vector3F[] positions = DemoHelper.GenerateSinPoints(size);

            // Randomly remove points from that grid for irregular grid, only 30% will be taken from original grid.
            Vector3F[] irregularPositions = positions.Where(t => random.NextDouble() > 0.7).ToArray();
            // Surface data presentation creation.
            var surface = new ValueSurface
            {
                // Reader can be reused and we can create several presentations for 1 reader.
                // Note: this reader provider default implementation, so feel free to implement your own logic.
                Reader = new IrregularValueSurfaceDataReader(
                    irregularPositions,                                                           // Define surface points.
                    DemoHelper.ExtractZValues(irregularPositions, out OneAxisBounds valueBounds), // Surface values, here they are equal to Z values .
                    2,                                                                            // As data is irregular in 2D space we should specify exclude axis index for triangulation.
                    valueBounds),                                                                 //Value axis bounds.
                // Setup presentation option.
                PresentationType = ValueSurfacePresentationType.SolidAndWireframe,
                // Set name.
                Name = "Surface"
            };

            // Setup chart options.
            chartControl.Axes.IsAxes3DVisible            = true;
            chartControl.ContextView.Camera2D.Projection = Projection2DTypes.XPosYPos;

            // Set data source.
            chartControl.DataSource = surface;
        }
    }
        public override void Do(IDemoChartControl chartControl)
        {
            // Generate positions.
            Vector3F[] positions = DemoHelper.GenerateSinPoints(MapSize);

            // Creation of surface data presentation.
            var surface = new ValueSurface
            {
                // Data reader approach is used to improve performance for big data sets and their updates.
                Reader = new StructuredValueSurfaceDataReader(
                    positions,                                                           // Surface positions.
                    DemoHelper.ExtractZValues(positions, out OneAxisBounds valueBounds), // Surface values, for demo purposes values are extracted from Z position component, but in real world they are independent, size of array should be the same as for positions.
                    MapSize,                                                             // Width and height are required for triangulation of structured grid.
                    MapSize,
                    valueBounds),                                                        //Bounds of value axes.
                // Set presentation option.
                PresentationType = ValueSurfacePresentationType.SolidAndWireframe,
                // Set name.
                Name = "Surface"
            };

            // Setup chart options.
            chartControl.Axes.IsAxes3DVisible = true;

            // Setup chart data source.
            chartControl.DataSource = surface;
        }
    }
        public override void Do(IDemoChartControl chartControl)
        {
            // Generate vertex positions.
            Vector3F[] positions = DemoHelper.GenerateSinPoints(Resolution);

            // Generates initial values (for this case extract it as Z coordinates of positions).
            initialValues = DemoHelper.ExtractZValues(positions, out OneAxisBounds valueRange);

            // Current values storage.
            var currentValues = new float[initialValues.Length];

            Array.Copy(initialValues, currentValues, initialValues.Length);

            // Create value surface data reader.
            var reader = new StructuredValueSurfaceDataReader(positions, currentValues, Resolution, Resolution, valueRange);

            // Create value surface presentation data.
            var valueSurface = new ValueSurface
            {
                // Set data reader.
                Reader = reader,
                // Set presentation type.
                PresentationType = ValueSurfacePresentationType.Solid,
                // Set name.
                Name = "Surface"
            };

            // Setup chart options.
            chartControl.Axes.IsAxes3DVisible            = true;
            chartControl.ContextView.Mode2D              = false;
            chartControl.ContextView.Camera2D.Projection = Projection2DTypes.XPosYPos;

            // Set chart data source.
            chartControl.DataSource = valueSurface;

            // Start animation.
            animationHelper.Start(
                argument => argument,
                argument =>
            {
                // Generates new values and update reader with it.
                float[] randomizedValues = GenerateValues(argument, reader.ValueRange);
                reader.UpdateValues(randomizedValues, 0, reader.VertexCount, 0);
            },
                0, 0.025f * ((float)UpdateInterval / 16), UpdateInterval);
        }
示例#4
0
            public override ColoredMesh GetMesh()
            {
                // Here we gonna generate mesh with duplicated triangles to avoid vertex color interpolation.
                Vector3F[] initialPositions = DemoHelper.GenerateSinPoints(Resolution);
                int[]      initialIndices   = GridHelper.GetStructuredTriangleListIndices(0, Resolution, Resolution, 1);

                var vertices = new List <Vector3F>();
                var normals  = new List <Vector3F>();
                var indices  = new List <int>();
                var colors   = new List <Vector3F>();

                int index = 0;

                void SubmitVertex(Vector3F position, Vector3F normal, Vector3F color)
                {
                    vertices.Add(position);
                    normals.Add(normal);
                    colors.Add(color);
                    indices.Add(index++);
                }

                int triangleCount = initialIndices.Length / 3;

                for (int i = 0; i < triangleCount; i++)
                {
                    Vector3F color = DemoHelper.GetRandomColor();
                    Vector3F
                        p0          = initialPositions[initialIndices[i * 3]],
                        p1          = initialPositions[initialIndices[i * 3 + 1]],
                        p2          = initialPositions[initialIndices[i * 3 + 2]];
                    Vector3F normal = NormalProcessor.GetNormal(p0, p1, p2);

                    SubmitVertex(p0, normal, color);
                    SubmitVertex(p1, normal, color);
                    SubmitVertex(p2, normal, color);
                }

                int[] indicesArray = indices.ToArray();
                return(new ColoredMesh(vertices.ToArray(), colors.ToArray(), normals.ToArray(),
                                       indicesArray, GridHelper.GetWireframeIndices(indicesArray)));
            }
示例#5
0
        public override void Do(IDemoChartControl chartControl)
        {
            // We take the same data as for surfaces for demo purposes, in current case it contains redundant x, y values.
            Vector3F[] xyzPoints = DemoHelper.GenerateSinPoints(Resolution);

            // Extract only values from z array.
            float[] values = DemoHelper.ExtractZValues(xyzPoints);

            // Create geometry.
            var geometry = new RectTextureGeometry
            {
                Origin     = Vector3F.Zero,
                DirectionX = Vector3F.UnitX,
                DirectionY = Vector3F.UnitY,
                Size       = new Vector2F(1f, 1f)
            };

            var rasterData = new ValueRasterData
            {
                // Linear interpolation.
                InterpolationType = RasterDataInterpolationType.Linear,
                // Float data reader specification (values, data stride/width and value axis bounds).
                Reader = new FloatIntensityImage2DReader(values, Resolution, new OneAxisBounds(-1f, 1f)),
                // Set geometry.
                Geometry = geometry,
                // Set name.
                Name = "Surface"
            };

            // Setup view settings.
            chartControl.ContextView.Mode2D = true;
            chartControl.ContextView.Camera2D.Projection = Projection2DTypes.XPosYPos;

            // Set chart data source.
            chartControl.DataSource = rasterData;
        }