mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 17:20:12 +02:00
code cleanup, new scene
This commit is contained in:
parent
93a5f662f7
commit
244da2f9a5
1 changed files with 24 additions and 29 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue