コード例 #1
0
        private void FindWalls_HandleLocatePhysicalWallPlaneQuery(MLResult result, MLPlanes.Plane[] planes, MLPlanes.Boundaries[] boundaries)
        {
            //resets:
            Vector3 sourceWallCenter = Vector3.Lerp(_plottedCorners[_queryCount].position, _plottedCorners[_queryCount + 1].position, .5f);

            //find furthest:
            int   primeID = -1;
            float largest = 0;

            for (int i = 0; i < planes.Length; i++)
            {
                //check to make sure this plane is close to the same orientation as the virtual one:
                float dot = Vector3.Dot(planes[i].Rotation * Vector3.back, _virtualWalls[_queryCount].normal);

                //candidate - test for largest plane:
                if (dot > .9f)
                {
                    float size = planes[i].Width + planes[i].Height;
                    if (size > largest)
                    {
                        largest = size;
                        primeID = i;
                    }
                }
            }

            //use found wall or just use boundry from virtual wall:
            if (primeID != -1)
            {
                MLPlanes.Plane foundPlane = planes[primeID];
                foundPlane.Center.y = _roomVerticalCenter;
                foundPlane.Width    = _virtualWalls[_queryCount].Vector.magnitude;
                foundPlane.Height   = Height;
                _virtualWalls[_queryCount].plane = foundPlane;
            }
            else
            {
                //if we didn't find a physical wall let's just make the virtual wall a boundary plane as is:
                MLPlanes.Plane plane  = new MLPlanes.Plane();
                Vector3        center = _virtualWalls[_queryCount].Center;
                center.y       = _roomVerticalCenter;
                plane.Center   = center;
                plane.Rotation = Quaternion.LookRotation(_virtualWalls[_queryCount].normal);
                plane.Width    = _virtualWalls[_queryCount].Vector.magnitude;
                plane.Height   = Height;
                _virtualWalls[_queryCount].plane    = plane;
                _virtualWalls[_queryCount].physical = false;
            }

            //continue additional queries:
            if (_queryCount < _virtualWalls.Count - 1)
            {
                FindWalls_ResolveToPhysicalWalls();
            }
            else
            {
                FindWalls_LocateBoundry();
            }
        }
コード例 #2
0
        /// <summary>
        /// Based on the passed in SurfaceType, returns a list of ContentObjects
        /// that meet the same flag requirements.
        /// </summary>
        /// <param name="flag">The SurfaceType to be checked</param>
        private ContentObject[] GetCandidateObjects(MLPlanes.Plane plane)
        {
            var candidates = new List <ContentObject>();
            var flags      = System.Enum.GetValues(typeof(SurfaceType)) as SurfaceType[];

            // Get all of the ContentObject refs that match these flags
            for (int i = 0; i < flags.Length; ++i)
            {
                if (MLPlanesStarterKit.DoesPlaneHaveFlag(plane, (MLPlanes.QueryFlags)flags[i]))
                {
                    candidates.AddRange(_sortedContentObjects[(uint)flags[i]]);
                }
            }

            return(candidates.ToArray());
        }
コード例 #3
0
 /// <summary>
 /// Utility function used to determine if some MLPlanes.Plane object contains a certain flag.
 /// </summary>
 /// <param name="plane">The MLPlanes.Plane object to be checked.</param>
 /// <param name="flag">The MLPlanes.QueryFlags to be checked.</param>
 public static bool DoesPlaneHaveFlag(MLPlanes.Plane plane, MLPlanes.QueryFlags flag)
 {
     return((plane.Flags & (uint)flag) == (uint)flag);
 }