Volume

class nvisii.volume(*args, **kwargs)

The “Volume” component is essentially the dual of a mesh component. As a result, entities can have a mesh component or a volume component attached, but not both.

With a mesh component, surfaces are explicitly defined using triangles, and the volumes separating that surface are implicit (eg air outside vs glass inside). With a Volume component, that’s reversed. Voxels are used to explicitly represent the density of particles in space, and surfaces are implicitly defined in areas where particles are dense.

static are_any_dirty()

Indicates whether or not any entities are “out of date” and need to be updated through the “update components” function

static clear_all()

Clears any existing Volume components.

static create_box(*args, **kwargs)

Creates a sparse fog volume of a box such that the exterior is 0 and inactive, the interior is active with values varying smoothly from 0 at the surface of the box to 1 at the half width and interior of the box. :type name: string :param name: The name of the volume to create. :type size: vec3, optional :param size: The width, height, and depth of the box in local units. :type center: vec3, optional :param center: The center of the box in local units :type half_width: float, optional :param half_width: The half-width of the narrow band in voxel units

static create_from_data(name, width, height, depth, data, background)

Constructs a Volume with the given name from custom user data. :type name: string :param name: The name of the volume to create. :type width: int :param width: The width of the volume. :type height: int :param height: The height of the volume. :type depth: int :param depth: The depth of the volume. :type data: float :param data: A row major flattened vector of single-scalar voxels.

The length of this vector should be width * height * depth.

Parameters

background (float) – If a voxel matches this value, that voxel is considered as “empty”. This is used to “sparcify” the volume and save memory.

static create_from_file(name, path)

Constructs a Volume with the given name from a file. :type name: string :param name: The name of the volume to create.

Supported formats include NanoVDB (.nvdb)

Parameters

path (string) – The path to the file.

Return type

Volume

Returns

a Volume allocated by the renderer.

static create_octahedron(name)

Creates a sparse fog volume of an octahedron such that the exterior is 0 and inactive, the interior is active with values varying smoothly from 0 at the surface of the octahedron to 1 at the half width and interior of the octahedron

static create_sphere(name)

Creates a sparse fog volume of a sphere such that the exterior is 0 and inactive, the interior is active with values varying smoothly from 0 at the surface of the sphere to 1 at the half width and interior of the sphere.

static create_torus(name)

Creates a sparse fog volume of a torus in the xz-plane such that the exterior is 0 and inactive, the interior is active with values varying smoothly from 0 at the surface of the torus to 1 at the half width and interior of the torus.

static get(name)
Parameters

name (string) – The name of the Volume to get

Return type

Volume

Returns

a Volume who’s name matches the given name

get_aabb_center(level, node_idx)
Parameters
  • level (int) – The level of nodes being referenced (0->3 = leaf -> root).

  • node_idx (int) – The index of the node within the selected level.

Return type

vec3

Returns

the center of the aligned bounding box for a node

static get_count()
Return type

int

Returns

the number of allocated volumes

static get_dirty_volumes()
Return type

std::set< nvisii::Volume * >

Returns

a list of volumes that have been modified since the previous frame

static get_edit_mutex()

For internal use. Returns the mutex used to lock entities for processing by the renderer.

static get_front()
Return type

Volume

Returns

a pointer to the table of Volume components

static get_front_struct()
Return type

VolumeStruct

Returns

a pointer to the table of VolumeStructs

get_grid_type()
Return type

string

Returns

the type of the volume’s scalar field

get_id()
Return type

int

Returns

the unique integer ID for this component

get_max(level, node_idx)

todo… document

get_max_aabb_corner(level, node_idx)
Parameters
  • level (int) – The level of nodes being referenced (0->3 = leaf -> root).

  • node_idx (int) – The index of the node within the selected level.

Return type

vec3

Returns

the maximum node axis aligned bounding box position

get_min_aabb_corner(level, node_idx)
Parameters
  • level (int) – The level of nodes being referenced (0->3 = leaf -> root).

  • node_idx (int) – The index of the node within the selected level.

Return type

vec3

Returns

the minimum node axis aligned bounding box position

get_name()
Return type

string

Returns

the name of this component

static get_name_to_id_map()
Return type

std::map< std::string,uint32_t,std::less< std::string >,std::allocator< std::pair< std::string const,uint32_t > > >

Returns

A map whose key is a volume name and whose value is the ID for that volume

get_nano_vdbgrid_handle()
Return type

std::shared_ptr< nanovdb::GridHandle< > >

Returns

the handle to the nanovdb grid. For internal purposes.

get_node_count(level)
Parameters

level (int) – The level of nodes being referenced (0->3 = leaf -> root)

Return type

int

Returns

the number of nodes, or subvolumes, used to store a volume. (See the illustration of the NanoVDB data structure for more details)

static initialize_factory(max_components)

Allocates the tables used to store all Volume components

static is_factory_initialized()
Return type

boolean

Returns

True if the tables used to store all Volume components have been allocated, and False otherwise

is_initialized()
Return type

boolean

Returns

True the current Volume is a valid, initialized Volume, and False if the Volume was cleared or removed.

mark_dirty()

Tags the current component as being modified since the previous frame.

static remove(name)
Parameters

name (string) – The name of the Volume to remove

set_absorption(absorption)

todo… document

set_gradient_factor(factor)

todo… document

set_scale(units)

todo… document

set_scattering(scattering)

todo… document

property thisown

The membership flag

to_string()
Return type

string

Returns

a json string representation of the current component

static update_components()

Iterates through all components, updating any component struct fields and marking components as clean.