Esempio n. 1
0
        private void ReadDoodadInstances()
        {
            var chunk     = Data.GetChunkByName("MODD");
            var nameChunk = Data.GetChunkByName("MODN");

            if (chunk == null || nameChunk == null)
            {
                return;
            }

            const int instanceSize   = 40;
            var       countInstances = (int)(chunk.Length / instanceSize);

            DoodadInstances = new List <DoodadInstance>(countInstances);
            for (int i = 0; i < countInstances; i++)
            {
                var stream = chunk.GetStream();
                stream.Seek(instanceSize * i, SeekOrigin.Current);
                var instance   = DoodadInstance.Read(stream);
                var nameStream = nameChunk.GetStream();
                if (instance.FileOffset >= nameChunk.Length)
                {
                    continue;
                }
                nameStream.Seek(instance.FileOffset, SeekOrigin.Current);
                instance.File = nameStream.ReadCString();
                DoodadInstances.Add(instance);
            }
        }
Esempio n. 2
0
        public static Matrix GetWmoDoodadTransformation(DoodadInstance inst, WorldModelHandler.WorldModelDefinition root)
        {
            var rootTransformation = GetTransformation(root);

            var translation = Matrix.Translation(inst.Position);
            var scale = Matrix.Scaling(new Vector3(inst.Scale));
            var rotation = Matrix.RotationY(MathHelper.Pi);
            var quatRotation = Matrix.RotationQuaternion(new Quaternion(-inst.QuatY, inst.QuatZ, -inst.QuatX, inst.QuatW));

            return scale*rotation*quatRotation*translation*rootTransformation;
        }
Esempio n. 3
0
 public static DoodadInstance Read(Stream s)
 {
     var r = new BinaryReader(s);
     var ret = new DoodadInstance();
     ret.FileOffset = r.ReadUInt32();
     ret.Position = Vector3Helper.Read(s);
     ret.QuatW = r.ReadSingle();
     ret.QuatX = r.ReadSingle();
     ret.QuatY = r.ReadSingle();
     ret.QuatZ = r.ReadSingle();
     ret.Scale = r.ReadSingle();
     ret.LightColor = r.ReadUInt32();
     return ret;
 }
Esempio n. 4
0
        public static DoodadInstance Read(Stream s)
        {
            var r   = new BinaryReader(s);
            var ret = new DoodadInstance();

            ret.FileOffset = r.ReadUInt32();
            ret.Position   = Vector3Helper.Read(s);
            ret.QuatW      = r.ReadSingle();
            ret.QuatX      = r.ReadSingle();
            ret.QuatY      = r.ReadSingle();
            ret.QuatZ      = r.ReadSingle();
            ret.Scale      = r.ReadSingle();
            ret.LightColor = r.ReadUInt32();
            return(ret);
        }
Esempio n. 5
0
        public static DoodadInstance Read(Stream s)
        {
            var  r             = new BinaryReader(s);
            var  ret           = new DoodadInstance();
            uint OffsetAndFlag = r.ReadUInt32();

            ret.FileOffset = OffsetAndFlag & 0x00FFFFFF;
            ret.Flags      = (ushort)(OffsetAndFlag >> 24);
            ret.Position   = Vector3Helper.Read(s);
            ret.QuatX      = r.ReadSingle();
            ret.QuatY      = r.ReadSingle();
            ret.QuatZ      = r.ReadSingle();
            ret.QuatW      = r.ReadSingle();
            ret.Scale      = r.ReadSingle();
            ret.LightColor = r.ReadUInt32();
            return(ret);
        }