Skip to content

FxVoxelGrid ​

This module contains functions for editing the voxel grid of an active VoxelLayer node. A node is active if it is selected and is either the only selected node or the first selected node. Each VoxelLayer node has a grid for each LOD. Only the grid of the active LOD is used. To activate a node and LOD use Activate.

The active grid is the voxel grid of the active VoxelLayer node and the active LOD.

Load ​

lua
FxVoxelGrid = require "FxVoxelGrid";

Functions ​

FunctionDescription
Activate (NodeID, LOD)Activates a voxel grid.
Deselect ()Deselects all voxels.
EditBox (X, Y, Z, Width, Height, Depth, EditMethod, Voxel)Edits voxels inside a box.
EditLine (StartX, StartY, StartZ, EndX, EndY, EndZ, EditMethod, Voxel)Edits voxels in a straight line.
EditPoint (X, Y, Z, EditMethod, Voxel)Edits a single voxel.
InvertSelection ()Inverts voxel selection.
IsAnySelected ()Returns whether any voxel of the grid is selected.
IsSelected (X, Y, Z)Returns whether a voxel of the grid is selected.
IsSolid (X, Y, Z)Returns whether a voxel of the grid is solid.
Read (X, Y, Z)Returns the voxel at a position.
SelectAll ()Selects all voxels.
Write (X, Y, Z, Voxel)Sets the voxel at a position.

Activate (NodeID, LOD) ​

This function activates the specified node if it is a VoxelLayer node. The voxel grid of the active VoxelLayer node at the specified LOD becomes the active grid.

Parameters ​

  • NodeID: The NodeID of the VoxelLayer to activate.
  • LOD: The LOD to activate

Errors ​

Possible errors include FX_REQUIRED_ASSET_UNAVAILABLE, FX_NODE_NOT_FOUND

Since ​

Version 1.0

Example ​

lua
-- activate voxel grid of layer1
FxVoxelGrid.Activate("layer1", 0);

Deselect () ​

This function deselects all voxels of the active grid.

Errors ​

Possible errors include FX_REQUIRED_GRID_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
FxVoxelGrid.Deselect();

EditBox (X, Y, Z, Width, Height, Depth, EditMethod, Voxel) ​

This function edits the voxels inside the specified box using the specified edit method and voxel. Depending on the edit method the whole voxel, only parts of it, or none of it will be used. For example, if the edit method is paint, only the color of the voxel is used. Or, if the edit method is erase then the voxel is ignored.

Parameters ​

  • X: The X coordinate of the box position
  • Y: The Y coordinate of the box position
  • Z: The Z coordinate of the box position
  • Width: The box width
  • Height: The box height
  • Depth: The box depth
  • EditMethod: The EditMethod
  • Voxel: The FoxelVoxel

Errors ​

Possible errors include FX_REQUIRED_GRID_UNAVAILABLE. FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
-- coat a box area with material 10
voxel = FxVoxel.Create(0, 10);
FxVoxelGrid.EditBox(0, 0, 0, 5, 5, 5, 3, voxel);

EditLine (StartX, StartY, StartZ, EndX, EndY, EndZ, EditMethod, Voxel) ​

This function edits a straight line between the two specified coordinates using the specified edit method and voxel. Depending on the edit method the whole voxel, only parts of it, or none of it will be used. For example, if the edit method is paint, only the color of the voxel is used. Or, if the edit method is erase then the voxel is ignored.

Parameters ​

  • StartX: The X coordinate of the start of the line
  • StartY: The Y coordinate of the start of the line
  • StartZ: The X coordinate of the start of the line
  • EndX: The X coordinate of the end of the line
  • EndY: The Y coordinate of the end of the line
  • EndZ: The Z coordinate of the end of the line
  • EditMethod: The EditMethod
  • Voxel: The FoxelVoxel

Errors ​

Possible errors include FX_REQUIRED_GRID_UNAVAILABLE, FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
-- draw a line from (0,0,0) to (5,5,5)
FxVoxelGrid.EditLine(0, 0, 0, 5, 5, 5, 1, voxel);

EditPoint (X, Y, Z, EditMethod, Voxel) ​

This function edits a single voxel at the specified coordinates using the specified edit method and voxel. Depending on the edit method the whole voxel, only parts of it, or none of it will be used. For example, if the edit method is paint, only the color of the voxel is used. Or, if the edit method is erase then the voxel is ignored.

Parameters ​

  • X: The X coordinate of the voxel
  • Y: The Y coordinate of the voxel
  • Z: The Z coordinate of the voxel
  • EditMethod: The EditMethod
  • Voxel: The FoxelVoxel

Errors ​

Possible errors include FX_REQUIRED_GRID_UNAVAILABLE, FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
-- paint the voxel at (2,3,4) with color 20
voxel = FxVoxel.Create(20, 0);
FxVoxelGrid.EditPoint(2, 3, 4, 2, voxel);

IsAnySelected () ​

This function returns whether any voxel of the active grid is selected.

Returns ​

The selection state

Errors ​

Possible errors include FX_REQUIRED_GRID_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
if FxVoxelGrid.IsAnySelected() then
	-- do something
end

IsSelected (X, Y, Z) ​

This function returns whether the voxel at the given coordinates is selected.

Parameters ​

  • X: The X coordinate of the voxel
  • Y: The Y coordinate of the voxel
  • Z: The Z coordinate of the voxel

Returns ​

The selection state of the voxel

Errors ​

Possible errors include FX_REQUIRED_GRID_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
if FxVoxelGrid.IsSelected(0, 0, 0) then
	-- do something
end

IsSolid (X, Y, Z) ​

This function returns whether the voxel at the given coordinates is solid.

Parameters ​

  • X: The X coordinate of the voxel
  • Y: The Y coordinate of the voxel
  • Z: The Z coordinate of the voxel

Returns ​

The solid state of the voxel

Errors ​

Possible errors include FX_REQUIRED_GRID_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
if FxVoxelGrid.IsSolid(0, 0, 0) then
	-- do something
end

InvertSelection () ​

This function toggles the selection status of all solid voxels of the active grid.

Errors ​

Possible errors include FX_REQUIRED_GRID_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
-- select all solid voxels that are outside of a box:
FxVoxelGrid.EditBox(5, 5, 5, 10, 10, 10, 11, 0);
FxVoxelGrid.InvertSelection();

Read (X, Y, Z) ​

This function returns the voxel at the given coordinates.

Parameters ​

  • X: The X coordinate of the voxel
  • Y: The Y coordinate of the voxel
  • Z: The Z coordinate of the voxel

Returns ​

The FoxelVoxel

Errors ​

Possible errors include FX_REQUIRED_GRID_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
voxel = FxVoxelGrid.Read(4, 5, 6);

SelectAll () ​

This function selects all solid voxels of the active grid.

Errors ​

Possible errors include FX_REQUIRED_GRID_UNAVAILABLE

Since ​

Version 1.0

Example ​

lua
FxVoxelGrid.SelectAll();

Write (X, Y, Z, Voxel) ​

This function sets the voxel at the given coordinates.

Parameters ​

  • X: The X coordinate of the voxel
  • Y: The Y coordinate of the voxel
  • Z: The Z coordinate of the voxel
  • Voxel: The new FoxelVoxel

Errors ​

Possible errors include FX_REQUIRED_GRID_UNAVAILABLE, FX_VALUE_INVALID

Since ​

Version 1.0

Example ​

lua
-- erase voxel at (4,5,6)
FxVoxelGrid.Write(4, 5, 6, 0);