Esempio n. 1
0
        // highlight the selection
        public override void HighlightSelection(System.Windows.Media.Media3D.MeshGeometry3D meshGeometry, System.Windows.Media.Color selectColor)
        {
            int nDotNo = GetDataNo();

            if (nDotNo == 0)
            {
                return;
            }

            Point mapPt;

            for (int i = 0; i < nDotNo; i++)
            {
                if (m_vertices[i].selected)
                {
                    mapPt = TextureMapping.GetMappingPosition(selectColor, true);
                }
                else
                {
                    mapPt = TextureMapping.GetMappingPosition(m_vertices[i].color, true);
                }
                int nMin = m_vertices[i].nMinI;
                meshGeometry.TextureCoordinates[nMin] = mapPt;
            }
        }
Esempio n. 2
0
        public void Draw(Func <Vertex3D, double> calculateZ, int nGridNo)
        {
            int nXNo = nGridNo;
            int nYNo = nGridNo;

            // 1. set the surface grid
            _3dChartData = new UniformSurfaceChart3D();
            ((UniformSurfaceChart3D)_3dChartData).SetGrid(nXNo, nYNo, -(float)Settings.Radius.Value, (float)Settings.Radius.Value, -(float)Settings.Radius.Value, (float)Settings.Radius.Value);

            // 2. set surface chart z value
            double xC      = _3dChartData.XCenter();
            double yC      = _3dChartData.YCenter();
            int    nVertNo = _3dChartData.GetDataNo();

            for (int i = 0; i < nVertNo; i++)
            {
                _3dChartData[i].z = (float)calculateZ(_3dChartData[i]);
            }
            UpdateResultTable();
            _3dChartData.GetDataRange();
            //_3dChartData.SetAxes();

            // 3. set the surface chart color according to z vaule
            double zMin = _3dChartData.ZMin();
            double zMax = _3dChartData.ZMax();

            for (int i = 0; i < nVertNo; i++)
            {
                Vertex3D vert = _3dChartData[i];
                double   h    = (vert.z - zMin) / (zMax - zMin);

                Color color = TextureMapping.PseudoColor(h);
                _3dChartData[i].color = color;
            }

            // 4. Get the Mesh3D array from surface chart
            ArrayList meshs = ((UniformSurfaceChart3D)_3dChartData).GetMeshes();

            // 5. display vertex no and triangle no of this surface chart
            UpdateModelSizeInfo(meshs);

            // 6. Set the model display of surface chart
            Model3D  model3d      = new Model3D();
            Material backMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Gray));

            _chartModelIndex = model3d.UpdateModel(meshs, backMaterial, _chartModelIndex, this.mainViewport);

            // 7. set projection matrix, so the data is in the display region
            float xMin = _3dChartData.XMin();
            float xMax = _3dChartData.XMax();

            _transformMatrix.CalculateProjectionMatrix(xMin, xMax, xMin, xMax, zMin, zMax, 0.5);
            TransformChart();
        }