示例#1
0
        protected void CreateMesh(IEnumerable <double> x, IEnumerable <double> y, IEnumerable <double> z, int xLength, int yLength)
        {
            lengthU = xLength;
            lengthV = yLength;
            bounds  = new Cuboid(x.Min(), y.Min(), z.Min(), x.Max(), y.Max(), z.Max());
            Cuboid modelBounds = new Cuboid(new System.Windows.Media.Media3D.Point3D(-10, -10, -10), new System.Windows.Media.Media3D.Point3D(10, 10, 10));

            UpdateModelVertices(x, y, z, xLength, yLength);
            CreateVertsAndInds();
            colourMap        = new ColourMap(ColourMapType.HSV, 256);
            colourMapIndices = FalseColourImage.IEnumerableToIndexArray(z, xLength, yLength, 256);
            SetColorFromIndices();
            colourMapUpdateTimer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(0.2)
            };
            colourMapUpdateTimer.Tick += new EventHandler(colourMapUpdateTimer_Tick);

            lights = new List <SharpDX.Direct3D9.Light>();
            SharpDX.Direct3D9.Light light = new SharpDX.Direct3D9.Light()
            {
                Type = LightType.Directional
            };
            light.Diffuse   = new Color4(0.4f, 0.4f, 0.4f, 1.0f);
            light.Direction = new Vector3(0.3f, 0.3f, -0.7f);
            light.Specular  = new Color4(0.05f, 0.05f, 0.05f, 1.0f);
            lights.Add(light);

            light = new SharpDX.Direct3D9.Light()
            {
                Type = LightType.Directional
            };
            light.Diffuse   = new Color4(0.4f, 0.4f, 0.4f, 1.0f);
            light.Direction = new Vector3(-0.3f, -0.3f, -0.7f);
            light.Specular  = new Color4(0.05f, 0.05f, 0.05f, 1.0f);
            lights.Add(light);

            material          = new SharpDX.Direct3D9.Material();
            material.Specular = new Color4(0.0f, 0.0f, 0.0f, 1.0f);
            material.Diffuse  = new Color4(0.0f, 0.0f, 0.0f, 1.0f);
            material.Ambient  = new Color4(0.0f, 0.0f, 0.0f, 1.0f);
            material.Power    = 10;
        }
示例#2
0
        protected void CreateMeshILArray(ILArray <double> x, ILArray <double> y, ILArray <double> z)
        {
            bounds  = new Cuboid(x.MinValue, y.MinValue, z.MinValue, x.MaxValue, y.MaxValue, z.MaxValue);
            lengthU = x.Dimensions[0];
            lengthV = x.Dimensions[1];
            ILArray <double> xs, ys, zs;

            if (x.IsReference)
            {
                xs = x.Clone() as ILArray <double>;
            }
            else
            {
                xs = x;
            }
            if (y.IsReference)
            {
                ys = y.Clone() as ILArray <double>;
            }
            else
            {
                ys = y;
            }
            if (z.IsReference)
            {
                zs = z.Clone() as ILArray <double>;
            }
            else
            {
                zs = z;
            }
            //if (x.IsReference || y.IsReference || z.IsReference) throw new Exception("x, y and z must be solid arrays");
            double[] xa          = xs.InternalArray4Experts;
            double[] ya          = ys.InternalArray4Experts;
            double[] za          = zs.InternalArray4Experts;
            Cuboid   modelBounds = new Cuboid(new System.Windows.Media.Media3D.Point3D(-10, -10, -10), new System.Windows.Media.Media3D.Point3D(10, 10, 10));

            UpdateModelVertices(xa, ya, za, lengthU, lengthV);
            CreateVertsAndInds();
            colourMap        = new ColourMap(ColourMapType.Jet, 256);
            colourMapIndices = FalseColourImage.IEnumerableToIndexArray(za, lengthU, lengthV, 256);
            SetColorFromIndices();
        }