Пример #1
0
        internal BoundingBox CreateWorldBounds(DoodadDefinition dDef, out Matrix modelToWorld)
        {
            modelToWorld = Matrix.Identity;
            if (BoundingVertices == null) return BoundingBox.INVALID;
            if (BoundingVertices.Length == 0) return BoundingBox.INVALID;

            Matrix scaleMatrix;
            Matrix.CreateScale(dDef.Scale, out scaleMatrix);

            Matrix rotMatrix;
            Matrix.CreateFromQuaternion(ref dDef.Rotation, out rotMatrix);

            Matrix.Multiply(ref scaleMatrix, ref rotMatrix, out modelToWorld);

            var tempVertices = new List<Vector3>(BoundingVertices.Length);
            foreach (var vertex in BoundingVertices)
            {
                var tempVertex = Vector3.Transform(vertex, modelToWorld);
                tempVertices.Add(tempVertex + dDef.Position);
            }

            return new BoundingBox(tempVertices.ToArray());
        }
Пример #2
0
        static void ReadMODD(BinaryReader br, WMORoot wmo, uint size)
        {
            // Why oh why is wmo.Header.DoodadCount wrong sometimes
            // 40 is the size of DoodadDefinition
            wmo.DoodadDefinitions = new DoodadDefinition[size / 40];

            for (var i = 0; i < wmo.DoodadDefinitions.Length; i++)
            {
                var dd = new DoodadDefinition
                             {
                                 NameIndex = br.ReadInt32(),
                                 Position = br.ReadWMOVector3(),
                                 Rotation = br.ReadQuaternion(),
                                 Scale = br.ReadSingle(),
                                 Color = br.ReadColor4()
                             };

                if (dd.NameIndex != -1)
                {
                    dd.FilePath = wmo.DoodadFiles[dd.NameIndex];
                }

                wmo.DoodadDefinitions[i] = dd;
            }
        }