class
#include <esp/geo/VoxelWrapper.h>
VoxelWrapper When an object is voxelized, it is given a VoxelWrapper which points to an underlying VoxelGrid and the scene node of the object. This class handles object-specific functionality. Multiple objects will each have there own VoxelWrapper, but each of those VoxelWrappers could share a VoxelGrid if they have the same underlying RenderAssetHandle and Voxel resolution.
Constructors, destructors, conversion operators
-
VoxelWrapper(const std::
string& renderAssetHandle, esp:: scene:: SceneNode* sceneNode, esp:: assets:: ResourceManager& resourceManager, Mn:: Vector3& voxelSize, Mn:: Vector3i& voxelDimensions) - Generates a voxelization with a specified size and dimensions. The voxelization is corner aligned with the object's cumulative bounding box's corner.
Public functions
-
auto getVoxelIndexFromGlobalCoords(const Mn::
Vector3& coords) -> Mn:: Vector3i - Converts a global coordinate into voxel coordinates.
-
auto getGlobalCoordsFromVoxelIndex(const Mn::
Vector3i& index) -> Mn:: Vector3 - Converts a voxel coordinate into the global coordinates of the middle of the specified voxel cell.
-
auto getVoxelGrid() -> std::
shared_ptr<VoxelGrid> - Returns the underlying voxel grid for direct manipulation.
-
auto getExistingGrids() -> std::
vector<std:: pair<std:: string, esp::geo::VoxelGridType>> - Returns a list of existing voxel grids and their types.
-
auto gridExists(const std::
string& gridName) -> bool - Returns a bool true if a grid exists, false otherwise.
-
template<typename T>void addGrid(const std::
string& gridName) - Generates a new empty voxel grid of a specified type.
-
void removeGrid(const std::
string& gridName) - Removes a grid and frees up memory.
-
template<typename T>auto getGrid(const std::
string& gridName) -> Cr::Containers::StridedArrayView<3, T> - Returns a StridedArrayView3D of a grid for easy index access and manipulation.
-
template<typename T>void setVoxel(const Mn::
Vector3i& index, const std:: string& gridName, const T& value) - Sets a voxel at a specified index for a specified grid to a value.
-
template<typename T>auto getVoxel(const Mn::
Vector3i& index, const std:: string& gridName) -> T - Retrieves the voxel value from a grid of a specified type (bool, int, float, Mn::Vector3).
-
auto getVoxelGridDimensions() -> Mn::
Vector3i - Returns the dimensions of the voxel grid.
-
auto getVoxelSize() -> Mn::
Vector3 - Returns the size of a voxel.
-
auto getOffset() -> Mn::
Vector3 - Returns the bounding box minimum offset used for generating an aligned mesh.
-
auto getMaxOffset() -> Mn::
Vector3 - Returns the bounding box maximum offset used for generating an aligned mesh.
-
auto getMeshData(const std::
string& gridName = "Boundary") -> std:: shared_ptr<Mn::Trade::MeshData> - Retrieves the MeshData for a particular voxelGrid. If it does not exist, it will generate the mesh for that grid.
-
auto getMeshGL(const std::
string& gridName = "Boundary") -> Mn::GL::Mesh& - Retrieves the MeshGL used for rendering for a particular voxelGrid. If it does not exist, it will generate the mesh for that grid.
-
void setSceneNode(esp::
scene:: SceneNode* sceneNode_) - Sets the SceneNode of the voxel grid.
-
void setOffset(const Mn::
Vector3& coords) - Sets the offset of the voxel grid.
-
void generateMesh(const std::
string& gridName = "Boundary") - Generates both a MeshData and MeshGL for a particular voxelGrid. Can be a Bool grid or a Vector3 grid.
-
template<typename T>void generateSliceMesh(const std::
string& gridName = "Boundary", int ind = 0, T minVal = 0, T maxVal = 1) - Generates a colored slice of a mesh.
Function documentation
esp:: geo:: VoxelWrapper:: VoxelWrapper(const std:: string& renderAssetHandle,
esp:: scene:: SceneNode* sceneNode,
esp:: assets:: ResourceManager& resourceManager,
Mn:: Vector3& voxelSize,
Mn:: Vector3i& voxelDimensions)
Generates a voxelization with a specified size and dimensions. The voxelization is corner aligned with the object's cumulative bounding box's corner.
Parameters | |
---|---|
renderAssetHandle | The handle for the render asset to which the voxel grid corresponds. |
sceneNode | The scene node the voxel wrapper will be pointing to. |
resourceManager | Used for registering the voxel grid. |
voxelSize | The size of an individual voxel cell. |
voxelDimensions | The dimensions of the voxel grid. |
Mn:: Vector3i esp:: geo:: VoxelWrapper:: getVoxelIndexFromGlobalCoords(const Mn:: Vector3& coords)
Converts a global coordinate into voxel coordinates.
Parameters | |
---|---|
coords | The global coordinate. |
Returns | The voxel index corresponding to the global coordinate. |
Mn:: Vector3 esp:: geo:: VoxelWrapper:: getGlobalCoordsFromVoxelIndex(const Mn:: Vector3i& index)
Converts a voxel coordinate into the global coordinates of the middle of the specified voxel cell.
Parameters | |
---|---|
index | The voxel index. |
Returns | The global coordinate of the middle of the specified voxel cell. |
std:: shared_ptr<VoxelGrid> esp:: geo:: VoxelWrapper:: getVoxelGrid()
Returns the underlying voxel grid for direct manipulation.
Returns | The underlying voxel grid. |
---|
std:: vector<std:: pair<std:: string, esp::geo::VoxelGridType>> esp:: geo:: VoxelWrapper:: getExistingGrids()
Returns a list of existing voxel grids and their types.
Returns | A vector of pairs, where the first element is the voxel grid's name, and the second element is the string of the object's type. |
---|
bool esp:: geo:: VoxelWrapper:: gridExists(const std:: string& gridName)
Returns a bool true if a grid exists, false otherwise.
Parameters | |
---|---|
gridName | The name of the grid. |
Returns | A bool representing whether or not the specified grid exists. |
template<typename T>
void esp:: geo:: VoxelWrapper:: addGrid(const std:: string& gridName)
Generates a new empty voxel grid of a specified type.
Parameters | |
---|---|
gridName | The key underwhich the grid will be registered and accessed. |
Returns | a StridedArrayView3D for the newly created grid. |
void esp:: geo:: VoxelWrapper:: removeGrid(const std:: string& gridName)
Removes a grid and frees up memory.
Parameters | |
---|---|
gridName | The name of the grid to be removed. |
template<typename T>
Cr::Containers::StridedArrayView<3, T> esp:: geo:: VoxelWrapper:: getGrid(const std:: string& gridName)
Returns a StridedArrayView3D of a grid for easy index access and manipulation.
Parameters | |
---|---|
gridName | The name of the grid to be removed. |
Returns | A StridedArrayView3D of the specified grid. |
template<typename T>
void esp:: geo:: VoxelWrapper:: setVoxel(const Mn:: Vector3i& index,
const std:: string& gridName,
const T& value)
Sets a voxel at a specified index for a specified grid to a value.
Parameters | |
---|---|
index | The index of the voxel |
gridName | The voxel grid. |
value | The new value. |
template<typename T>
T esp:: geo:: VoxelWrapper:: getVoxel(const Mn:: Vector3i& index,
const std:: string& gridName)
Retrieves the voxel value from a grid of a specified type (bool, int, float, Mn::Vector3).
Parameters | |
---|---|
index | The index of the voxel |
gridName | The voxel grid. |
Returns | The value from the specified voxel grid. |
Mn:: Vector3i esp:: geo:: VoxelWrapper:: getVoxelGridDimensions()
Returns the dimensions of the voxel grid.
Returns | The Vector3i value representing the dimensions. |
---|
Mn:: Vector3 esp:: geo:: VoxelWrapper:: getVoxelSize()
Returns the size of a voxel.
Returns | The Vector3 value representing the size of a voxel. |
---|
Mn:: Vector3 esp:: geo:: VoxelWrapper:: getOffset()
Returns the bounding box minimum offset used for generating an aligned mesh.
Returns | The Vector3 value representing the offset. |
---|
Mn:: Vector3 esp:: geo:: VoxelWrapper:: getMaxOffset()
Returns the bounding box maximum offset used for generating an aligned mesh.
Returns | The Vector3 value representing the offset. |
---|
std:: shared_ptr<Mn::Trade::MeshData> esp:: geo:: VoxelWrapper:: getMeshData(const std:: string& gridName = "Boundary")
Retrieves the MeshData for a particular voxelGrid. If it does not exist, it will generate the mesh for that grid.
Parameters | |
---|---|
gridName | The key underwhich the desired voxel grid is registered. |
Returns | A shared pointer to the MeshData. |
Mn::GL::Mesh& esp:: geo:: VoxelWrapper:: getMeshGL(const std:: string& gridName = "Boundary")
Retrieves the MeshGL used for rendering for a particular voxelGrid. If it does not exist, it will generate the mesh for that grid.
Parameters | |
---|---|
gridName | The key underwhich the desired voxel grid is registered. |
Returns | A reference to the MeshGL. |
void esp:: geo:: VoxelWrapper:: setSceneNode(esp:: scene:: SceneNode* sceneNode_)
Sets the SceneNode of the voxel grid.
Parameters | |
---|---|
sceneNode_ | The new sceneNode. |
void esp:: geo:: VoxelWrapper:: setOffset(const Mn:: Vector3& coords)
Sets the offset of the voxel grid.
Parameters | |
---|---|
coords | The new offset. |
void esp:: geo:: VoxelWrapper:: generateMesh(const std:: string& gridName = "Boundary")
Generates both a MeshData and MeshGL for a particular voxelGrid. Can be a Bool grid or a Vector3 grid.
Parameters | |
---|---|
gridName | The name of the voxel grid to be converted into a mesh. |
template<typename T>
void esp:: geo:: VoxelWrapper:: generateSliceMesh(const std:: string& gridName = "Boundary",
int ind = 0,
T minVal = 0,
T maxVal = 1)
Generates a colored slice of a mesh.
Parameters | |
---|---|
gridName | The name of the voxel grid to be converted into a mesh slice. |
ind | The index long the x axis for the slicing plane. |
minVal | The minimum value of the grid. Used for determining heatmap colors. |
maxVal | The maximum value of the grid. Used for determining heatmap colors. |