Ejemplo n.º 1
0
        bool initialize(GameObjectModelOwnerBase modelOwner)
        {
            var modelData = StaticModelList.models.LookupByKey(modelOwner.GetDisplayId());

            if (modelData == null)
            {
                return(false);
            }

            AxisAlignedBox mdl_box = new AxisAlignedBox(modelData.bound);

            // ignore models with no bounds
            if (mdl_box == AxisAlignedBox.Zero())
            {
                Log.outError(LogFilter.Server, "GameObject model {0} has zero bounds, loading skipped", modelData.name);
                return(false);
            }

            iModel = Global.VMapMgr.acquireModelInstance(modelData.name);

            if (iModel == null)
            {
                return(false);
            }

            name      = modelData.name;
            iPos      = modelOwner.GetPosition();
            iScale    = modelOwner.GetScale();
            iInvScale = 1.0f / iScale;

            Matrix3 iRotation = Matrix3.fromEulerAnglesZYX(modelOwner.GetOrientation(), 0, 0);

            iInvRot = iRotation.inverse();
            // transform bounding box:
            mdl_box = new AxisAlignedBox(mdl_box.Lo * iScale, mdl_box.Hi * iScale);
            AxisAlignedBox rotated_bounds = new AxisAlignedBox();

            for (int i = 0; i < 8; ++i)
            {
                rotated_bounds.merge(iRotation * mdl_box.corner(i));
            }

            iBound = rotated_bounds + iPos;
            owner  = modelOwner;
            isWmo  = modelData.isWmo;
            return(true);
        }
Ejemplo n.º 2
0
        public bool UpdatePosition()
        {
            if (iModel == null)
            {
                return(false);
            }

            var it = StaticModelList.models.LookupByKey(owner.GetDisplayId());

            if (it == null)
            {
                return(false);
            }

            AxisAlignedBox mdl_box = new AxisAlignedBox(it.bound);

            // ignore models with no bounds
            if (mdl_box == AxisAlignedBox.Zero())
            {
                Log.outError(LogFilter.Server, "GameObject model {0} has zero bounds, loading skipped", it.name);
                return(false);
            }

            iPos = owner.GetPosition();

            Matrix3 iRotation = Matrix3.fromEulerAnglesZYX(owner.GetOrientation(), 0, 0);

            iInvRot = iRotation.inverse();
            // transform bounding box:
            mdl_box = new AxisAlignedBox(mdl_box.Lo * iScale, mdl_box.Hi * iScale);
            AxisAlignedBox rotated_bounds = new AxisAlignedBox();

            for (int i = 0; i < 8; ++i)
            {
                rotated_bounds.merge(iRotation * mdl_box.corner(i));
            }

            iBound = rotated_bounds + iPos;

            return(true);
        }