Ejemplo n.º 1
0
        public PolyPointResult FindNearestPoly(NavMeshQuery navMeshQuery, float[] point, float[] halfExtents)
        {
            var polyPointResultPointer = RecastLibrary.navmesh_query_find_nearest_poly(navMeshQuery.DangerousGetHandle(), point, halfExtents);
            var polyPointResult        = Marshal.PtrToStructure(polyPointResultPointer, typeof(PolyPointResult));

            RecastLibrary.poly_point_result_delete(polyPointResultPointer);

            return((PolyPointResult)polyPointResult);
        }
Ejemplo n.º 2
0
        public PolyPointResult FindRandomPoint(NavMeshQuery navMeshQuery)
        {
            var polyPointResultPointer = RecastLibrary.navmesh_query_find_random_point(navMeshQuery.DangerousGetHandle());
            var polyPointResult        = Marshal.PtrToStructure(polyPointResultPointer, typeof(PolyPointResult));

            RecastLibrary.poly_point_result_delete(polyPointResultPointer);

            return((PolyPointResult)polyPointResult);
        }
Ejemplo n.º 3
0
        public NavMesh LoadTiledNavMeshBinFile(string path)
        {
            if (!File.Exists(path))
            {
                throw new FileNotFoundException("File not found.", path);
            }

            return(new NavMesh(RecastLibrary.navmesh_load_tiled_bin(path.ToCharArray())));
        }
Ejemplo n.º 4
0
 public NavMeshDataResult CreateNavMeshData(RcConfig config, PolyMeshDetail polyMeshDetail, PolyMesh polyMesh,
                                            InputGeom geom, int tx, int ty, float agentHeight, float agentRadius, float agentMaxClimb)
 {
     return(RecastLibrary.navmesh_data_create(
                _context.DangerousGetHandle(),
                ref config,
                polyMeshDetail.DangerousGetHandle(),
                polyMesh.DangerousGetHandle(),
                geom.DangerousGetHandle(),
                tx,
                ty,
                agentHeight,
                agentRadius,
                agentMaxClimb));
 }
Ejemplo n.º 5
0
        public FindPathResult FindPath(NavMeshQuery navMeshQuery, PolyPointResult a, PolyPointResult b)
        {
            var filter   = RecastLibrary.dtQueryFilter_create();
            var aPointer = Marshal.AllocHGlobal(3 * 4);

            Marshal.Copy(a.point, 0, aPointer, 3);

            var bPointer = Marshal.AllocHGlobal(3 * 4);

            Marshal.Copy(b.point, 0, bPointer, 3);

            var pathResultPointer = RecastLibrary.navmesh_query_find_path(navMeshQuery.DangerousGetHandle(), a.polyRef, b.polyRef, aPointer, bPointer, filter);

            Marshal.FreeHGlobal(aPointer);
            Marshal.FreeHGlobal(bPointer);
            RecastLibrary.dtQueryFilter_delete(filter);

            var pathResult = Marshal.PtrToStructure(pathResultPointer, typeof(FindPathResult));

            RecastLibrary.find_path_result_delete(pathResultPointer);
            return((FindPathResult)pathResult);
        }
Ejemplo n.º 6
0
        public SmoothPathResult FindSmoothPath(NavMeshQuery navMeshQuery, NavMesh navMesh, FindPathResult pathResult, PolyPointResult a, PolyPointResult b)
        {
            var filter   = RecastLibrary.dtQueryFilter_create();
            var aPointer = Marshal.AllocHGlobal(3 * 4);

            Marshal.Copy(a.point, 0, aPointer, 3);

            var bPointer = Marshal.AllocHGlobal(3 * 4);

            Marshal.Copy(b.point, 0, bPointer, 3);

            var pathResultPointer = RecastLibrary.navmesh_query_get_smooth_path(aPointer, a.polyRef, bPointer,
                                                                                ref pathResult, filter, navMesh.DangerousGetHandle(), navMeshQuery.DangerousGetHandle());

            Marshal.FreeHGlobal(aPointer);
            Marshal.FreeHGlobal(bPointer);
            RecastLibrary.dtQueryFilter_delete(filter);

            var smoothPathResult = Marshal.PtrToStructure(pathResultPointer, typeof(SmoothPathResult));

            RecastLibrary.smooth_path_result_delete(pathResultPointer);
            return((SmoothPathResult)smoothPathResult);
        }
Ejemplo n.º 7
0
        public NavMeshQuery CreateNavMeshQuery(NavMesh navMesh)
        {
            var handle = RecastLibrary.navmesh_query_create(navMesh.DangerousGetHandle());

            return(new NavMeshQuery(handle));
        }
Ejemplo n.º 8
0
 public NavMesh CreateNavMesh(NavMeshDataResult navMeshDataResult)
 {
     return(new NavMesh(RecastLibrary.navmesh_create(_context.DangerousGetHandle(), ref navMeshDataResult)));
 }
Ejemplo n.º 9
0
        public PolyMeshDetail CreatePolyMeshDetail(RcConfig config, PolyMesh polyMesh, CompactHeightfield chf)
        {
            var handle = RecastLibrary.polymesh_detail_create(_context.DangerousGetHandle(), ref config, polyMesh.DangerousGetHandle(), chf.DangerousGetHandle());

            return(new PolyMeshDetail(handle));
        }
Ejemplo n.º 10
0
        public PolyMesh CreatePolyMesh(RcConfig config, CompactHeightfield chf)
        {
            var handle = RecastLibrary.polymesh_create(_context.DangerousGetHandle(), ref config, chf.DangerousGetHandle());

            return(new PolyMesh(handle));
        }
Ejemplo n.º 11
0
        public CompactHeightfield CreateCompactHeightfield(RcConfig config, InputGeom geom)
        {
            var handle = RecastLibrary.compact_heightfield_create(_context.DangerousGetHandle(), ref config, geom.DangerousGetHandle());

            return(new CompactHeightfield(handle));
        }
Ejemplo n.º 12
0
 public void CalcGridSize(ref RcConfig config, InputGeom geom)
 {
     RecastLibrary.rcConfig_calc_grid_size(ref config, geom.DangerousGetHandle());
 }
Ejemplo n.º 13
0
        public InputGeom LoadInputGeom(string path, bool invertYZ)
        {
            var handle = RecastLibrary.InputGeom_load(_context.DangerousGetHandle(), path, invertYZ);

            return(new InputGeom(handle));
        }
Ejemplo n.º 14
0
 public static bool IsUsing64BitPolyRefs()
 {
     return(RecastLibrary.dtPolyRef_is_64bit());
 }
Ejemplo n.º 15
0
 public RecastContext()
 {
     _context = new RcContext(RecastLibrary.rcContext_create());
     RecastLibrary.random_set_seed(new Random().Next());
 }