public static WmoLiquid readFromFile(BinaryReader reader)
        {
            WmoLiquid liquid = new WmoLiquid();

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

            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();
            }

            return(liquid);
        }
        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;
            }
        }
Exemple #3
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 = reader.ReadArray <float>(size);

                size          = liquid.iTilesX * liquid.iTilesY;
                liquid.iFlags = reader.ReadArray <byte>(size);
            }
            else
            {
                liquid.iHeight    = new float[1];
                liquid.iHeight[0] = reader.ReadSingle();
            }

            return(liquid);
        }
        public GroupModel(GroupModel other)
        {
            iBound      = other.iBound;
            iMogpFlags  = other.iMogpFlags;
            iGroupWMOID = other.iGroupWMOID;
            vertices    = other.vertices;
            triangles   = other.triangles;
            meshTree    = other.meshTree;
            iLiquid     = null;

            if (other.iLiquid != null)
            {
                iLiquid = new WmoLiquid(other.iLiquid);
            }
        }
        public bool readFromFile(BinaryReader reader)
        {
            uint chunkSize = 0;
            uint count     = 0;

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

            iBound      = reader.ReadStruct <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.ReadStruct <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.ReadStruct <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);
        }
 void setLiquidData(WmoLiquid liquid)
 {
     iLiquid = liquid;
     liquid  = null;
 }
Exemple #7
0
 void SetLiquidData(WmoLiquid liquid)
 {
     iLiquid = liquid;
 }