Showing the changes to interface/src/VoxelSystem.cpp (1 of 31 files). Show all
Unified · Split
| @@ -23,25 +23,27 @@ · 22 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | const int MAX_VOXELS_PER_SYSTEM = 250000; |
| 25 | 25 | |
| 26 | −const int VERTICES_PER_VOXEL = 8; | |
| 26 | +const int VERTICES_PER_VOXEL = 24; | |
| 27 | 27 | const int VERTEX_POINTS_PER_VOXEL = 3 * VERTICES_PER_VOXEL; |
| 28 | 28 | const int INDICES_PER_VOXEL = 3 * 12; |
| 29 | 29 | |
| 30 | −float identityVertices[] = { 0, 0, 0, | |
| 31 | − 1, 0, 0, | |
| 32 | − 1, 1, 0, | |
| 33 | − 0, 1, 0, | |
| 34 | − 0, 0, 1, | |
| 35 | − 1, 0, 1, | |
| 36 | − 1, 1, 1, | |
| 37 | − 0, 1, 1 }; | |
| 38 | − | |
| 39 | −GLubyte identityIndices[] = { 0,1,2, 0,2,3, | |
| 40 | − 0,1,5, 0,4,5, | |
| 41 | − 0,3,7, 0,4,7, | |
| 42 | − 1,2,6, 1,5,6, | |
| 43 | − 2,3,7, 2,6,7, | |
| 44 | − 4,5,6, 4,6,7 }; | |
| 30 | +float identityVertices[] = { 0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1, | |
| 31 | + 0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1, | |
| 32 | + 0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1 }; | |
| 33 | + | |
| 34 | +GLfloat identityNormals[] = { 0,0,-1, 0,0,-1, 0,0,-1, 0,0,-1, | |
| 35 | + 0,0,+1, 0,0,+1, 0,0,+1, 0,0,+1, | |
| 36 | + 0,-1,0, 0,-1,0, 0,+1,0, 0,+1,0, | |
| 37 | + 0,-1,0, 0,-1,0, 0,+1,0, 0,+1,0, | |
| 38 | + -1,0,0, +1,0,0, +1,0,0, -1,0,0, | |
| 39 | + -1,0,0, +1,0,0, +1,0,0, -1,0,0 }; | |
| 40 | + | |
| 41 | +GLubyte identityIndices[] = { 0,2,1, 0,3,2, // Z- . | |
| 42 | + 8,9,13, 8,13,12, // Y- | |
| 43 | + 16,23,19, 16,20,23, // X- | |
| 44 | + 17,18,22, 17,22,21, // X+ | |
| 45 | + 10,11,15, 10,15,14, // Y+ | |
| 46 | + 4,5,6, 4,6,7 }; // Z+ . | |
| 45 | 47 | |
| 46 | 48 | VoxelSystem::VoxelSystem() { |
| 47 | 49 | voxelsRendered = 0; |
| @@ -49,7 +51,7 @@ VoxelSystem::VoxelSystem() { · 1 unmodified line | ||
| 49 | 51 | pthread_mutex_init(&bufferWriteLock, NULL); |
| 50 | 52 | } |
| 51 | 53 | |
| 52 | −VoxelSystem::~VoxelSystem() { | |
| 54 | +VoxelSystem::~VoxelSystem() { | |
| 53 | 55 | delete[] readVerticesArray; |
| 54 | 56 | delete[] writeVerticesArray; |
| 55 | 57 | delete[] readColorsArray; |
| @@ -58,8 +60,8 @@ VoxelSystem::~VoxelSystem() { · 2 unmodified lines | ||
| 58 | 60 | pthread_mutex_destroy(&bufferWriteLock); |
| 59 | 61 | } |
| 60 | 62 | |
| 61 | −void VoxelSystem::setViewerHead(Head *newViewerHead) { | |
| 62 | − viewerHead = newViewerHead; | |
| 63 | +void VoxelSystem::setViewerAvatar(Avatar *newViewerAvatar) { | |
| 64 | + viewerAvatar = newViewerAvatar; | |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | 67 | ////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -70,9 +72,9 @@ void VoxelSystem::setViewerHead(Head *newViewerHead) { · 4 unmodified lines | ||
| 70 | 72 | // Complaints: Brad :) |
| 71 | 73 | // To Do: Need to add color data to the file. |
| 72 | 74 | void VoxelSystem::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) { |
| 73 | − | |
| 75 | + | |
| 74 | 76 | tree->loadVoxelsFile(fileName,wantColorRandomizer); |
| 75 | − | |
| 77 | + | |
| 76 | 78 | copyWrittenDataToReadArrays(); |
| 77 | 79 | } |
| 78 | 80 | |
| @@ -119,7 +121,7 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 40 unmodified lines | ||
| 119 | 121 | |
| 120 | 122 | unsigned char command = *sourceBuffer; |
| 121 | 123 | unsigned char *voxelData = sourceBuffer + 1; |
| 122 | − | |
| 124 | + | |
| 123 | 125 | switch(command) { |
| 124 | 126 | case PACKET_HEADER_VOXEL_DATA: |
| 125 | 127 | { |
| @@ -204,7 +206,7 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 78 unmodified lines | ||
| 204 | 206 | case PACKET_HEADER_Z_COMMAND: |
| 205 | 207 | |
| 206 | 208 | // the Z command is a special command that allows the sender to send high level semantic |
| 207 | − // requests, like erase all, or add sphere scene, different receivers may handle these | |
| 209 | + // requests, like erase all, or add sphere scene, different receivers may handle these | |
| 208 | 210 | // messages differently |
| 209 | 211 | char* packetData = (char *)sourceBuffer; |
| 210 | 212 | char* command = &packetData[1]; // start of the command |
| @@ -225,7 +227,7 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 14 unmodified lines | ||
| 225 | 227 | } |
| 226 | 228 | break; |
| 227 | 229 | } |
| 228 | − | |
| 230 | + | |
| 229 | 231 | setupNewVoxelsForDrawing(); |
| 230 | 232 | return numBytes; |
| 231 | 233 | } |
| @@ -258,7 +260,7 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosi · 26 unmodified lines | ||
| 258 | 260 | int voxelsAdded = 0; |
| 259 | 261 | |
| 260 | 262 | float halfUnitForVoxel = powf(0.5, *currentNode->octalCode) * (0.5 * TREE_SCALE); |
| 261 | − glm::vec3 viewerPosition = viewerHead->getBodyPosition(); | |
| 263 | + glm::vec3 viewerPosition = viewerAvatar->getPosition(); | |
| 262 | 264 | |
| 263 | 265 | // debug LOD code |
| 264 | 266 | glm::vec3 debugNodePosition; |
| @@ -285,11 +287,11 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosi · 20 unmodified lines | ||
| 285 | 287 | for (int i = 0; i < 8; i++) { |
| 286 | 288 | // check if there is a child here |
| 287 | 289 | if (currentNode->children[i] != NULL) { |
| 288 | − | |
| 290 | + | |
| 289 | 291 | glm::vec3 childNodePosition; |
| 290 | 292 | copyFirstVertexForCode(currentNode->children[i]->octalCode,(float*)&childNodePosition); |
| 291 | 293 | childNodePosition *= (float)TREE_SCALE; // scale it up |
| 292 | − | |
| 294 | + | |
| 293 | 295 | /**** disabled ************************************************************************************************ |
| 294 | 296 | // Note: Stephen, I intentionally left this in so you would talk to me about it. Here's the deal, this code |
| 295 | 297 | // doesn't seem to work correctly. It returns X and Z flipped and the values are negative. Since we use the |
| @@ -299,7 +301,7 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosi · 3 unmodified lines | ||
| 299 | 301 | // calculate the child's position based on the parent position |
| 300 | 302 | for (int j = 0; j < 3; j++) { |
| 301 | 303 | childNodePosition[j] = nodePosition[j]; |
| 302 | − | |
| 304 | + | |
| 303 | 305 | if (oneAtBit(branchIndexWithDescendant(currentNode->octalCode,currentNode->children[i]->octalCode),(7 - j))) { |
| 304 | 306 | childNodePosition[j] -= (powf(0.5, *currentNode->children[i]->octalCode) * TREE_SCALE); |
| 305 | 307 | } |
| @@ -316,13 +318,13 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosi · 10 unmodified lines | ||
| 316 | 318 | float startVertex[3]; |
| 317 | 319 | copyFirstVertexForCode(currentNode->octalCode,(float*)&startVertex); |
| 318 | 320 | float voxelScale = 1 / powf(2, *currentNode->octalCode); |
| 319 | − | |
| 321 | + | |
| 320 | 322 | // populate the array with points for the 8 vertices |
| 321 | 323 | // and RGB color for each added vertex |
| 322 | 324 | for (int j = 0; j < VERTEX_POINTS_PER_VOXEL; j++ ) { |
| 323 | 325 | *writeVerticesEndPointer = startVertex[j % 3] + (identityVertices[j] * voxelScale); |
| 324 | 326 | *(writeColorsArray + (writeVerticesEndPointer - writeVerticesArray)) = currentNode->getColor()[j % 3]; |
| 325 | − | |
| 327 | + | |
| 326 | 328 | writeVerticesEndPointer++; |
| 327 | 329 | } |
| 328 | 330 | voxelsAdded++; |
| @@ -344,7 +346,7 @@ void VoxelSystem::init() { · 15 unmodified lines | ||
| 344 | 346 | readColorsArray = new GLubyte[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM]; |
| 345 | 347 | |
| 346 | 348 | GLuint *indicesArray = new GLuint[INDICES_PER_VOXEL * MAX_VOXELS_PER_SYSTEM]; |
| 347 | − | |
| 349 | + | |
| 348 | 350 | // populate the indicesArray |
| 349 | 351 | // this will not change given new voxels, so we can set it all up now |
| 350 | 352 | for (int n = 0; n < MAX_VOXELS_PER_SYSTEM; n++) { |
| @@ -352,84 +354,107 @@ void VoxelSystem::init() { · 1 unmodified line | ||
| 352 | 354 | int voxelIndexOffset = n * INDICES_PER_VOXEL; |
| 353 | 355 | GLuint *currentIndicesPos = indicesArray + voxelIndexOffset; |
| 354 | 356 | int startIndex = (n * VERTICES_PER_VOXEL); |
| 355 | − | |
| 357 | + | |
| 356 | 358 | for (int i = 0; i < INDICES_PER_VOXEL; i++) { |
| 357 | 359 | // add indices for this side of the cube |
| 358 | 360 | currentIndicesPos[i] = startIndex + identityIndices[i]; |
| 359 | 361 | } |
| 360 | 362 | } |
| 361 | − | |
| 363 | + | |
| 364 | + GLfloat *normalsArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM]; | |
| 365 | + GLfloat *normalsArrayEndPointer = normalsArray; | |
| 366 | + | |
| 367 | + // populate the normalsArray | |
| 368 | + for (int n = 0; n < MAX_VOXELS_PER_SYSTEM; n++) { | |
| 369 | + for (int i = 0; i < VERTEX_POINTS_PER_VOXEL; i++) { | |
| 370 | + *(normalsArrayEndPointer++) = identityNormals[i]; | |
| 371 | + } | |
| 372 | + } | |
| 373 | + | |
| 362 | 374 | // VBO for the verticesArray |
| 363 | 375 | glGenBuffers(1, &vboVerticesID); |
| 364 | 376 | glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID); |
| 365 | 377 | glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW); |
| 366 | − | |
| 378 | + | |
| 379 | + // VBO for the normalsArray | |
| 380 | + glGenBuffers(1, &vboNormalsID); | |
| 381 | + glBindBuffer(GL_ARRAY_BUFFER, vboNormalsID); | |
| 382 | + glBufferData(GL_ARRAY_BUFFER, | |
| 383 | + VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * MAX_VOXELS_PER_SYSTEM, | |
| 384 | + normalsArray, GL_STATIC_DRAW); | |
| 385 | + | |
| 367 | 386 | // VBO for colorsArray |
| 368 | 387 | glGenBuffers(1, &vboColorsID); |
| 369 | 388 | glBindBuffer(GL_ARRAY_BUFFER, vboColorsID); |
| 370 | 389 | glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLubyte) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW); |
| 371 | − | |
| 390 | + | |
| 372 | 391 | // VBO for the indicesArray |
| 373 | 392 | glGenBuffers(1, &vboIndicesID); |
| 374 | 393 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID); |
| 375 | 394 | glBufferData(GL_ELEMENT_ARRAY_BUFFER, |
| 376 | 395 | INDICES_PER_VOXEL * sizeof(GLuint) * MAX_VOXELS_PER_SYSTEM, |
| 377 | 396 | indicesArray, GL_STATIC_DRAW); |
| 378 | − | |
| 379 | − // delete the indices array that is no longer needed | |
| 397 | + | |
| 398 | + // delete the indices and normals arrays that are no longer needed | |
| 380 | 399 | delete[] indicesArray; |
| 400 | + delete[] normalsArray; | |
| 381 | 401 | } |
| 382 | 402 | |
| 383 | 403 | void VoxelSystem::render() { |
| 384 | 404 | |
| 385 | 405 | glPushMatrix(); |
| 386 | − | |
| 406 | + | |
| 387 | 407 | if (readVerticesEndPointer != readVerticesArray) { |
| 388 | 408 | // try to lock on the buffer write |
| 389 | 409 | // just avoid pulling new data if it is currently being written |
| 390 | 410 | if (pthread_mutex_trylock(&bufferWriteLock) == 0) { |
| 391 | − | |
| 411 | + | |
| 392 | 412 | glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID); |
| 393 | 413 | glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLfloat), readVerticesArray); |
| 394 | − | |
| 414 | + | |
| 395 | 415 | glBindBuffer(GL_ARRAY_BUFFER, vboColorsID); |
| 396 | 416 | glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLubyte), readColorsArray); |
| 397 | − | |
| 417 | + | |
| 398 | 418 | readVerticesEndPointer = readVerticesArray; |
| 399 | − | |
| 419 | + | |
| 400 | 420 | pthread_mutex_unlock(&bufferWriteLock); |
| 401 | 421 | } |
| 402 | 422 | } |
| 403 | 423 | |
| 404 | 424 | // tell OpenGL where to find vertex and color information |
| 405 | 425 | glEnableClientState(GL_VERTEX_ARRAY); |
| 426 | + glEnableClientState(GL_NORMAL_ARRAY); | |
| 406 | 427 | glEnableClientState(GL_COLOR_ARRAY); |
| 407 | − | |
| 428 | + | |
| 408 | 429 | glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID); |
| 409 | 430 | glVertexPointer(3, GL_FLOAT, 0, 0); |
| 410 | − | |
| 431 | + | |
| 432 | + glBindBuffer(GL_ARRAY_BUFFER, vboNormalsID); | |
| 433 | + glNormalPointer(GL_FLOAT, 0, 0); | |
| 434 | + | |
| 411 | 435 | glBindBuffer(GL_ARRAY_BUFFER, vboColorsID); |
| 412 | 436 | glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0); |
| 413 | − | |
| 437 | + | |
| 414 | 438 | // draw the number of voxels we have |
| 415 | 439 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID); |
| 416 | 440 | glScalef(10, 10, 10); |
| 417 | 441 | glDrawElements(GL_TRIANGLES, 36 * voxelsRendered, GL_UNSIGNED_INT, 0); |
| 418 | − | |
| 442 | + | |
| 419 | 443 | // deactivate vertex and color arrays after drawing |
| 420 | 444 | glDisableClientState(GL_VERTEX_ARRAY); |
| 445 | + glDisableClientState(GL_NORMAL_ARRAY); | |
| 421 | 446 | glDisableClientState(GL_COLOR_ARRAY); |
| 422 | − | |
| 447 | + | |
| 423 | 448 | // bind with 0 to switch back to normal operation |
| 424 | 449 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 425 | 450 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 426 | − | |
| 451 | + | |
| 427 | 452 | // scale back down to 1 so heads aren't massive |
| 428 | 453 | glPopMatrix(); |
| 429 | 454 | } |
| 430 | 455 | |
| 431 | 456 | void VoxelSystem::simulate(float deltaTime) { |
| 432 | − | |
| 457 | + | |
| 433 | 458 | } |
| 434 | 459 | |
| 435 | 460 | int VoxelSystem::_nodeCount = 0; |
| @@ -440,7 +465,7 @@ bool VoxelSystem::randomColorOperation(VoxelNode* node, bool down, void* extraDa · 4 unmodified lines | ||
| 440 | 465 | if (down) { |
| 441 | 466 | return true; |
| 442 | 467 | } |
| 443 | − | |
| 468 | + | |
| 444 | 469 | _nodeCount++; |
| 445 | 470 | if (node->isColored()) { |
| 446 | 471 | nodeColor newColor = { 0,0,0,1 }; |
| @@ -471,9 +496,9 @@ bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, bool down, void* · 24 unmodified lines | ||
| 471 | 496 | if (down) { |
| 472 | 497 | return true; |
| 473 | 498 | } |
| 474 | − | |
| 499 | + | |
| 475 | 500 | _nodeCount++; |
| 476 | − | |
| 501 | + | |
| 477 | 502 | // always false colorize |
| 478 | 503 | unsigned char newR = randomColorValue(150); |
| 479 | 504 | unsigned char newG = randomColorValue(150); |
| @@ -500,7 +525,7 @@ bool VoxelSystem::trueColorizeOperation(VoxelNode* node, bool down, void* extraD · 20 unmodified lines | ||
| 500 | 525 | if (down) { |
| 501 | 526 | return true; |
| 502 | 527 | } |
| 503 | − | |
| 528 | + | |
| 504 | 529 | _nodeCount++; |
| 505 | 530 | node->setFalseColored(false); |
| 506 | 531 | //printf("setting true color for node %d\n",_nodeCount); |
| @@ -521,23 +546,23 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, bool down, void* · 14 unmodified lines | ||
| 521 | 546 | if (down) { |
| 522 | 547 | return true; |
| 523 | 548 | } |
| 524 | − | |
| 549 | + | |
| 525 | 550 | ViewFrustum* viewFrustum = (ViewFrustum*) extraData; |
| 526 | − | |
| 551 | + | |
| 527 | 552 | _nodeCount++; |
| 528 | − | |
| 553 | + | |
| 529 | 554 | // only do this for truely colored voxels... |
| 530 | 555 | if (node->isColored()) { |
| 531 | 556 | // first calculate the AAbox for the voxel |
| 532 | 557 | AABox voxelBox; |
| 533 | 558 | node->getAABox(voxelBox); |
| 534 | − | |
| 559 | + | |
| 535 | 560 | voxelBox.scale(TREE_SCALE); |
| 536 | − | |
| 561 | + | |
| 537 | 562 | printf("voxelBox corner=(%f,%f,%f) x=%f\n", |
| 538 | 563 | voxelBox.getCorner().x, voxelBox.getCorner().y, voxelBox.getCorner().z, |
| 539 | 564 | voxelBox.getSize().x); |
| 540 | − | |
| 565 | + | |
| 541 | 566 | // If the voxel is outside of the view frustum, then false color it red |
| 542 | 567 | if (ViewFrustum::OUTSIDE == viewFrustum->boxInFrustum(voxelBox)) { |
| 543 | 568 | // Out of view voxels are colored RED |
| @@ -554,7 +579,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, bool down, void* · 10 unmodified lines | ||
| 554 | 579 | } else { |
| 555 | 580 | printf("voxel not colored, don't consider it\n"); |
| 556 | 581 | } |
| 557 | − | |
| 582 | + | |
| 558 | 583 | return true; // keep going! |
| 559 | 584 | } |
| 560 | 585 | |
| @@ -576,7 +601,7 @@ bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, bool d · 15 unmodified lines | ||
| 576 | 601 | } |
| 577 | 602 | |
| 578 | 603 | ViewFrustum* viewFrustum = (ViewFrustum*) extraData; |
| 579 | − | |
| 604 | + | |
| 580 | 605 | // only do this for truly colored voxels... |
| 581 | 606 | if (node->isColored()) { |
| 582 | 607 | |
| @@ -590,10 +615,10 @@ bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, bool d · 7 unmodified lines | ||
| 590 | 615 | |
| 591 | 616 | // scale up the node position |
| 592 | 617 | nodePosition = nodePosition*(float)TREE_SCALE; |
| 593 | − | |
| 618 | + | |
| 594 | 619 | float halfUnitForVoxel = powf(0.5, *node->octalCode) * (0.5 * TREE_SCALE); |
| 595 | 620 | glm::vec3 viewerPosition = viewFrustum->getPosition(); |
| 596 | − | |
| 621 | + | |
| 597 | 622 | //printf("halfUnitForVoxel=%f\n",halfUnitForVoxel); |
| 598 | 623 | //printf("viewer.x=%f y=%f z=%f \n", viewerPosition.x, viewerPosition.y, viewerPosition.z); |
| 599 | 624 | //printf("node.x=%f y=%f z=%f \n", nodePosition.x, nodePosition.y, nodePosition.z); |
| @@ -606,7 +631,7 @@ bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, bool d · 6 unmodified lines | ||
| 606 | 631 | _nodeCount++; |
| 607 | 632 | |
| 608 | 633 | float distanceRatio = (_minDistance==_maxDistance) ? 1 : (distance - _minDistance)/(_maxDistance - _minDistance); |
| 609 | − | |
| 634 | + | |
| 610 | 635 | // We want to colorize this in 16 bug chunks of color |
| 611 | 636 | const unsigned char maxColor = 255; |
| 612 | 637 | const unsigned char colorBands = 16; |
| @@ -615,7 +640,7 @@ bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, bool d · 2 unmodified lines | ||
| 615 | 640 | unsigned char newR = (colorBand*(gradientOver/colorBands))+(maxColor-gradientOver); |
| 616 | 641 | unsigned char newG = 0; |
| 617 | 642 | unsigned char newB = 0; |
| 618 | − //printf("Setting color down=%s distance=%f min=%f max=%f distanceRatio=%f color=%d \n", | |
| 643 | + //printf("Setting color down=%s distance=%f min=%f max=%f distanceRatio=%f color=%d \n", | |
| 619 | 644 | // (down ? "TRUE" : "FALSE"), distance, _minDistance, _maxDistance, distanceRatio, (int)newR); |
| 620 | 645 | |
| 621 | 646 | node->setFalseColor(newR,newG,newB); |
| @@ -641,7 +666,7 @@ bool VoxelSystem::getDistanceFromViewRangeOperation(VoxelNode* node, bool down, · 19 unmodified lines | ||
| 641 | 666 | //printf("getDistanceFromViewRangeOperation() down=%s\n",(down ? "TRUE" : "FALSE")); |
| 642 | 667 | |
| 643 | 668 | ViewFrustum* viewFrustum = (ViewFrustum*) extraData; |
| 644 | − | |
| 669 | + | |
| 645 | 670 | // only do this for truly colored voxels... |
| 646 | 671 | if (node->isColored()) { |
| 647 | 672 | |
| @@ -687,7 +712,7 @@ void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) { · 39 unmodified lines | ||
| 687 | 712 | printf("determining distance range for %d nodes\n",_nodeCount); |
| 688 | 713 | |
| 689 | 714 | _nodeCount = 0; |
| 690 | − | |
| 715 | + | |
| 691 | 716 | tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum); |
| 692 | 717 | printf("setting in distance false color for %d nodes\n",_nodeCount); |
| 693 | 718 | setupNewVoxelsForDrawing(); |