Exemple #1
0
        public WmoInstance(int uuid, Vector3 position, Vector3 rotation, WmoRootRender model)
        {
            ReferenceCount = 1;
            Uuid           = uuid;
            BoundingBox    = model.BoundingBox;

            mPosition = position;
            mRotation = rotation;
            mModel    = model;

            mInstanceMatrix = Matrix.RotationYawPitchRoll(MathUtil.DegreesToRadians(rotation.Y),
                                                          MathUtil.DegreesToRadians(rotation.X), MathUtil.DegreesToRadians(rotation.Z)) * Matrix.Translation(position);

            mRenderer = new WeakReference <WmoRootRender>(model);

            InstanceCorners = model.BoundingBox.GetCorners();
            Vector3.TransformCoordinate(InstanceCorners, ref mInstanceMatrix, InstanceCorners);

            BoundingBox = BoundingBox.Transform(ref mInstanceMatrix);
            GroupBoxes  = new BoundingBox[model.Groups.Count];
            for (var i = 0; i < GroupBoxes.Length; ++i)
            {
                var group = model.Groups[i];
                GroupBoxes[i] = group.BoundingBox.Transform(ref mInstanceMatrix);
            }
            Matrix.Invert(ref mInstanceMatrix, out mInverseInstanceMatrix);

            mInstanceMatrix = Matrix.Transpose(mInstanceMatrix);
            ModelRoot       = model.Data;
        }
Exemple #2
0
        private void Dispose(bool disposing)
        {
            if (mActiveInstances != null)
            {
                mActiveInstances.Clear();
                mActiveInstances = null;
            }

            if (mInstances != null)
            {
                foreach (var inst in mInstances.Values)
                {
                    inst.Dispose();
                }

                mInstances.Clear();
                mInstances = null;
            }

            if (mRoot != null)
            {
                mRoot.Dispose();
                mRoot = null;
            }
        }
Exemple #3
0
 public WmoGroupRender(IO.Files.Models.WmoGroup group, WmoRootRender root)
 {
     Data = group;
     foreach (var batch in Data.Batches)
     {
         mBatches.Add(new WmoRenderBatch
         {
             Batch    = batch,
             Material = root.Data.GetMaterial(batch.MaterialId)
         });
     }
 }
Exemple #4
0
 public WmoGroupRender(IO.Files.Models.WmoGroup group, WmoRootRender root)
 {
     Data = group;
     foreach(var batch in Data.Batches)
     {
         mBatches.Add(new WmoRenderBatch
         {
             Batch = batch,
             Material = root.Data.GetMaterial(batch.MaterialId)
         });
     }
 }
Exemple #5
0
        public WmoInstance(int uuid, Vector3 position, Vector3 rotation, WmoRootRender model)
        {
            Uuid            = uuid;
            BoundingBox     = model.BoundingBox;
            mInstanceMatrix = Matrix.RotationYawPitchRoll(MathUtil.DegreesToRadians(rotation.Y),
                                                          MathUtil.DegreesToRadians(rotation.X), MathUtil.DegreesToRadians(rotation.Z)) * Matrix.Translation(position);

            BoundingBox = BoundingBox.Transform(ref mInstanceMatrix);
            GroupBoxes  = new BoundingBox[model.Groups.Count];
            for (var i = 0; i < GroupBoxes.Length; ++i)
            {
                var group = model.Groups[i];
                GroupBoxes[i] = group.BoundingBox.Transform(ref mInstanceMatrix);
            }

            mInstanceMatrix = Matrix.Transpose(mInstanceMatrix);
        }
Exemple #6
0
        public WmoInstance(int uuid, Vector3 position, Vector3 rotation, WmoRootRender model)
        {
            Uuid = uuid;
            BoundingBox = model.BoundingBox;
            mInstanceMatrix = Matrix.RotationYawPitchRoll(MathUtil.DegreesToRadians(rotation.Y),
                                  MathUtil.DegreesToRadians(rotation.X), MathUtil.DegreesToRadians(rotation.Z)) * Matrix.Translation(position);

            BoundingBox = BoundingBox.Transform(ref mInstanceMatrix);
            GroupBoxes = new BoundingBox[model.Groups.Count];
            for(var i = 0; i < GroupBoxes.Length; ++i)
            {
                var group = model.Groups[i];
                GroupBoxes[i] = group.BoundingBox.Transform(ref mInstanceMatrix);
            }

            mInstanceMatrix = Matrix.Transpose(mInstanceMatrix);
        }
Exemple #7
0
        private void PreloadModel(string model)
        {
            var hash = model.ToUpperInvariant().GetHashCode();
            lock(mRenderer)
            {
                if (mRenderer.ContainsKey(hash))
                    return;

                var root = IO.Files.Models.ModelFactory.Instance.CreateWmo();

                if (root.Load(model) == false)
                    Log.Warning("Unable to load WMO '" + model + "'. Further instances wont be loaded again");


                var renderer = new WmoRootRender();
                renderer.OnAsyncLoad(root);

                var batch = new WmoBatchRender(renderer);

                lock (mAddLock)
                    mRenderer.Add(hash, batch);
            }
        }
Exemple #8
0
 public WmoBatchRender(WmoRootRender root)
 {
     mRoot = root;
 }
Exemple #9
0
 public WmoBatchRender(WmoRootRender root)
 {
     mRoot = root;
 }