From 244da2f9a5ca47f92a8495e988cfcca2db186fd9 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 8 May 2013 01:08:05 -0700 Subject: [PATCH] code cleanup, new scene --- voxel-edit/src/main.cpp | 53 +++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/voxel-edit/src/main.cpp b/voxel-edit/src/main.cpp index 5a474f15ee..7e606bc6c5 100644 --- a/voxel-edit/src/main.cpp +++ b/voxel-edit/src/main.cpp @@ -11,14 +11,6 @@ VoxelTree myTree; -int _nodeCount=0; -bool countVoxelsOperation(VoxelNode* node, void* extraData) { - if (node->isColored()){ - _nodeCount++; - } - return true; // keep going -} - void addScene(VoxelTree * tree) { printf("adding scene...\n"); @@ -74,40 +66,43 @@ void addScene(VoxelTree * tree) { // Now some more examples... creating some spheres using the sphere primitive // We want the smallest unit of our spheres to be about 1/16th of a meter tall - float sphereVoxelSize = 1.f / (16 * TREE_SCALE); + float sphereVoxelSize = 1.f / (8 * TREE_SCALE); printf("creating spheres... sphereVoxelSize=%f\n",sphereVoxelSize); - tree->createSphere(0.25, 0.5, 0.5, 0.5, sphereVoxelSize, true, false, true); - printf("one sphere added... sphereVoxelSize=%f\n",sphereVoxelSize); - tree->createSphere(0.030625, 0.5, 0.5, (0.25 - 0.06125), sphereVoxelSize, true, true); - printf("two spheres added... sphereVoxelSize=%f\n",sphereVoxelSize); - tree->createSphere(0.030625, (0.75 - 0.030625), (0.75 - 0.030625), (0.75 - 0.06125), sphereVoxelSize, true, true); - printf("three spheres added... sphereVoxelSize=%f\n",sphereVoxelSize); - tree->createSphere(0.030625, (0.75 - 0.030625), (0.75 - 0.030625), 0.06125, sphereVoxelSize, true, true); - printf("four spheres added... sphereVoxelSize=%f\n",sphereVoxelSize); - tree->createSphere(0.030625, (0.75 - 0.030625), 0.06125, (0.75 - 0.06125), sphereVoxelSize, true, true); - printf("five spheres added... sphereVoxelSize=%f\n",sphereVoxelSize); - tree->createSphere(0.06125, 0.125, 0.125, (0.75 - 0.125), sphereVoxelSize, true, true); + tree->createSphere(0.030625, 0.5, 0.5, (0.25 - 0.06125), sphereVoxelSize, true, NATURAL); + printf("1 spheres added... sphereVoxelSize=%f\n",sphereVoxelSize); + tree->createSphere(0.030625, (0.75 - 0.030625), (0.75 - 0.030625), (0.75 - 0.06125), sphereVoxelSize, true, GRADIENT); + printf("2 spheres added... sphereVoxelSize=%f\n",sphereVoxelSize); + tree->createSphere(0.030625, (0.75 - 0.030625), (0.75 - 0.030625), 0.06125, sphereVoxelSize, true, RANDOM); + printf("3 spheres added... sphereVoxelSize=%f\n",sphereVoxelSize); + tree->createSphere(0.030625, (0.75 - 0.030625), 0.06125, (0.75 - 0.06125), sphereVoxelSize, true, GRADIENT); + printf("4 spheres added... sphereVoxelSize=%f\n",sphereVoxelSize); + tree->createSphere(0.06125, 0.125, 0.125, (0.75 - 0.125), sphereVoxelSize, true, GRADIENT); +/** float radius = 0.0125f; + printf("5 spheres added...\n"); + tree->createSphere(radius, 0.25, radius * 5.0f, 0.25, sphereVoxelSize, true, GRADIENT); printf("6 spheres added...\n"); - tree->createSphere(radius, 0.25, radius * 5.0f, 0.25, (1.0 / 4096), true, true); + tree->createSphere(radius, 0.125, radius * 5.0f, 0.25, sphereVoxelSize, true, RANDOM); printf("7 spheres added...\n"); - tree->createSphere(radius, 0.125, radius * 5.0f, 0.25, (1.0 / 4096), true, true); + tree->createSphere(radius, 0.075, radius * 5.0f, 0.25, sphereVoxelSize, true, GRADIENT); printf("8 spheres added...\n"); - tree->createSphere(radius, 0.075, radius * 5.0f, 0.25, (1.0 / 4096), true, true); + tree->createSphere(radius, 0.05, radius * 5.0f, 0.25, sphereVoxelSize, true, RANDOM); printf("9 spheres added...\n"); - tree->createSphere(radius, 0.05, radius * 5.0f, 0.25, (1.0 / 4096), true, true); + tree->createSphere(radius, 0.025, radius * 5.0f, 0.25, sphereVoxelSize, true, GRADIENT); printf("10 spheres added...\n"); - tree->createSphere(radius, 0.025, radius * 5.0f, 0.25, (1.0 / 4096), true, true); - printf("11 spheres added...\n"); +*/ + float largeRadius = 0.1875f; + tree->createSphere(largeRadius, 0.5, 0.5, 0.5, sphereVoxelSize, true, NATURAL); + printf("11 - last large sphere added... largeRadius=%f sphereVoxelSize=%f\n", largeRadius, sphereVoxelSize); + printf("DONE creating spheres...\n"); // Here's an example of how to recurse the tree and do some operation on the nodes as you recurse them. // This one is really simple, it just couts them... // Look at the function countVoxelsOperation() for an example of how you could use this function - _nodeCount=0; - tree->recurseTreeWithOperation(countVoxelsOperation); - printf("Nodes after adding scene %d nodes\n", _nodeCount); + unsigned long nodeCount = tree->getVoxelCount(); + printf("Nodes after adding scene %ld nodes\n", nodeCount); printf("DONE adding scene of spheres...\n"); }