25 namespace VoxelGridUtils
42 gridPosition *= (1.0 / voxelSize);
44 (
agx::Int)std::floor(gridPosition.
y() + 0.5),
45 (
agx::Int)std::floor(gridPosition.
z() + 0.5) );
56 static_cast<agx::Real>((voxelIndex.
y()))* voxelSize,
57 static_cast<agx::Real>((voxelIndex.
z()))* voxelSize );
85 corners[0] = voxelCenter +
agx::Vec3(-h, -h, -h);
86 corners[1] = voxelCenter +
agx::Vec3(+h, -h, -h);
87 corners[2] = voxelCenter +
agx::Vec3(-h, +h, -h);
88 corners[3] = voxelCenter +
agx::Vec3(+h, +h, -h);
90 corners[4] = voxelCenter +
agx::Vec3(-h, -h, +h);
91 corners[5] = voxelCenter +
agx::Vec3(+h, -h, +h);
92 corners[6] = voxelCenter +
agx::Vec3(-h, +h, +h);
93 corners[7] = voxelCenter +
agx::Vec3(+h, +h, +h);
95 static const int edges[12][2] = {
115 for (
int e = 0; e < 12; ++e) {
120 const agx::Vec3& p0 = corners[a] * gridTransform;
121 const agx::Vec3& p1 = corners[b] * gridTransform;
131 for (
const auto& v : voxels)
132 renderVoxel(v, color, voxelSize, gridTransform, size);
Axis aligned bounding box implementation.
Utility color class with "common colors".
static RenderSingleton * instance()
void add(const Point &point)
Add temporary point (sphere).
Vector containing 'raw' data.
agx::Vec3 getGridPositionFromVoxelIndex(agx::Vec3i voxelIndex, agx::Real voxelSize)
agx::Vec3i getVoxelIndexFromGridPosition(agx::Vec3 gridPosition, agx::Real voxelSize)
void renderVoxels(const agx::Vec3iVector &voxels, const agxRender::Color &color, agx::Real voxelSize, const agx::AffineMatrix4x4 &gridTransform, agx::Real size)
agx::Bound3 transformBound(const agx::Bound3 &bound, const agx::AffineMatrix4x4 &gridInvTransform, agx::Real extend=agx::Real(0))
Transforms a world bound to grid given grid transform and additional/extended size.
void renderVoxel(const agx::Vec3i voxel, const agxRender::Color &color, agx::Real voxelSize, const agx::AffineMatrix4x4 &gridTransform, agx::Real size)
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.