예제 #1
0
        /// <summary>
        /// Populates the vertices array with the height data from the file and the X/Y offsets from the header Also loads the BoundingBox and
        /// sets the texture coordinates for each vertex.
        /// </summary>
        private void LoadVertices()
        {
            mFile.Position = mOffset.Offset + mHeader.ofsHeight;
            byte[] sig = mFile.Read(4);
            string sigStr = Encoding.UTF8.GetString(sig);
            mFile.Position += 4;

            uint counter = 0;
            Vector3 minPos = new Vector3(999999.9f);
            Vector3 maxPos = new Vector3(-999999.9f);
            minPos.X = mHeader.position.X;
            minPos.Y = mHeader.position.Y;
            maxPos.X = minPos.X + Utils.Metrics.Chunksize;
            maxPos.Y = minPos.Y + Utils.Metrics.Chunksize;
            for (int i = 0; i < 17; ++i)
            {
                for (int j = 0; j < (((i % 2) != 0) ? 8 : 9); ++j)
                {
                    float x, y, z;
                    z = mFile.Read<float>() + mHeader.position.Z;
                    y = i * Utils.Metrics.Unitsize * 0.5f + mHeader.position.Y;
                    x = j * Utils.Metrics.Unitsize + mHeader.position.X;

                    if ((i % 2) != 0)
                        x += 0.5f * Utils.Metrics.Unitsize;

                    if (z < minPos.Z)
                        minPos.Z = z;
                    if (z > maxPos.Z)
                        maxPos.Z = z;
                    if (x < minPos.X)
                        minPos.X = x;
                    if (x > maxPos.X)
                        maxPos.X = x;
                    if (y < minPos.Y)
                        minPos.Y = y;
                    if (y > maxPos.Y)
                        maxPos.Y = y;

                    vertices[counter] = new Wotlk.ADTVertex()
                    {
                        X = x,
                        Y = y,
                        Z = z,
                        U = ADTStaticData.TexCoords[counter, 0],
                        V = ADTStaticData.TexCoords[counter, 1],
                        S = ADTStaticData.AlphaCoords[counter, 0],
                        T = ADTStaticData.AlphaCoords[counter, 1]
                    };

                    ++counter;
                }
            }

            mBox = new BoundingBox(minPos, maxPos);
            MinPosition = minPos;
            MaxPosition = maxPos;
        }
예제 #2
0
        /// <summary>
        /// Populates the vertices array with the height data from the file and the X/Y offsets from the header Also loads the BoundingBox and
        /// sets the texture coordinates for each vertex.
        /// </summary>
        private void LoadVertices()
        {
            mFile.Position = mOffset.Offset + mHeader.ofsHeight;
            byte[] sig    = mFile.Read(4);
            string sigStr = Encoding.UTF8.GetString(sig);

            mFile.Position += 4;

            uint    counter = 0;
            Vector3 minPos  = new Vector3(999999.9f);
            Vector3 maxPos  = new Vector3(-999999.9f);

            minPos.X = mHeader.position.X;
            minPos.Y = mHeader.position.Y;
            maxPos.X = minPos.X + Utils.Metrics.Chunksize;
            maxPos.Y = minPos.Y + Utils.Metrics.Chunksize;
            for (int i = 0; i < 17; ++i)
            {
                for (int j = 0; j < (((i % 2) != 0) ? 8 : 9); ++j)
                {
                    float x, y, z;
                    z = mFile.Read <float>() + mHeader.position.Z;
                    y = i * Utils.Metrics.Unitsize * 0.5f + mHeader.position.Y;
                    x = j * Utils.Metrics.Unitsize + mHeader.position.X;

                    if ((i % 2) != 0)
                    {
                        x += 0.5f * Utils.Metrics.Unitsize;
                    }

                    if (z < minPos.Z)
                    {
                        minPos.Z = z;
                    }
                    if (z > maxPos.Z)
                    {
                        maxPos.Z = z;
                    }
                    if (x < minPos.X)
                    {
                        minPos.X = x;
                    }
                    if (x > maxPos.X)
                    {
                        maxPos.X = x;
                    }
                    if (y < minPos.Y)
                    {
                        minPos.Y = y;
                    }
                    if (y > maxPos.Y)
                    {
                        maxPos.Y = y;
                    }

                    vertices[counter] = new Wotlk.ADTVertex()
                    {
                        X = x,
                        Y = y,
                        Z = z,
                        U = ADTStaticData.TexCoords[counter, 0],
                        V = ADTStaticData.TexCoords[counter, 1],
                        S = ADTStaticData.AlphaCoords[counter, 0],
                        T = ADTStaticData.AlphaCoords[counter, 1]
                    };

                    ++counter;
                }
            }

            mBox        = new BoundingBox(minPos, maxPos);
            MinPosition = minPos;
            MaxPosition = maxPos;
        }