FxVoxel ​
This module contains functions for creating and editing FoxelVoxel values.
Load ​
FxVoxel = require "FxVoxel";Functions ​
| Function | Description |
|---|---|
| Create (Color, Material) | Creates a voxel. |
| Flip (Voxel, Axis) | Flips a voxel. |
| GetColor (Voxel) | Returns the color of a voxel. |
| GetMaterial (Voxel) | Returns the material of a voxel. |
| GetRotation (Voxel) | Returns the rotation of a voxel. |
| GetShape (Voxel) | Returns the shape of a voxel. |
| Rotate90 (Voxel, Axis, Steps) | Rotates a voxel in 90° steps. |
| SetColor (Voxel, Value) | Sets the color of a voxel. |
| SetMaterial (Voxel, Value) | Sets the material of a voxel. |
| SetRotation (Voxel, Value) | Sets the rotation of a voxel. |
| SetShape (Voxel, Value) | Sets the shape of a voxel. |
Create (Color, Material) ​
This function creates a voxel from the given color and material ItemIndex. All other properties are set to their default values.
Parameters ​
Returns ​
The created FoxelVoxel
Errors ​
Possible errors include FX_ITEM_INDEX_INVALID
Since ​
Version 1.0
Example ​
voxel = FxVoxel.Create(10, 0);Flip (Voxel, Axis) ​
This function flips a voxel along the given axis and returns the updated voxel.
Parameters ​
- Voxel: The FoxelVoxel to flip
- Axis: The flip Axis3D
Returns ​
The updated FoxelVoxel
Errors ​
Possible errors include FX_VALUE_INVALID
Since ​
Version 1.0
Example ​
-- flip voxel along x-axis
voxel = FxVoxel.Flip(voxel, 0);GetColor (Voxel) ​
This function returns the color ItemIndex of the given voxel. This index can be used for example with FxColorPalette to get the color properties.
Parameters ​
- Voxel: The FoxelVoxel to query
Returns ​
The color ItemIndex of the voxel
Errors ​
Possible errors include FX_VALUE_INVALID
Since ​
Version 1.0
Example ​
colorid = FxVoxel.GetColor(voxel);
color = FxColorPalette.GetItemColor(colorid);GetMaterial (Voxel) ​
This function returns the material of the given voxel. This index can be used for example with FxMaterialSet to get the material properties.
Parameters ​
- Voxel: The FoxelVoxel to query
Returns ​
The material ItemIndex of the voxel
Errors ​
Possible errors include FX_VALUE_INVALID
Since ​
Version 1.0
Example ​
material = FxVoxel.GetMaterial(voxel);
metallic = FxMaterialMap.GetItemMetallic(material);GetRotation (Voxel) ​
This function returns the cube rotation of the given voxel.
Parameters ​
- Voxel: The FoxelVoxel to query
Returns ​
The CubeRotation of the voxel
Errors ​
Possible errors include FX_VALUE_INVALID
Since ​
Version 1.0
Example ​
rotation = FxVoxel.GetRotation(voxel);GetShape (Voxel) ​
This function returns the shape of the given voxel.
Parameters ​
- Voxel: The FoxelVoxel to query
Returns ​
The VoxelShape of the voxel
Errors ​
Possible errors include FX_VALUE_INVALID
Since ​
Version 1.0
Example ​
shape = FxVoxel.GetShape(voxel);Rotate90 (Voxel, Axis, Steps) ​
This function rotates the voxel around the given axis and returns the updated voxel.
Parameters ​
- Voxel: The FoxelVoxel to rotate
- Axis: The rotation Axis3D
- Steps: The number of 90° rotation steps
Returns ​
The updated FoxelVoxel
Errors ​
Possible errors include FX_VALUE_INVALID
Since ​
Version 1.0
Example ​
-- rotate voxel 180° around y-axis
voxel = FxVoxel.Rotate90(voxel, 1, 2);SetColor (Voxel, Value) ​
This function changes the color of the given voxel and returns the updated voxel.
Parameters ​
- Voxel: The FoxelVoxel
- Value: The new color ItemIndex
Returns ​
The updated FoxelVoxel
Errors ​
Possible errors include FX_VALUE_INVALID, FX_ITEM_INDEX_INVALID
Since ​
Version 1.0
Example ​
voxel = FxVoxel.SetColor(voxel, 100);SetMaterial (Voxel, Value) ​
This function changes the material of the given voxel and returns the updated voxel.
Parameters ​
- Voxel: The FoxelVoxel
- Value: The new material ItemIndex
Returns ​
The updated FoxelVoxel
Errors ​
Possible errors include FX_VALUE_INVALID, FX_ITEM_INDEX_INVALID
Since ​
Version 1.0
Example ​
voxel = FxVoxel.SetMaterial(voxel, 2);SetRotation (Voxel, Value) ​
This function changes the rotation of the given voxel and returns the updated voxel.
Parameters ​
- Voxel: The FoxelVoxel
- Value: The new CubeRotation
Returns ​
The updated FoxelVoxel
Errors ​
Possible errors include FX_VALUE_INVALID
Since ​
Version 1.0
Example ​
voxel = FxVoxel.SetRotation(voxel, 15);SetShape (Voxel, Value) ​
This function changes the shape of the given voxel and returns the updated voxel.
Parameters ​
- Voxel: The FoxelVoxel
- Value: The new VoxelShape
Returns ​
The updated FoxelVoxel
Errors ​
Possible errors include FX_VALUE_INVALID
Since ​
Version 1.0
Example ​
voxel = FxVoxel.SetShape(voxel, 2);