private Tuple <Material, Media3D.Transform3D> LoadBeetle()
        {
            var    data = ReadDat("stagbeetle208x208x123.dat", out var width, out var height, out var depth);
            var    m    = new VolumeTextureDiffuseMaterial();
            ushort max  = data.Max();

            uint[] histogram = new uint[max + 1];

            float[] fdata = new float[data.Length];

            for (int i = 0; i < data.Length; ++i)
            {
                fdata[i] = (float)data[i] / max;
                histogram[data[i]]++;
            }
            var transferMap = GetTransferFunction(histogram, data.Length, 1, 0.0001f);
            var gradients   = VolumeDataHelper.GenerateGradients(fdata, width, height, depth, 1);

            VolumeDataHelper.FilterNxNxN(gradients, width, height, depth, 3);
            m.Texture = new VolumeTextureGradientParams(gradients, width, height, depth);
            m.Color   = new Color4(0, 1, 0, 0.4f);
            var transform = new Media3D.ScaleTransform3D(1, 1, 1);

            transform.Freeze();
            m.Freeze();
            return(new Tuple <Material, Media3D.Transform3D>(m, transform));
        }
        private Tuple <Material, Media3D.Transform3D> LoadSkull()
        {
            var m    = new VolumeTextureDiffuseMaterial();
            var data = VolumeTextureRawDataMaterialCore.LoadRAWFile("male128x256x256.raw", 128, 256, 256);

            m.Texture     = ProcessData(data.VolumeTextures, data.Width, data.Height, data.Depth, out var transferMap);
            m.Color       = new Color4(0.6f, 0.6f, 0.6f, 1f);
            m.TransferMap = transferMap;
            m.Freeze();
            var rotate    = Matrix.RotationAxis(new Vector3(1, 0, 0), (float)Math.PI);
            var transform = new Media3D.MatrixTransform3D(rotate.ToMatrix3D());

            transform.Freeze();
            return(new Tuple <Material, Media3D.Transform3D>(m, transform));
        }
Beispiel #3
0
        private Tuple <Material, Media3D.Transform3D> LoadTeapot()
        {
            //var m = new VolumeTextureRawDataMaterial();
            //m.Texture = VolumeTextureRawDataMaterialCore.LoadRAWFile("teapot256x256x178.raw", 256, 256, 178);
            var m    = new VolumeTextureDiffuseMaterial();
            var data = VolumeTextureRawDataMaterialCore.LoadRAWFile("teapot256x256x178.raw", 256, 256, 178);

            m.Texture     = ProcessData(data.VolumeTextures, data.Width, data.Height, data.Depth, out var transferMap);
            m.Color       = new Color4(1, 1, 1, 0.4f);
            m.TransferMap = transferMap;
            m.Freeze();
            var transform = new Media3D.RotateTransform3D(new Media3D.AxisAngleRotation3D(new Vector3D(1, 0, 0), 180));

            transform.Freeze();
            return(new Tuple <Material, Media3D.Transform3D>(m, transform));
        }
        private Tuple <Material, Media3D.Transform3D> LoadTeapot()
        {
            //var m = new VolumeTextureRawDataMaterial();
            //m.Texture = VolumeTextureRawDataMaterialCore.LoadRAWFile("teapot256x256x178.raw", 256, 256, 178);
            var m    = new VolumeTextureDiffuseMaterial();
            var data = VolumeTextureRawDataMaterialCore.LoadRAWFile("teapot256x256x178.raw", 256, 256, 178);

            m.Texture     = ProcessData(data.VolumeTextures, data.Width, data.Height, data.Depth, out var transferMap);
            m.Color       = new Color4(1, 1, 1, 0.4f);
            m.TransferMap = transferMap;
            m.Freeze();
            var scale  = Matrix.Scaling(2, 2, 178 / 256f * 2);
            var rotate = Matrix.RotationAxis(new Vector3(1, 0, 0), (float)Math.PI);
            var t      = new Media3D.MatrixTransform3D((scale * rotate).ToMatrix3D());

            t.Freeze();
            return(new Tuple <Material, Media3D.Transform3D>(m, t));
        }