Voxel toolkit
The toolkit that lets you easily import .vox assets and have runtime API
Loading...
Searching...
No Matches
VoxelToolkit.DynamicVoxelObject Class Reference
Inheritance diagram for VoxelToolkit.DynamicVoxelObject:

Public Member Functions

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 SetMaterial (byte index, Material material)
 Changes the material at a given index.
 
void Clear ()
 Clears the voxel object.
 
bool Raycast (Ray ray, out RaycastHit hit)
 Finds an intersection of the ray and the voxel object.
 
void SetupFromModel (Model model, ReadonlyArray< Material > palette)
 Setting up the dynamic voxel object from the model prototype.
 
Vector3Int TransformWorldToVoxel (Vector3 worldPosition)
 Transforms world point to voxel coordinates.
 
int3 TransformWorldToVoxel (float3 worldPosition)
 Transforms world point to voxel coordinates.
 
Vector3 TransformVoxelToWorld (Vector3Int voxelPosition)
 Transforms voxel point to world position.
 
float3 TransformVoxelToWorld (int3 voxelPosition)
 Transforms voxel point to world position.
 
void SetSphere (Vector3Int position, int radius, Voxel voxel)
 Replaces the sphere of the voxels at a given position.
 
void QueryVoxelsInSphere (Vector3Int position, int radius, List< VoxelQueryResult > target, VoxelQueryOptions queryOptions=VoxelQueryOptions.Default)
 Fills the list of voxels in the volume.
 

Protected Member Functions

virtual void Update ()
 
virtual void OnValidate ()
 

Properties

Bounds LocalBounds [get]
 The local bounds of the voxel object.
 
UnityEngine.Material OpaqueMaterial [get, set]
 The opaque material to be used for the meshes.
 
UnityEngine.Material TransparentMaterial [get, set]
 The transparent material to be used for the meshes.
 
IndexFormat IndexFormat [get, set]
 Gets/sets the index format used for the mesh.
 
int3 Size [get, set]
 Gets/sets the size of the voxel object which should be strictly larger than 0.
 
float Scale [get, set]
 The scale of the object.
 
int ChunkSize [get, set]
 Provides/sets the chunk size which should be strictly larger than 4.
 
Voxel this[Vector3Int position] [get, set]
 Sets/gets the voxel at/from a given position.
 
Voxel this[int3 position] [get, set]
 Sets/gets the voxel at/from a given position.
 

Member Function Documentation

◆ IsInVolume() [1/2]

bool VoxelToolkit.DynamicVoxelObject.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.DynamicVoxelObject.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.

◆ QueryVoxelsInSphere()

void VoxelToolkit.DynamicVoxelObject.QueryVoxelsInSphere ( Vector3Int  position,
int  radius,
List< VoxelQueryResult target,
VoxelQueryOptions  queryOptions = VoxelQueryOptions::Default 
)

Fills the list of voxels in the volume.

Parameters
positionThe position of the sphere
radiusThe radius of the sphere
targetTarget list to fill
queryOptionsQuery filter options

◆ Raycast()

bool VoxelToolkit.DynamicVoxelObject.Raycast ( Ray  ray,
out RaycastHit  hit 
)

Finds an intersection of the ray and the voxel object.

Parameters
rayThe ray to be casted
hitThe hit result of the raycast
Returns
Returns true if raycast hit ended up hitting the voxel object

◆ SetMaterial()

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

Changes the material at a given index.

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

◆ SetSphere()

void VoxelToolkit.DynamicVoxelObject.SetSphere ( Vector3Int  position,
int  radius,
Voxel  voxel 
)

Replaces the sphere of the voxels at a given position.

Parameters
positionThe center position of the sphere
radiusThe radius of the sphere in voxels
voxelThe voxel prototype to fill the sphere with

◆ SetupFromModel()

void VoxelToolkit.DynamicVoxelObject.SetupFromModel ( Model  model,
ReadonlyArray< Material palette 
)

Setting up the dynamic voxel object from the model prototype.

Parameters
modelThe model to setup from
paletteThe palette to use to setup the voxel object

◆ TransformVoxelToWorld() [1/2]

float3 VoxelToolkit.DynamicVoxelObject.TransformVoxelToWorld ( int3  voxelPosition)

Transforms voxel point to world position.

Parameters
voxelPositionThe position of the voxel to transform
Returns
World coordinates

◆ TransformVoxelToWorld() [2/2]

Vector3 VoxelToolkit.DynamicVoxelObject.TransformVoxelToWorld ( Vector3Int  voxelPosition)

Transforms voxel point to world position.

Parameters
voxelPositionThe position of the voxel to transform
Returns
World coordinates

◆ TransformWorldToVoxel() [1/2]

int3 VoxelToolkit.DynamicVoxelObject.TransformWorldToVoxel ( float3  worldPosition)

Transforms world point to voxel coordinates.

Parameters
worldPositionThe world position to transform
Returns
Voxel coordinate

◆ TransformWorldToVoxel() [2/2]

Vector3Int VoxelToolkit.DynamicVoxelObject.TransformWorldToVoxel ( Vector3  worldPosition)

Transforms world point to voxel coordinates.

Parameters
worldPositionThe world position to transform
Returns
Voxel coordinate

Property Documentation

◆ ChunkSize

int VoxelToolkit.DynamicVoxelObject.ChunkSize
getset

Provides/sets the chunk size which should be strictly larger than 4.

Exceptions
ArgumentExceptionThrows the exception if the chunk size is less than 4

◆ Size

int3 VoxelToolkit.DynamicVoxelObject.Size
getset

Gets/sets the size of the voxel object which should be strictly larger than 0.

Exceptions
ArgumentExceptionThrows if one of the dimensions is smaller or equal to zero

◆ this[int3 position]

Voxel VoxelToolkit.DynamicVoxelObject.this[int3 position]
getset

Sets/gets the voxel at/from a given position.

Parameters
positionThe position of the voxel to be gotten/set

◆ this[Vector3Int position]

Voxel VoxelToolkit.DynamicVoxelObject.this[Vector3Int position]
getset

Sets/gets the voxel at/from a given position.

Parameters
positionThe position of the voxel to be gotten/set

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