Voxel toolkit
The toolkit that lets you easily import .vox assets and have runtime API
Loading...
Searching...
No Matches
VoxelToolkit.VoxelObject Class Reference

The class responsible for a voxel meshes generation. More...

Inheritance diagram for VoxelToolkit.VoxelObject:

Public Member Functions

 VoxelObject (Vector3Int size, ReadonlyArray< Material > palette, int chunkSize)
 Creates the voxel object of the given size and chunks size.
 
 VoxelObject (Vector3Int size, int chunkSize)
 Creates the voxel object of the given size and chunks size.
 
void SetMaterial (byte index, Material material)
 Sets the material for the voxel object.
 
MeshDescriptor GetMesh (int index)
 Get access to the generated mesh.
 
void CopyTo (VoxelObject other)
 Copies the voxel object from one to another.
 
bool IsInVolume (Vector3Int value)
 Checks if the voxel position belongs to the voxel object volume.
 
bool IsInVolume (int3 value)
 Checks if the voxel position belongs to the voxel object volume.
 
void UpdateMeshes (IndexFormat indexFormat, Vector3 shift=new Vector3())
 Regenerates meshes.
 
void DeleteMeshes ()
 Deletes all generated meshes.
 
void Dispose ()
 Disposes the voxel object.
 
void DisposeWithoutMeshes ()
 Disposes the voxel object but keeps meshes alive.
 
Model ToModel ()
 Transforms voxel object to model.
 

Static Public Member Functions

static VoxelObject CreateFromModel (Model model, ReadonlyArray< Material > palette, int chunkSize)
 Creates voxel object directly from voxel model.
 

Properties

int MeshesCount [get]
 The count of the generated meshes.
 
float HueShift [get, set]
 The hue shift to be applied to the materials.
 
float Saturation [get, set]
 Saturation to be applied to the materials.
 
float Brightness [get, set]
 Brightness to be applied to the materials.
 
MeshGenerationApproach MeshGenerationApproach [get, set]
 
float Scale [get, set]
 The scale of the voxel object.
 
float OpaqueEdgeShift [get, set]
 The shift of the edge of the voxel object applied for opaque objects.
 
float TransparentEdgeShift [get, set]
 The shift of the edge of the voxel object applied for transparent objects.
 
int3 Size [get]
 Provides the size of the voxel object.
 
Vector3Int ChunksCount [get]
 The count of the chunks for the current voxel object.
 
Voxel this[Vector3Int position] [get, set]
 Provides access to a specific voxel of the voxel object.
 
Voxel this[int3 position] [get, set]
 Provides access to a specific voxel of the voxel object.
 

Detailed Description

The class responsible for a voxel meshes generation.

Constructor & Destructor Documentation

◆ VoxelObject() [1/2]

VoxelToolkit.VoxelObject.VoxelObject ( Vector3Int  size,
ReadonlyArray< Material palette,
int  chunkSize 
)

Creates the voxel object of the given size and chunks size.

Parameters
sizeThe size of the voxel object
paletteThe palette to be used for the mesh generation
chunkSizeThe chunk size of the voxel object

◆ VoxelObject() [2/2]

VoxelToolkit.VoxelObject.VoxelObject ( Vector3Int  size,
int  chunkSize 
)

Creates the voxel object of the given size and chunks size.

Parameters
sizeThe size of the voxel object
chunkSizeThe chunk size of the voxel object

Member Function Documentation

◆ CopyTo()

void VoxelToolkit.VoxelObject.CopyTo ( VoxelObject  other)

Copies the voxel object from one to another.

Parameters
otherThe object to copy to

◆ CreateFromModel()

static VoxelObject VoxelToolkit.VoxelObject.CreateFromModel ( Model  model,
ReadonlyArray< Material palette,
int  chunkSize 
)
static

Creates voxel object directly from voxel model.

Parameters
modelThe voxel model voxel object to be created from
paletteThe palette used for mesh generation
chunkSizeThe chunk size of the object to be generated
Returns

◆ GetMesh()

MeshDescriptor VoxelToolkit.VoxelObject.GetMesh ( int  index)

Get access to the generated mesh.

Parameters
indexThe index of the mesh to obtain
Returns
Mesh descriptor of the requested mesh

◆ IsInVolume() [1/2]

bool VoxelToolkit.VoxelObject.IsInVolume ( int3  value)

Checks if the voxel position belongs to the voxel object volume.

Parameters
valueThe position to check
Returns
True if the position is inside the voxel object volume. False if not.

◆ IsInVolume() [2/2]

bool VoxelToolkit.VoxelObject.IsInVolume ( Vector3Int  value)

Checks if the voxel position belongs to the voxel object volume.

Parameters
valueThe position to check
Returns
True if the position is inside the voxel object volume. False if not.

◆ SetMaterial()

void VoxelToolkit.VoxelObject.SetMaterial ( byte  index,
Material  material 
)

Sets the material for the voxel object.

Parameters
indexThe index of the material to be set
materialThe material to be set

◆ ToModel()

Model VoxelToolkit.VoxelObject.ToModel ( )

Transforms voxel object to model.

Returns
Model representing the voxel object

◆ UpdateMeshes()

void VoxelToolkit.VoxelObject.UpdateMeshes ( IndexFormat  indexFormat,
Vector3  shift = new Vector3() 
)

Regenerates meshes.

Parameters
indexFormatThe index format to be used for the meshes
generationApproachThe generation approach to be taken to generate meshes
shiftThe shift applied to the vertices

Property Documentation

◆ this[int3 position]

Voxel VoxelToolkit.VoxelObject.this[int3 position]
getset

Provides access to a specific voxel of the voxel object.

Parameters
positionThe position of the voxel

◆ this[Vector3Int position]

Voxel VoxelToolkit.VoxelObject.this[Vector3Int position]
getset

Provides access to a specific voxel of the voxel object.

Parameters
positionThe position of the voxel

The documentation for this class was generated from the following file: