Search Results for

    Show / Hide Table of Contents

    Class VoxelMesher

    This class manages a naive mesh for a voxel grid.

    It can generate the naive mesh and can map any face index on the generated mesh to a voxel face. This is used by the tile map editor to select which voxel to fill/clear when clicking on the voxel grid. It can also be used at runtime to test for mouse clicks in a live level editor.

    The generated meshes contain faces for each of the filled-to-unfilled surfaces in the grid, as well as walls surrounding the whole grid.

    Inheritance
    System.Object
    VoxelMesher
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: CarbideFunction.Wildtile
    Syntax
    public class VoxelMesher

    Properties

    TempMeshInstance

    Readonly access to the spawned GameObject.

    Declaration
    public GameObject TempMeshInstance { get; }
    Property Value
    Type Description
    GameObject

    Methods

    ChangeMaterials(Material, Material, Material)

    Swap the materials of the surfaces in the already spawned GameObject.

    Declaration
    public void ChangeMaterials(Material material, Material wallsMaterial, Material voxelsTouchingWallsMaterial)
    Parameters
    Type Name Description
    Material material
    Material wallsMaterial
    Material voxelsTouchingWallsMaterial

    CreateAndGenerateMesh(IVoxelGrid, Vector3)

    Generates a simple mesh for the voxel grid, intended for use with level editors. It also populates trianglesToFaceDataToUpdate with information about which coordinate is behind the tile and which is in front of the tile, making it easier to add or remove tiles when you click on them.

    The output includes two submeshes: Submesh zero holds the map's surface. Submesh one holds the map's boundary, facing inwards.

    Declaration
    public static VoxelMesher.GeneratedMesh CreateAndGenerateMesh(IVoxelGrid map, Vector3 tileDimensions)
    Parameters
    Type Name Description
    IVoxelGrid map

    A map of filled/empty cubes. This map's surface will be created and saved in the output meshToPopulate.

    Vector3 tileDimensions

    The size of the bounding box for an individual tile in the tileset

    Returns
    Type Description
    VoxelMesher.GeneratedMesh

    Returns the mesh and associated triangle data as a VoxelMesher.GeneratedMesh.

    CreateMeshedVoxels(IVoxelGrid, Vector3, Material, Material, Material, Transform, Int32, HideFlags)

    Immediately spawn a temporary mesh GameObject, create a mesh, and assign the mesh to the new GameObject

    Declaration
    public void CreateMeshedVoxels(IVoxelGrid map, Vector3 tileDimensions, Material material, Material wallsMaterial, Material voxelTouchingBorderMaterial, Transform targetTransform, int layerIndex, HideFlags hideFlags = null)
    Parameters
    Type Name Description
    IVoxelGrid map
    Vector3 tileDimensions
    Material material
    Material wallsMaterial
    Material voxelTouchingBorderMaterial
    Transform targetTransform
    System.Int32 layerIndex
    HideFlags hideFlags

    DestroyMeshedVoxels()

    Immediately destroy the spawned GameObject and release all references to the created mesh and creation data, allowing the C# GC to reclaim them.

    Declaration
    public void DestroyMeshedVoxels()

    GetFaceDataForTriIndex(Int32)

    Gets the VoxelMesher.FaceData for a triangle in the generated mesh. The mesh must have been generated first by calling RegenerateMeshedVoxels(IVoxelGrid, Vector3).

    The triangle index is expected to come from a physics raycast based on where the user clicks.

    Declaration
    public VoxelMesher.FaceData GetFaceDataForTriIndex(int triangleIndex)
    Parameters
    Type Name Description
    System.Int32 triangleIndex
    Returns
    Type Description
    VoxelMesher.FaceData

    RegenerateMeshedVoxels(IVoxelGrid, Vector3)

    Recreate the mesh and apply it to the already spawned GameObject.

    Declaration
    public void RegenerateMeshedVoxels(IVoxelGrid map, Vector3 tileDimensions)
    Parameters
    Type Name Description
    IVoxelGrid map
    Vector3 tileDimensions
    In This Article
    Generated by DocFX Wildtile Documentation