Exemplo n.º 1
0
        public WmoLiquid(WmoLiquid other)
        {
            if (this == other)
            {
                return;
            }

            iTilesX = other.iTilesX;
            iTilesY = other.iTilesY;
            iCorner = other.iCorner;
            iType   = other.iType;
            if (other.iHeight != null)
            {
                iHeight = new float[(iTilesX + 1) * (iTilesY + 1)];
                Buffer.BlockCopy(other.iHeight, 0, iHeight, 0, (int)((iTilesX + 1) * (iTilesY + 1)));
            }
            else
            {
                iHeight = null;
            }
            if (other.iFlags != null)
            {
                iFlags = new byte[iTilesX * iTilesY];
                Buffer.BlockCopy(other.iFlags, 0, iFlags, 0, (int)(iTilesX * iTilesY));
            }
            else
            {
                iFlags = null;
            }
        }
Exemplo n.º 2
0
        public static WmoLiquid ReadFromFile(BinaryReader reader)
        {
            WmoLiquid liquid = new WmoLiquid();

            liquid.iTilesX = reader.ReadUInt32();
            liquid.iTilesY = reader.ReadUInt32();
            liquid.iCorner = reader.Read <Vector3>();
            liquid.iType   = reader.ReadUInt32();

            if (liquid.iTilesX != 0 && liquid.iTilesY != 0)
            {
                uint size = (liquid.iTilesX + 1) * (liquid.iTilesY + 1);
                liquid.iHeight = new float[size];
                for (var i = 0; i < size; i++)
                {
                    liquid.iHeight[i] = reader.ReadSingle();
                }

                size          = liquid.iTilesX * liquid.iTilesY;
                liquid.iFlags = new byte[size];
                for (var i = 0; i < size; i++)
                {
                    liquid.iFlags[i] = reader.ReadByte();
                }
            }
            else
            {
                liquid.iHeight    = new float[1];
                liquid.iHeight[0] = reader.ReadSingle();
            }

            return(liquid);
        }
Exemplo n.º 3
0
 public void GetMeshData(out List <Vector3> outVertices, out List <MeshTriangle> outTriangles, out WmoLiquid liquid)
 {
     outVertices  = vertices;
     outTriangles = triangles;
     liquid       = iLiquid;
 }
Exemplo n.º 4
0
        public bool ReadFromFile(BinaryReader reader)
        {
            uint chunkSize = 0;
            uint count     = 0;

            triangles.Clear();
            vertices.Clear();
            iLiquid = null;

            iBound      = reader.Read <AxisAlignedBox>();
            iMogpFlags  = reader.ReadUInt32();
            iGroupWMOID = reader.ReadUInt32();

            // read vertices
            if (reader.ReadStringFromChars(4) != "VERT")
            {
                return(false);
            }

            chunkSize = reader.ReadUInt32();
            count     = reader.ReadUInt32();
            if (count == 0)
            {
                return(false);
            }

            for (var i = 0; i < count; ++i)
            {
                vertices.Add(reader.Read <Vector3>());
            }

            // read triangle mesh
            if (reader.ReadStringFromChars(4) != "TRIM")
            {
                return(false);
            }

            chunkSize = reader.ReadUInt32();
            count     = reader.ReadUInt32();

            for (var i = 0; i < count; ++i)
            {
                triangles.Add(reader.Read <MeshTriangle>());
            }

            // read mesh BIH
            if (reader.ReadStringFromChars(4) != "MBIH")
            {
                return(false);
            }
            meshTree.readFromFile(reader);

            // write liquid data
            if (reader.ReadStringFromChars(4).ToString() != "LIQU")
            {
                return(false);
            }
            chunkSize = reader.ReadUInt32();
            if (chunkSize > 0)
            {
                iLiquid = WmoLiquid.ReadFromFile(reader);
            }

            return(true);
        }
Exemplo n.º 5
0
 public void SetLiquidData(WmoLiquid liquid)
 {
     iLiquid = liquid;
     liquid  = null;
 }