From c6a667af613493348b463bd299499f61c2b9a61e Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 29 Mar 2013 07:27:46 -0700 Subject: [PATCH] added Scene mode to voxel server --- shared/src/VoxelTree.cpp | 7 ++++--- voxel/src/main.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/shared/src/VoxelTree.cpp b/shared/src/VoxelTree.cpp index c400e0debf..c51c01a285 100644 --- a/shared/src/VoxelTree.cpp +++ b/shared/src/VoxelTree.cpp @@ -513,8 +513,8 @@ void VoxelTree::createSphere(float r,float xc, float yc, float zc, float s, bool // If you also iterate form the interior of the sphere to the radius, makeing // larger and larger sphere's you'd end up with a solid sphere. And lots of voxels! - for (; ri <= r; ri+=s) { - //printf("radius: %f\n",ri); + for (; ri <= (r+(s/2.0)); ri+=s) { + printf("radius: ri=%f ri+s=%f (r+(s/2.0))=%f\n",ri,ri+s,(r+(s/2.0))); for (float theta=0.0; theta <= 2*M_PI; theta += angleDelta) { for (float phi=0.0; phi <= M_PI; phi += angleDelta) { t++; // total voxels @@ -527,7 +527,8 @@ void VoxelTree::createSphere(float r,float xc, float yc, float zc, float s, bool // only use our actual desired color on the outer edge, otherwise // use our "average" color - if (ri==r) { + if (ri+(s*2.0)>=r) { + printf("painting candy shell radius: ri=%f r=%f\n",ri,r); red = wantColorRandomizer ? randomColorValue(165) : r1+((r2-r1)*gradient); green = wantColorRandomizer ? randomColorValue(165) : g1+((g2-g1)*gradient); blue = wantColorRandomizer ? randomColorValue(165) : b1+((b2-b1)*gradient); diff --git a/voxel/src/main.cpp b/voxel/src/main.cpp index 121d82a394..1e8b2da675 100644 --- a/voxel/src/main.cpp +++ b/voxel/src/main.cpp @@ -66,6 +66,13 @@ void addSphere(VoxelTree * tree,bool random, bool wantColorRandomizer) { tree->createSphere(r,xc,yc,zc,s,solid,wantColorRandomizer); } +void addSphereScene(VoxelTree * tree, bool wantColorRandomizer) { + printf("adding scene of spheres...\n"); + tree->createSphere(0.25,0.5,0.5,0.5,(1.0/256),true,wantColorRandomizer); + tree->createSphere(0.030625,0.5,0.5,(0.25-0.06125),(1.0/2048),true,true); +} + + void randomlyFillVoxelTree(int levelsToGo, VoxelNode *currentRootNode) { // randomly generate children for this node // the first level of the tree (where levelsToGo = MAX_VOXEL_TREE_DEPTH_LEVELS) has all 8 @@ -233,6 +240,7 @@ int main(int argc, const char * argv[]) // octal codes to the tree nodes that it is creating randomlyFillVoxelTree(MAX_VOXEL_TREE_DEPTH_LEVELS, randomTree.rootNode); } + const char* ADD_SPHERE="--AddSphere"; const char* ADD_RANDOM_SPHERE="--AddRandomSphere"; @@ -241,6 +249,11 @@ int main(int argc, const char * argv[]) } else if (cmdOptionExists(argc, argv, ADD_RANDOM_SPHERE)) { addSphere(&randomTree,true,wantColorRandomizer); } + + const char* ADD_SCENE="--AddScene"; + if (cmdOptionExists(argc, argv, ADD_SCENE)) { + addSphereScene(&randomTree,wantColorRandomizer); + } pthread_t sendVoxelThread; pthread_create(&sendVoxelThread, NULL, distributeVoxelsToListeners, NULL);