Пример #1
0
 public void SetBuildingParams(float agentHeight, float agentRadius, float agentMaxClimb, float agentMaxSlope,
                               float cellSize, float cellHeight, float regionMinSize, float regionMergeSize, float edgeMaxLen,
                               float edgeMaxError, float vertsPerPoly, float detailSampleDist, float detailSampleMaxError,
                               int partitionType, float tileSize)
 {
     RecastDll.SetBuildParams(this.recastPtr, agentHeight, agentRadius, agentMaxClimb, agentMaxSlope,
                              cellSize, cellHeight, regionMinSize, regionMergeSize, edgeMaxLen,
                              edgeMaxError, vertsPerPoly, detailSampleDist, detailSampleMaxError,
                              partitionType, tileSize);
 }
Пример #2
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);
        }
Пример #3
0
        /// <summary>
        /// 添加圆柱形障碍
        /// </summary>
        /// <param name="pos">y轴要贴近地面</param>
        public IntPtr AddCylinderObstacle(Vector3 pos, float radius, float height)
        {
            this.Vector3ToArray(ref pos, this.startPos);
            IntPtr obstaclePtr;

            if (RecastDll.AddCylinderObstacle(this.recastPtr, this.startPos, radius, height, out obstaclePtr))
            {
                return(obstaclePtr);
            }

            return(IntPtr.Zero);
        }
Пример #4
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);
        }
Пример #5
0
        /// <summary>
        /// 添加矩形障碍
        /// </summary>
        public IntPtr AddBoxObstacle(Vector3 bMin, Vector3 bMax)
        {
            this.Vector3ToArray(ref bMin, this.startPos);
            this.Vector3ToArray(ref bMax, this.endPos);
            IntPtr obstaclePtr;

            if (RecastDll.AddBoxObstacle(this.recastPtr, this.startPos, this.endPos, out obstaclePtr))
            {
                return(obstaclePtr);
            }

            return(IntPtr.Zero);
        }
Пример #6
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);
        }
Пример #7
0
        public ConvexVolumeData[] GetVolumeDatas()
        {
            int length = RecastDll.GetConvexCount(this.recastPtr);
            var array  = new ConvexVolumeData[length];
            var size   = Marshal.SizeOf(typeof(ConvexVolumeData)) * length;
            var ptr    = Marshal.AllocHGlobal(size);

            RecastDll.GetConvexArray(this.recastPtr, ptr);
            for (var i = 0; i < length; i++)
            {
                var p = new IntPtr(ptr.ToInt64() + Marshal.SizeOf(typeof(ConvexVolumeData)) * i);
                array[i] = (ConvexVolumeData)Marshal.PtrToStructure(p, typeof(ConvexVolumeData));
            }
            Marshal.FreeHGlobal(ptr);             // 释放内存
            return(array);
        }
Пример #8
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);
        }
Пример #9
0
 public bool DeleteConvexPolygon(Vector3 point)
 {
     //point.x = -point.x;
     this.Vector3ToArray(ref point, this.startPos);
     return(RecastDll.DeleteConvexPolygon(this.recastPtr, this.startPos));
 }
Пример #10
0
 public void RemoveTile(Vector3 minPoint, Vector3 maxPoint)
 {
     this.Vector3ToArray(ref minPoint, this.startPos);
     this.Vector3ToArray(ref maxPoint, this.endPos);
     RecastDll.RemoveTile(this.recastPtr, this.startPos, this.endPos);
 }
Пример #11
0
 public void Update(float deltaTime)
 {
     RecastDll.Update(this.recastPtr, deltaTime);
 }
Пример #12
0
 public void SetFilterFlag(PolyFlags flag, bool isIncluded)
 {
     RecastDll.SetFilterFlag(this.recastPtr, (int)flag, isIncluded);
 }
Пример #13
0
 public void SetAreaCost(PolyAreas area, float cost)
 {
     RecastDll.SetAreaCost(this.recastPtr, (int)area, cost);
 }
Пример #14
0
 static RecastBase()
 {
     RecastDll.SetEnvLog(Log);
 }
Пример #15
0
 public bool LoadMeshBin(string binPath)
 {
     return(RecastDll.LoadMeshBin(this.recastPtr, binPath));
 }
Пример #16
0
 public bool LoadGeometry(string inObjPath)
 {
     return(RecastDll.LoadMeshGeometry(this.recastPtr, inObjPath));
 }
Пример #17
0
 public void RemoveAllObstacles()
 {
     RecastDll.RemoveAllObstacles(this.recastPtr);
 }
Пример #18
0
 public void Build(string outBinPath)
 {
     RecastDll.BuildBinary(this.recastPtr, outBinPath);
 }
Пример #19
0
 public bool MakeConvexPolygon(PolyAreas areaType)
 {
     return(RecastDll.MakeConvexPolygon(this.recastPtr, (int)areaType));
 }
Пример #20
0
 public void AddConvexPoint(Vector3 point)
 {
     //point.x = -point.x;
     this.Vector3ToArray(ref point, this.startPos);
     RecastDll.AddConvexPoint(this.recastPtr, this.startPos);
 }
Пример #21
0
 public bool RemoveObstacle(IntPtr obstaclePtr)
 {
     return(RecastDll.RemoveObstacle(this.recastPtr, obstaclePtr));
 }
Пример #22
0
 public void GetBuildSettings(out BuildSettings settings)
 {
     RecastDll.GetBuildSettings(this.recastPtr, out settings);
 }
Пример #23
0
 public TileCacheRecast()
 {
     this.recastPtr = RecastDll.CreateTileCacheRecast();
 }
Пример #24
0
 public virtual void Release()
 {
     RecastDll.Release(this.recastPtr);
 }