コード例 #1
0
ファイル: RecatGridTest.cs プロジェクト: zh880517/UnityLib
    public void Test()
    {
        var bounds = RecastBuilder.GetBoundsFromGameObject(gameObject);

        //bounds.Expand(2.0f);
        bounds = RecastBuilder.AlignBounds(bounds);
        bounds.Expand(new Vector3(0, 1.6f, 0));
        voxel = RecastBuilder.Creat(bounds, Size);
        RecastBuilder.AddGameObject(voxel, gameObject);
        Vector3 min = voxel.Bounds.min;

        heightfield = RecastBuilder.VoxelToHeightfield(voxel);
        var bitMask = RecastBuilder.VoxelizationWalkableFilter(voxel);

        if (ValidPoint)
        {
            var        pos       = Vector3Int.CeilToInt((ValidPoint.position - min) / voxel.CellSize);
            Vector2Int pt        = new Vector2Int(pos.x, pos.z);
            Vector2Int size      = new Vector2Int(voxel.Size.x, voxel.Size.z);
            var        validMask = RecastBuilder.CalcClosePoint(bitMask, size, pt);
            gridData = new RecastGridData
            {
                OriginPoint = new Vector3(min.x, min.z),
                Width       = voxel.Size.x,
                Length      = voxel.Size.z,
                Mask        = new SerializBitArray(validMask)
            };
        }
        else
        {
            gridData = RecastBuilder.VoxelizationToGrid(voxel);
        }
    }
コード例 #2
0
    public void Test()
    {
        var bounds = RecastBuilder.GetBoundsFromGameObject(gameObject);

        //bounds.Expand(2.0f);
        bounds = RecastBuilder.AlignBounds(bounds);
        bounds.Expand(new Vector3(0, 1.6f, 0));
        voxel = RecastBuilder.Creat(bounds, Size);
        RecastBuilder.AddGameObject(voxel, gameObject);
        Vector3 min = voxel.Bounds.min;

        heightfield = RecastBuilder.VoxelToHeightfield(voxel);
        gridData    = RecastBuilder.HeightfieldToPlaneGrid(heightfield, 0, 2);
        //var bitMask = RecastBuilder.VoxelizationWalkableFilter(voxel);
        if (ValidPoint)
        {
            var        pos  = Vector3Int.CeilToInt((ValidPoint.position - min) / voxel.CellSize);
            Vector2Int pt   = new Vector2Int(pos.x, pos.z);
            Vector2Int size = new Vector2Int(voxel.Size.x, voxel.Size.z);
            gridData.Mask = RecastBuilder.CalcClosePoint(gridData.Mask, size, pt);
        }
    }
コード例 #3
0
ファイル: RecatGridTest.cs プロジェクト: zh880517/UnityLib
 public void Clear()
 {
     voxel = null;
 }