Merge branch 'master' of github.com:worklist/hifi

This commit is contained in:
Stephen Birarda 2013-03-29 11:35:22 -07:00
commit e5a31bc174
3 changed files with 13 additions and 14 deletions

View file

@ -97,7 +97,7 @@ bool VoxelNode::collapseIdenticalLeaves() {
if (allChildrenMatch) { if (allChildrenMatch) {
printf("allChildrenMatch: pruning tree\n"); //printf("allChildrenMatch: pruning tree\n");
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
delete children[i]; // delete all the child nodes delete children[i]; // delete all the child nodes
children[i]=NULL; // set it to NULL children[i]=NULL; // set it to NULL

View file

@ -515,7 +515,7 @@ 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 // 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! // larger and larger sphere's you'd end up with a solid sphere. And lots of voxels!
for (; ri <= (r+(s/2.0)); ri+=s) { 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))); //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 theta=0.0; theta <= 2*M_PI; theta += angleDelta) {
for (float phi=0.0; phi <= M_PI; phi += angleDelta) { for (float phi=0.0; phi <= M_PI; phi += angleDelta) {
t++; // total voxels t++; // total voxels
@ -529,7 +529,7 @@ 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 // only use our actual desired color on the outer edge, otherwise
// use our "average" color // use our "average" color
if (ri+(s*2.0)>=r) { if (ri+(s*2.0)>=r) {
printf("painting candy shell radius: ri=%f r=%f\n",ri,r); //printf("painting candy shell radius: ri=%f r=%f\n",ri,r);
red = wantColorRandomizer ? randomColorValue(165) : r1+((r2-r1)*gradient); red = wantColorRandomizer ? randomColorValue(165) : r1+((r2-r1)*gradient);
green = wantColorRandomizer ? randomColorValue(165) : g1+((g2-g1)*gradient); green = wantColorRandomizer ? randomColorValue(165) : g1+((g2-g1)*gradient);
blue = wantColorRandomizer ? randomColorValue(165) : b1+((b2-b1)*gradient); blue = wantColorRandomizer ? randomColorValue(165) : b1+((b2-b1)*gradient);
@ -537,12 +537,11 @@ void VoxelTree::createSphere(float r,float xc, float yc, float zc, float s, bool
unsigned char* voxelData = pointToVoxel(x,y,z,s,red,green,blue); unsigned char* voxelData = pointToVoxel(x,y,z,s,red,green,blue);
this->readCodeColorBufferToTree(voxelData); this->readCodeColorBufferToTree(voxelData);
printf("voxel data for x:%f y:%f z:%f s:%f\n",x,y,z,s); //printf("voxel data for x:%f y:%f z:%f s:%f\n",x,y,z,s);
printVoxelCode(voxelData); //printVoxelCode(voxelData);
delete voxelData; delete voxelData;
} }
} }
} }
this->reaverageVoxelColors(this->rootNode); this->reaverageVoxelColors(this->rootNode);
this->printTreeForDebugging(this->rootNode);
} }

View file

@ -52,7 +52,7 @@ void addSphere(VoxelTree * tree,bool random, bool wantColorRandomizer) {
float xc = random ? randFloatInRange(r,(1-r)) : 0.5; float xc = random ? randFloatInRange(r,(1-r)) : 0.5;
float yc = random ? randFloatInRange(r,(1-r)) : 0.5; float yc = random ? randFloatInRange(r,(1-r)) : 0.5;
float zc = random ? randFloatInRange(r,(1-r)) : 0.5; float zc = random ? randFloatInRange(r,(1-r)) : 0.5;
float s = (1.0/16); // size of voxels to make up surface of sphere float s = (1.0/256); // size of voxels to make up surface of sphere
bool solid = true; bool solid = true;
printf("adding sphere:"); printf("adding sphere:");
@ -69,7 +69,7 @@ void addSphere(VoxelTree * tree,bool random, bool wantColorRandomizer) {
void addSphereScene(VoxelTree * tree, bool wantColorRandomizer) { void addSphereScene(VoxelTree * tree, bool wantColorRandomizer) {
printf("adding scene of spheres...\n"); printf("adding scene of spheres...\n");
tree->createSphere(0.25,0.5,0.5,0.5,(1.0/256),true,wantColorRandomizer); 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); tree->createSphere(0.030625,0.5,0.5,(0.25-0.06125),(1.0/512),true,true);
} }
@ -223,9 +223,9 @@ int main(int argc, const char * argv[])
// Check to see if the user passed in a command line option for loading a local // Check to see if the user passed in a command line option for loading a local
// Voxel File. If so, load it now. // Voxel File. If so, load it now.
const char* NO_COLOR_RANDOMIZER="--NoColorRandomizer"; const char* WANT_COLOR_RANDOMIZER="--WantColorRandomizer";
const char* INPUT_FILE="-i"; const char* INPUT_FILE="-i";
bool wantColorRandomizer = !cmdOptionExists(argc, argv, NO_COLOR_RANDOMIZER); bool wantColorRandomizer = cmdOptionExists(argc, argv, WANT_COLOR_RANDOMIZER);
printf("wantColorRandomizer=%s\n",(wantColorRandomizer?"yes":"no")); printf("wantColorRandomizer=%s\n",(wantColorRandomizer?"yes":"no"));
const char* voxelsFilename = getCmdOption(argc, argv, INPUT_FILE); const char* voxelsFilename = getCmdOption(argc, argv, INPUT_FILE);
@ -234,8 +234,8 @@ int main(int argc, const char * argv[])
randomTree.loadVoxelsFile(voxelsFilename,wantColorRandomizer); randomTree.loadVoxelsFile(voxelsFilename,wantColorRandomizer);
} }
const char* NO_RANDOM_VOXELS="--NoRandomVoxels"; const char* ADD_RANDOM_VOXELS="--AddRandomVoxels";
if (!cmdOptionExists(argc, argv, NO_RANDOM_VOXELS)) { if (cmdOptionExists(argc, argv, ADD_RANDOM_VOXELS)) {
// create an octal code buffer and load it with 0 so that the recursive tree fill can give // create an octal code buffer and load it with 0 so that the recursive tree fill can give
// octal codes to the tree nodes that it is creating // octal codes to the tree nodes that it is creating
randomlyFillVoxelTree(MAX_VOXEL_TREE_DEPTH_LEVELS, randomTree.rootNode); randomlyFillVoxelTree(MAX_VOXEL_TREE_DEPTH_LEVELS, randomTree.rootNode);
@ -250,8 +250,8 @@ int main(int argc, const char * argv[])
addSphere(&randomTree,true,wantColorRandomizer); addSphere(&randomTree,true,wantColorRandomizer);
} }
const char* ADD_SCENE="--AddScene"; const char* NO_ADD_SCENE="--NoAddScene";
if (cmdOptionExists(argc, argv, ADD_SCENE)) { if (!cmdOptionExists(argc, argv, NO_ADD_SCENE)) {
addSphereScene(&randomTree,wantColorRandomizer); addSphereScene(&randomTree,wantColorRandomizer);
} }