示例#1
0
        public bool GetLocationInfo(Vector3 p, LocationInfo info)
        {
            if (iModel == null)
            {
                return(false);
            }

            // M2 files don't contain area info, only WMO files
            if (Convert.ToBoolean(flags & (uint)ModelFlags.M2))
            {
                return(false);
            }
            if (!iBound.contains(p))
            {
                return(false);
            }
            // 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.GetLocationInfo(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) // hm...could it be handled automatically with zDist at intersection?
                {
                    info.ground_Z    = world_Z;
                    info.hitInstance = this;
                    return(true);
                }
            }
            return(false);
        }
示例#2
0
 public LocationInfoCallback(ModelInstance[] val, LocationInfo info)
 {
     prims   = val;
     locInfo = info;
     result  = false;
 }