示例#1
0
        public void UpdateVertices(MapChunk chunk)
        {
            if (chunk == null)
                return;

            var ix = chunk.IndexX;
            var iy = chunk.IndexY;

            var index = (ix + iy * 16) * 145;
            for (var i = 0; i < 145; ++i)
                FullVertices[i + index] = chunk.Vertices[i];
        }
示例#2
0
文件: MapArea.cs 项目: veserine/Neo
        public void UpdateVertices(MapChunk chunk)
        {
            if (chunk == null)
            {
                return;
            }

            var ix = chunk.IndexX;
            var iy = chunk.IndexY;

            var index = (ix + iy * 16) * 145;

            for (var i = 0; i < 145; ++i)
            {
                FullVertices[i + index] = chunk.Vertices[i];
            }
        }
示例#3
0
文件: MapArea.cs 项目: veserine/Neo
        private void InitChunks(BinaryReader reader)
        {
            var minPos = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            var maxPos = new Vector3(float.MinValue, float.MinValue, float.MinValue);

            var modelMin = new Vector3(float.MaxValue);
            var modelMax = new Vector3(float.MinValue);

            for (var i = 0; i < 256; ++i)
            {
                var chunk = new MapChunk(i % 16, i / 16, new WeakReference <MapArea>(this));
                if (chunk.AsyncLoad(reader, mChunkInfos[i]) == false)
                {
                    throw new InvalidOperationException("Unable to load chunk");
                }

                var bbmin = chunk.BoundingBox.Minimum;
                var bbmax = chunk.BoundingBox.Maximum;
                if (bbmin.X < minPos.X)
                {
                    minPos.X = bbmin.X;
                }
                if (bbmax.X > maxPos.X)
                {
                    maxPos.X = bbmax.X;
                }
                if (bbmin.Y < minPos.Y)
                {
                    minPos.Y = bbmin.Y;
                }
                if (bbmax.Y > maxPos.Y)
                {
                    maxPos.Y = bbmax.Y;
                }
                if (bbmin.Z < minPos.Z)
                {
                    minPos.Z = bbmin.Z;
                }
                if (bbmax.Z > maxPos.Z)
                {
                    maxPos.Z = bbmax.Z;
                }

                bbmin = chunk.ModelBox.Minimum;
                bbmax = chunk.ModelBox.Maximum;
                if (bbmin.X < modelMin.X)
                {
                    modelMin.X = bbmin.X;
                }
                if (bbmax.X > modelMax.X)
                {
                    modelMax.X = bbmax.X;
                }
                if (bbmin.Y < modelMin.Y)
                {
                    modelMin.Y = bbmin.Y;
                }
                if (bbmax.Y > modelMax.Y)
                {
                    modelMax.Y = bbmax.Y;
                }
                if (bbmin.Z < modelMin.Z)
                {
                    modelMin.Z = bbmin.Z;
                }
                if (bbmax.Z > modelMax.Z)
                {
                    modelMax.Z = bbmax.Z;
                }

                mChunks.Add(chunk);
                Array.Copy(chunk.Vertices, 0, FullVertices, i * 145, 145);
            }

            BoundingBox = new BoundingBox(minPos, maxPos);
            ModelBox    = new BoundingBox(modelMin, modelMax);
        }
示例#4
0
        private void InitChunks(BinaryReader reader)
        {
            var minPos = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            var maxPos = new Vector3(float.MinValue, float.MinValue, float.MinValue);

            var modelMin = new Vector3(float.MaxValue);
            var modelMax = new Vector3(float.MinValue);

            for (var i = 0; i < 256; ++i)
            {
                var chunk = new MapChunk(i % 16, i / 16, new WeakReference<MapArea>(this));
                if (chunk.AsyncLoad(reader, mChunkInfos[i]) == false)
                    throw new InvalidOperationException("Unable to load chunk");

                var bbmin = chunk.BoundingBox.Minimum;
                var bbmax = chunk.BoundingBox.Maximum;
                if (bbmin.X < minPos.X)
                    minPos.X = bbmin.X;
                if (bbmax.X > maxPos.X)
                    maxPos.X = bbmax.X;
                if (bbmin.Y < minPos.Y)
                    minPos.Y = bbmin.Y;
                if (bbmax.Y > maxPos.Y)
                    maxPos.Y = bbmax.Y;
                if (bbmin.Z < minPos.Z)
                    minPos.Z = bbmin.Z;
                if (bbmax.Z > maxPos.Z)
                    maxPos.Z = bbmax.Z;

                bbmin = chunk.ModelBox.Minimum;
                bbmax = chunk.ModelBox.Maximum;
                if (bbmin.X < modelMin.X)
                    modelMin.X = bbmin.X;
                if (bbmax.X > modelMax.X)
                    modelMax.X = bbmax.X;
                if (bbmin.Y < modelMin.Y)
                    modelMin.Y = bbmin.Y;
                if (bbmax.Y > modelMax.Y)
                    modelMax.Y = bbmax.Y;
                if (bbmin.Z < modelMin.Z)
                    modelMin.Z = bbmin.Z;
                if (bbmax.Z > modelMax.Z)
                    modelMax.Z = bbmax.Z;

                mChunks.Add(chunk);
                Array.Copy(chunk.Vertices, 0, FullVertices, i * 145, 145);
            }

            BoundingBox = new BoundingBox(minPos, maxPos);
            ModelBox = new BoundingBox(modelMin, modelMax);
        }