Example #1
0
        public bool FindRandomPoint(ref Vector3 resultPoint)
        {
            NavimeshStatus status = (NavimeshStatus)RecastDll.FindRandomPoint(this.recastPtr, this.resultPos);

            if (this.IsSuccessStatus(status))
            {
                resultPoint.Set(this.resultPos[0], this.resultPos[1], this.resultPos[2]);
                return(true);
            }

            return(false);
        }
Example #2
0
        public bool FindRandomPointAroundCircle(ref Vector3 center, float radius, ref Vector3 resultPoint)
        {
            this.Vector3ToArray(ref center, this.startPos);
            NavimeshStatus status = (NavimeshStatus)RecastDll.FindRandomPointAroundCircle(this.recastPtr, this.startPos, radius, this.resultPos);

            if (this.IsSuccessStatus(status))
            {
                resultPoint.Set(this.resultPos[0], this.resultPos[1], this.resultPos[2]);
                return(true);
            }

            return(false);
        }
Example #3
0
        public bool Raycast(ref Vector3 startPoint, ref Vector3 endPoint, ref Vector3 hitPoint)
        {
            this.Vector3ToArray(ref startPoint, this.startPos);
            this.Vector3ToArray(ref endPoint, this.endPos);
            NavimeshStatus status = (NavimeshStatus)RecastDll.Raycast(this.recastPtr, this.startPos, this.endPos, this.resultPos);

            if (this.IsSuccessStatus(status))
            {
                hitPoint.Set(this.resultPos[0], this.resultPos[1], this.resultPos[2]);
                return(true);
            }

            return(false);
        }
Example #4
0
        /// <summary>
        /// 路径点少,无平滑
        /// </summary>
        public bool FindStraightPath(Vector3 startPos, Vector3 endPos, List <Vector3> path)
        {
            this.Vector3ToArray(ref startPos, this.startPos);
            this.Vector3ToArray(ref endPos, this.endPos);
            NavimeshStatus status = (NavimeshStatus)RecastDll.FindStraightPath(this.recastPtr, this.startPos, this.endPos, this.straightPath, ref this.straigntCount);

            if (this.IsSuccessStatus(status))
            {
                path.Clear();
                int count = this.straigntCount * 3;
                Debug.Assert(this.straightPath.Length >= count);
                for (int i = 0; i < count; i += 3)
                {
                    Vector3 point = new Vector3(this.straightPath[i], this.straightPath[i + 1], this.straightPath[i + 2]);
                    path.Add(point);
                }
                return(true);
            }
            return(false);
        }
Example #5
0
 private bool IsSuccessStatus(NavimeshStatus status)
 {
     return((status & NavimeshStatus.DT_SUCCESS) != 0);
 }