Exemple #1
0
        private void Start2()
        {
            var data   = new PointsData(234, 1100, 1100, 45, 6);
            var points = new short[data.points.Length * 2];

            for (int i = 0; i < data.points.Length; ++i)
            {
                var p = data.points[i];
                points[i * 2 + 0] = (short)p[0];
                points[i * 2 + 1] = (short)p[1];
            }
            var peaks_index = new short[data.peaks.Length];

            for (int i = 0; i < data.peaks.Length; ++i)
            {
                var p = data.peaks[i];
                peaks_index[i] = (short)p;
            }

            var points_f = applyJitter(points, spacing * jitter * 0.5f, seed);

            Debug.Log($"dphe points:{points_f.Count} peaks:{peaks_index.Length}");

            var builder = new MeshBuilder(spacing * 1.5f).addPoints(points_f);
            var graph   = builder.create();

            if (mapMesh != null)
            {
                mapMesh.setup(seed, graph, peaks_index, spacing);
            }
        }
Exemple #2
0
        public static void loadFromFile(string path)
        {
            FileInfo file   = new FileInfo(path);
            var      stream = file.Create();
            var      length = stream.Length;
            var      bytes  = new byte[length];
            int      ret    = stream.Read(bytes, 0, (int)length);

            if (ret != length)
            {
            }

            var pointData = new PointsData();

            var data = new short[ret / 2];

            Buffer.BlockCopy(bytes, 0, data, 0, ret);

            var numPeaks = data[0];
            var peaks    = new UInt16[numPeaks];

            Array.Copy(data, 1, peaks, 0, numPeaks);

            var numPoints = (data.Length - 1 - numPeaks) / 2;
            var points    = new UInt16[numPoints][];

            for (int i = 0; i < numPoints; i++)
            {
                var j = 1 + numPeaks + i * 2;
                points[i] = new UInt16[] { (UInt16)data[j], (UInt16)data[j + 1] };
            }

            var pd = new PointsData()
            {
                peaks  = peaks,
                points = points,
            };
        }