Exemplo n.º 1
0
        public override void IntersectPoint(Vector3 point, AreaInfo info, PhaseShift phaseShift)
        {
            if (!IsCollisionEnabled() || !owner.IsSpawned() || !IsMapObject())
            {
                return;
            }

            if (!owner.IsInPhase(phaseShift))
            {
                return;
            }

            if (!iBound.contains(point))
            {
                return;
            }

            // child bounds are defined in object space:
            Vector3 pModel    = iInvRot * (point - iPos) * iInvScale;
            Vector3 zDirModel = iInvRot * new Vector3(0.0f, 0.0f, -1.0f);
            float   zDist;

            if (iModel.IntersectPoint(pModel, zDirModel, out zDist, info))
            {
                Vector3 modelGround = pModel + zDist * zDirModel;
                float   world_Z     = ((modelGround * iInvRot) * iScale + iPos).Z;
                if (info.ground_Z < world_Z)
                {
                    info.ground_Z = world_Z;
                    info.adtId    = owner.GetNameSetId();
                }
            }
        }
Exemplo n.º 2
0
        public void intersectPoint(Vector3 p, AreaInfo info)
        {
            if (iModel == null)
            {
                return;
            }

            // M2 files don't contain area info, only WMO files
            if (Convert.ToBoolean(flags & (uint)ModelFlags.M2))
            {
                return;
            }
            if (!iBound.contains(p))
            {
                return;
            }
            // child bounds are defined in object space:
            Vector3 pModel    = iInvRot * (p - iPos) * iInvScale;
            Vector3 zDirModel = iInvRot * new Vector3(0.0f, 0.0f, -1.0f);
            float   zDist;

            if (iModel.IntersectPoint(pModel, zDirModel, out zDist, info))
            {
                Vector3 modelGround = pModel + zDist * zDirModel;
                // Transform back to world space. Note that:
                // Mat * vec == vec * Mat.transpose()
                // and for rotation matrices: Mat.inverse() == Mat.transpose()
                float world_Z = ((modelGround * iInvRot) * iScale + iPos).Z;
                if (info.ground_Z < world_Z)
                {
                    info.ground_Z = world_Z;
                    info.adtId    = adtId;
                }
            }
        }
Exemplo n.º 3
0
        public bool IntersectPoint(Vector3 p, Vector3 down, out float dist, AreaInfo info)
        {
            dist = 0f;
            if (groupModels.Empty())
            {
                return(false);
            }

            WModelAreaCallback callback = new WModelAreaCallback(groupModels, down);

            groupTree.intersectPoint(p, callback);
            if (callback.hit != null)
            {
                info.rootId  = (int)RootWMOID;
                info.groupId = (int)callback.hit.GetWmoID();
                info.flags   = callback.hit.GetMogpFlags();
                info.result  = true;
                dist         = callback.zDist;
                return(true);
            }
            return(false);
        }
Exemplo n.º 4
0
 public virtual void IntersectPoint(Vector3 point, AreaInfo info, PhaseShift phaseShift)
 {
 }
Exemplo n.º 5
0
 public DynamicTreeAreaInfoCallback(PhaseShift phaseShift)
 {
     _phaseShift = phaseShift;
     _areaInfo   = new AreaInfo();
 }