ZLab.Discrete ZLab.Discrete
ZLab.Discrete ZLab.Discrete
Developed by Zeke Zhang

Search Results for

    Edit this page

    Rasterization

    Dense rasterization

    This will result in a dense occupancy grid where each voxel is classified as Inside, Outside, or Boundary.

    // Flood fill classifies interior; requires a closed mesh
    DenseRasterizer.RasterizeMesh(oGrid, mesh, floodFill: true);
    
    • oGrid will be mutated.
    • floodFill is optional and defaults to false. It is recommended to set it to true if the mesh is closed (watertight) to correctly identify interior voxels. This is a post-processing step that fills in the interior of the mesh after rasterization.

    Sparse rasterization

    This will only return a list of voxel origins that are classified as Boundary.

    List<Vector3> origins = SparseRasterizer.RasterizeMesh(Mesh, size);
    

    Polyline Rasterization

    The library supports voxelizing polylines into a 3D grid. This is useful for applications like pathfinding, spatial analysis, or visualizing line-based geometries in a voxel representation.

    Example: Voxelizing a Polyline

    PolylineF polyline = new(new Vector3[] {
        new(0, 0, 0),
        new(1, 2, 1),
        new(2, 0, 2),
        new(3, 3, 3)
    });
    
    // sparse voxelization with a voxel size of 0.1 in all dimensions
    List<Vector3> origins = SparseVoxelization.RasterizePolyline(polyline, new Vector3(0.1f, 0.1f, 0.1f));
    
    // dense voxelization into an occupancy grid
    OccupancyGrid oGrid = new(
        voxelSize: new Vector3(0.1f, 0.1f, 0.1f),
        bounds: polyline.GetBounds()
    );
    
    DenseVoxelization.RasterizePolyline(oGrid, polyline);