public static ImageTexture FromMRC(string path)
        {
            ImageTexture NewTexture = new ImageTexture();

            HeaderMRC Header = HeaderMRC.ReadFromFile(path) as HeaderMRC;
            NewTexture.Size = Header.Dimensions;
            NewTexture.Scale = new Vector2(Header.Pixelsize.X, Header.Pixelsize.Y);
            NewTexture.Offset = new Vector2(Header.Origin.X, Header.Origin.Y);

            float[] Data = IOHelper.ReadSmallMapFloat(path, new int2(1, 1), 0, typeof(float));
            float DataMin = float.MaxValue, DataMax = -float.MaxValue;
            for (int i = 0; i < Data.Length; i++)
            {
                DataMin = Math.Min(DataMin, Data[i]);
                DataMax = Math.Max(DataMax, Data[i]);
            }
            float Range = 255f / (DataMax - DataMin);

            byte[] DataByte = new byte[Data.Length];
            for (int i = 0; i < Data.Length; i++)
                DataByte[i] = (byte)((Data[i] - DataMin) * Range);
            NewTexture.Data = DataByte;

            return NewTexture;
        }
        public static ImageTexture FromMRC(string path)
        {
            ImageTexture NewTexture = new ImageTexture();

            HeaderMRC Header = HeaderMRC.ReadFromFile(path) as HeaderMRC;

            NewTexture.Size   = Header.Dimensions;
            NewTexture.Scale  = new Vector2(Header.Pixelsize.X, Header.Pixelsize.Y);
            NewTexture.Offset = new Vector2(Header.Origin.X, Header.Origin.Y);

            float[] Data = IOHelper.ReadSmallMapFloat(path, new int2(1, 1), 0, typeof(float));
            float   DataMin = float.MaxValue, DataMax = -float.MaxValue;

            for (int i = 0; i < Data.Length; i++)
            {
                DataMin = Math.Min(DataMin, Data[i]);
                DataMax = Math.Max(DataMax, Data[i]);
            }
            float Range = 255f / (DataMax - DataMin);

            byte[] DataByte = new byte[Data.Length];
            for (int i = 0; i < Data.Length; i++)
            {
                DataByte[i] = (byte)((Data[i] - DataMin) * Range);
            }
            NewTexture.Data = DataByte;

            return(NewTexture);
        }
Exemple #3
0
        public Membrane()
        {
            MeshProgram = new GLSLProgram("Shaders/Membrane.vert", null, null, null, "Shaders/Membrane.frag");
            PointProgram = new GLSLProgram("Shaders/Point.vert", null, null, "Shaders/Point.geom", "Shaders/Point.frag");
            PointGizmoProgram = new GLSLProgram("Shaders/Point.vert", null, null, "Shaders/PointGizmo.geom", "Shaders/Point.frag");
            PointModelProgram = new GLSLProgram("Shaders/PointModel.vert", null, null, null, "Shaders/PointModel.frag");
            SelectionTexture = ImageTexture.FromMRC("Shaders/unicorn.mrc");

            PointGroups.CollectionChanged += PointGroups_CollectionChanged;

            ActiveGroup = new PointGroup { Color = ColorHelper.SpectrumColor(0, 0.3f), Name = "Default Group", Size = 10 };
            PointGroups.Add(ActiveGroup);

            Patches.CollectionChanged += Patches_CollectionChanged;
        }
Exemple #4
0
        public Membrane()
        {
            MeshProgram       = new GLSLProgram("Shaders/Membrane.vert", null, null, null, "Shaders/Membrane.frag");
            PointProgram      = new GLSLProgram("Shaders/Point.vert", null, null, "Shaders/Point.geom", "Shaders/Point.frag");
            PointGizmoProgram = new GLSLProgram("Shaders/Point.vert", null, null, "Shaders/PointGizmo.geom", "Shaders/Point.frag");
            PointModelProgram = new GLSLProgram("Shaders/PointModel.vert", null, null, null, "Shaders/PointModel.frag");
            SelectionTexture  = ImageTexture.FromMRC("Shaders/unicorn.mrc");

            PointGroups.CollectionChanged += PointGroups_CollectionChanged;

            ActiveGroup = new PointGroup {
                Color = ColorHelper.SpectrumColor(0, 0.3f), Name = "Default Group", Size = 10
            };
            PointGroups.Add(ActiveGroup);

            Patches.CollectionChanged += Patches_CollectionChanged;
        }