コード例 #1
0
    // Information for doodad instances.
    public static void ReadMODD(Stream WMOrootstream, int MODDsize)
    {
        int numberOfDoodadInstances = MODDsize / 40;
        List <DoodadInstanceInfo> DoodadInstances = new List <DoodadInstanceInfo>();

        for (int i = 0; i < numberOfDoodadInstances; ++i)
        {
            DoodadInstanceInfo doodadInstance  = new DoodadInstanceInfo();
            byte[]             finalNameBytes  = new byte[4];
            byte[]             nameOffsetBytes = new byte[3];
            WMOrootstream.Read(nameOffsetBytes, 0, 3);
            Buffer.BlockCopy(nameOffsetBytes, 0, finalNameBytes, 0, 3);
            doodadInstance.nameOffset = BitConverter.ToUInt32(finalNameBytes, 0); // reference offset into MODN

            DoodadInstanceFlags doodadInstanceFlags = new DoodadInstanceFlags();
            byte[] arrayOfBytes = new byte[1];
            WMOrootstream.Read(arrayOfBytes, 0, 1);
            BitArray flags = new BitArray(arrayOfBytes);
            doodadInstanceFlags.AcceptProjectedTexture = flags[0];
            doodadInstanceFlags.Unknown1 = flags[1]; // MapStaticEntity::field_34 |= 1 (if set, MapStaticEntity::AdjustLighting is _not_ called)
            doodadInstanceFlags.Unknown2 = flags[2];
            doodadInstanceFlags.Unknown3 = flags[3];
            doodadInstance.flags         = doodadInstanceFlags;

            doodadInstance.position            = new Vector3(ReadFloat(WMOrootstream) / Settings.worldScale, ReadFloat(WMOrootstream) / Settings.worldScale, ReadFloat(WMOrootstream) / Settings.worldScale); // (X,Z,-Y)
            doodadInstance.orientation         = new Quaternion(ReadFloat(WMOrootstream), ReadFloat(WMOrootstream), ReadFloat(WMOrootstream), ReadFloat(WMOrootstream));                                      // (X, Y, Z, W)
            doodadInstance.scale               = ReadFloat(WMOrootstream);                                                                                                                                    // scale factor
            doodadInstance.staticLightingColor = ReadBGRA(WMOrootstream);                                                                                                                                     // (B,G,R,A) overrides pc_sunColor

            DoodadInstances.Add(doodadInstance);
        }
    }
コード例 #2
0
        public DoodadInstance(byte[] inData)
        {
            using (MemoryStream ms = new MemoryStream(inData))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    byte[] finalNameBytes = new byte[4];
                    byte[] nameOffsetBytes = br.ReadBytes(3);
                    Buffer.BlockCopy(nameOffsetBytes, 0, finalNameBytes, 0, 3);

                    this.NameOffset= BitConverter.ToUInt32(finalNameBytes, 0);

                    this.Flags = (DoodadInstanceFlags) br.ReadByte();

                    this.Position = br.ReadVector3f();

                    // TODO: Investigate whether or not this is a Quat16 in >= BC
                    this.Orientation = br.ReadQuaternion32();

                    this.Scale = br.ReadSingle();
                    this.StaticLightingColour = br.ReadBGRA();
                }
            }
        }
コード例 #3
0
        public DoodadInstance(byte[] inData)
        {
            using (MemoryStream ms = new MemoryStream(inData))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    byte[] finalNameBytes  = new byte[4];
                    byte[] nameOffsetBytes = br.ReadBytes(3);
                    Buffer.BlockCopy(nameOffsetBytes, 0, finalNameBytes, 0, 3);

                    NameOffset = BitConverter.ToUInt32(finalNameBytes, 0);

                    Flags = (DoodadInstanceFlags)br.ReadByte();

                    Position = br.ReadVector3();

                    // TODO: Investigate whether or not this is a Quat16 in >= BC
                    Orientation = br.ReadQuaternion32();

                    Scale = br.ReadSingle();
                    StaticLightingColour = br.ReadBGRA();
                }
            }
        }