Added support for non-cubic volumes.

This commit is contained in:
David Williams
2009-04-19 22:48:56 +00:00
parent 1f6a3231c1
commit c627c90cd0
9 changed files with 150 additions and 69 deletions

View File

@ -5,14 +5,14 @@ using namespace PolyVox;
void createSphereInVolume(Volume<PolyVox::uint8_t>& volData, float fRadius, PolyVox::uint8_t uValue)
{
//This vector hold the position of the center of the volume
Vector3DFloat v3dVolCenter(volData.getSideLength() / 2, volData.getSideLength() / 2, volData.getSideLength() / 2);
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
//This three-level for loop iterates over every voxel in the volume
for (int z = 0; z < volData.getSideLength(); z++)
for (int z = 0; z < volData.getWidth(); z++)
{
for (int y = 0; y < volData.getSideLength(); y++)
for (int y = 0; y < volData.getHeight(); y++)
{
for (int x = 0; x < volData.getSideLength(); x++)
for (int x = 0; x < volData.getDepth(); x++)
{
//Store our current position as a vector...
Vector3DFloat v3dCurrentPos(x,y,z);

View File

@ -47,12 +47,12 @@ void exampleLog(string message, int severity)
int main(int argc, char *argv[])
{
logHandler = &exampleLog;
Volume<PolyVox::uint8_t> volData(g_uVolumeSideLength);
Volume<PolyVox::uint8_t> volData(g_uVolumeSideLength, g_uVolumeSideLength, g_uVolumeSideLength);
//Make our volume contain a sphere in the center.
PolyVox::uint16_t minPos = 0;
PolyVox::uint16_t midPos = volData.getSideLength() / 2;
PolyVox::uint16_t maxPos = volData.getSideLength() - 1;
PolyVox::uint16_t midPos = g_uVolumeSideLength / 2;
PolyVox::uint16_t maxPos = g_uVolumeSideLength - 1;
createCubeInVolume(volData, Vector3DUint16(minPos, minPos, minPos), Vector3DUint16(maxPos, maxPos, maxPos), 0);
createSphereInVolume(volData, 50.0f, 5);