Showing the changes to interface/src/VoxelSystem.cpp (1 of 2 files). Show all
Unified · Split
| @@ -107,6 +107,34 @@ void VoxelSystem::loadVoxelsFile(char* fileName) { · 106 unmodified lines | ||
| 107 | 107 | // Complaints: Brad :) |
| 108 | 108 | void VoxelSystem::createSphere(float r,float xc, float yc, float zc, float s, bool solid) |
| 109 | 109 | { |
| 110 | + // About the color of the sphere... we're going to make this sphere be a gradient | |
| 111 | + // between two RGB colors. We will do the gradient along the phi spectrum | |
| 112 | + unsigned char r1 = randomColorValue(165); | |
| 113 | + unsigned char g1 = randomColorValue(165); | |
| 114 | + unsigned char b1 = randomColorValue(165); | |
| 115 | + unsigned char r2 = randomColorValue(65); | |
| 116 | + unsigned char g2 = randomColorValue(65); | |
| 117 | + unsigned char b2 = randomColorValue(65); | |
| 118 | + | |
| 119 | + // we don't want them to match!! | |
| 120 | + if (r1==r2 && g1==g2 && b1==b2) | |
| 121 | + { | |
| 122 | + r2=r1/2; | |
| 123 | + g2=g1/2; | |
| 124 | + b2=b1/2; | |
| 125 | + } | |
| 126 | + | |
| 127 | + /** | |
| 128 | + std::cout << "creatSphere COLORS "; | |
| 129 | + std::cout << " r1=" << (int)r1; | |
| 130 | + std::cout << " g1=" << (int)g1; | |
| 131 | + std::cout << " b1=" << (int)b1; | |
| 132 | + std::cout << " r2=" << (int)r2; | |
| 133 | + std::cout << " g2=" << (int)g2; | |
| 134 | + std::cout << " b2=" << (int)b2; | |
| 135 | + std::cout << std::endl; | |
| 136 | + **/ | |
| 137 | + | |
| 110 | 138 | // Psuedocode for creating a sphere: |
| 111 | 139 | // |
| 112 | 140 | // for (theta from 0 to 2pi): |
| @@ -157,10 +185,11 @@ void VoxelSystem::createSphere(float r,float xc, float yc, float zc, float s, bo · 44 unmodified lines | ||
| 157 | 185 | std::cout << std::endl; |
| 158 | 186 | */ |
| 159 | 187 | |
| 160 | − // random color data | |
| 161 | − unsigned char red = randomColorValue(65); | |
| 162 | − unsigned char green = randomColorValue(65); | |
| 163 | − unsigned char blue = randomColorValue(65); | |
| 188 | + // gradient color data | |
| 189 | + float gradient = (phi/M_PI); | |
| 190 | + unsigned char red = r1+((r2-r1)*gradient); | |
| 191 | + unsigned char green = g1+((g2-g1)*gradient); | |
| 192 | + unsigned char blue = b1+((b2-b1)*gradient); | |
| 164 | 193 | |
| 165 | 194 | unsigned char* voxelData = pointToVoxel(x,y,z,s,red,green,blue); |
| 166 | 195 | tree->readCodeColorBufferToTree(voxelData); |