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

This commit is contained in:
Stephen Birarda 2013-03-29 08:20:52 -07:00
commit f0f0df2cf3
2 changed files with 17 additions and 3 deletions

View file

@ -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);

View file

@ -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);