Showing the changes to interface/src/VoxelSystem.cpp (1 of 2 files). Show all
Unified · Split
| @@ -364,19 +364,12 @@ void VoxelSystem::render() { · 363 unmodified lines | |||
| 364 | glPopMatrix(); | 364 | glPopMatrix(); |
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | void VoxelSystem::simulate(float deltaTime) { | ||
| 368 | |||
| 369 | } | ||
| 370 | |||
| 371 | int VoxelSystem::_nodeCount = 0; | 367 | int VoxelSystem::_nodeCount = 0; |
| 372 | 368 | ||
| 373 | bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) { | 369 | bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) { |
| 374 | _nodeCount++; | 370 | _nodeCount++; |
| 375 | if (node->isColored()) { | 371 | if (node->isColored()) { |
| 376 | nodeColor newColor = { 0,0,0,1 }; | 372 | nodeColor newColor = { randomColorValue(150), randomColorValue(150), randomColorValue(150), 1 }; |
| 377 | newColor[0] = randomColorValue(150); | ||
| 378 | newColor[1] = randomColorValue(150); | ||
| 379 | newColor[1] = randomColorValue(150); | ||
| 380 | node->setColor(newColor); | 373 | node->setColor(newColor); |
| 381 | } | 374 | } |
| 382 | return true; | 375 | return true; |
| @@ -385,24 +378,21 @@ bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) { · 2 unmodified lines | |||
| 385 | void VoxelSystem::randomizeVoxelColors() { | 378 | void VoxelSystem::randomizeVoxelColors() { |
| 386 | _nodeCount = 0; | 379 | _nodeCount = 0; |
| 387 | _tree->recurseTreeWithOperation(randomColorOperation); | 380 | _tree->recurseTreeWithOperation(randomColorOperation); |
| 388 | printLog("setting randomized true color for %d nodes\n",_nodeCount); | 381 | printLog("setting randomized true color for %d nodes\n", _nodeCount); |
| 389 | setupNewVoxelsForDrawing(); | 382 | setupNewVoxelsForDrawing(); |
| 390 | } | 383 | } |
| 391 | 384 | ||
| 392 | bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, void* extraData) { | 385 | bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, void* extraData) { |
| 393 | _nodeCount++; | 386 | _nodeCount++; |
| 394 | // always false colorize | 387 | // always false colorize |
| 395 | unsigned char newR = randomColorValue(150); | 388 | node->setFalseColor(randomColorValue(150), randomColorValue(150), randomColorValue(150)); |
| 396 | unsigned char newG = randomColorValue(150); | ||
| 397 | unsigned char newB = randomColorValue(150); | ||
| 398 | node->setFalseColor(newR,newG,newB); | ||
| 399 | return true; // keep going! | 389 | return true; // keep going! |
| 400 | } | 390 | } |
| 401 | 391 | ||
| 402 | void VoxelSystem::falseColorizeRandom() { | 392 | void VoxelSystem::falseColorizeRandom() { |
| 403 | _nodeCount = 0; | 393 | _nodeCount = 0; |
| 404 | _tree->recurseTreeWithOperation(falseColorizeRandomOperation); | 394 | _tree->recurseTreeWithOperation(falseColorizeRandomOperation); |
| 405 | printLog("setting randomized false color for %d nodes\n",_nodeCount); | 395 | printLog("setting randomized false color for %d nodes\n", _nodeCount); |
| 406 | setupNewVoxelsForDrawing(); | 396 | setupNewVoxelsForDrawing(); |
| 407 | } | 397 | } |
| 408 | 398 | ||
| @@ -415,7 +405,7 @@ bool VoxelSystem::trueColorizeOperation(VoxelNode* node, void* extraData) { · 6 unmodified lines | |||
| 415 | void VoxelSystem::trueColorize() { | 405 | void VoxelSystem::trueColorize() { |
| 416 | _nodeCount = 0; | 406 | _nodeCount = 0; |
| 417 | _tree->recurseTreeWithOperation(trueColorizeOperation); | 407 | _tree->recurseTreeWithOperation(trueColorizeOperation); |
| 418 | printLog("setting true color for %d nodes\n",_nodeCount); | 408 | printLog("setting true color for %d nodes\n", _nodeCount); |
| 419 | setupNewVoxelsForDrawing(); | 409 | setupNewVoxelsForDrawing(); |
| 420 | } | 410 | } |
| 421 | 411 | ||
| @@ -426,10 +416,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData) · 4 unmodified lines | |||
| 426 | if (node->isColored()) { | 416 | if (node->isColored()) { |
| 427 | if (!node->isInView(*viewFrustum)) { | 417 | if (!node->isInView(*viewFrustum)) { |
| 428 | // Out of view voxels are colored RED | 418 | // Out of view voxels are colored RED |
| 429 | unsigned char newR = 255; | 419 | node->setFalseColor(255, 0, 0); |
| 430 | unsigned char newG = 0; | ||
| 431 | unsigned char newB = 0; | ||
| 432 | node->setFalseColor(newR,newG,newB); | ||
| 433 | } | 420 | } |
| 434 | } | 421 | } |
| 435 | return true; // keep going! | 422 | return true; // keep going! |
| @@ -438,7 +425,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData) · 2 unmodified lines | |||
| 438 | void VoxelSystem::falseColorizeInView(ViewFrustum* viewFrustum) { | 425 | void VoxelSystem::falseColorizeInView(ViewFrustum* viewFrustum) { |
| 439 | _nodeCount = 0; | 426 | _nodeCount = 0; |
| 440 | _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum); | 427 | _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum); |
| 441 | printLog("setting in view false color for %d nodes\n",_nodeCount); | 428 | printLog("setting in view false color for %d nodes\n", _nodeCount); |
| 442 | setupNewVoxelsForDrawing(); | 429 | setupNewVoxelsForDrawing(); |
| 443 | } | 430 | } |
| 444 | 431 | ||
| @@ -448,17 +435,14 @@ bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, void* · 3 unmodified lines | |||
| 448 | if (node->isColored()) { | 435 | if (node->isColored()) { |
| 449 | float distance = node->distanceToCamera(*viewFrustum); | 436 | float distance = node->distanceToCamera(*viewFrustum); |
| 450 | _nodeCount++; | 437 | _nodeCount++; |
| 451 | float distanceRatio = (_minDistance==_maxDistance) ? 1 : (distance - _minDistance)/(_maxDistance - _minDistance); | 438 | float distanceRatio = (_minDistance == _maxDistance) ? 1 : (distance - _minDistance) / (_maxDistance - _minDistance); |
| 452 | 439 | ||
| 453 | // We want to colorize this in 16 bug chunks of color | 440 | // We want to colorize this in 16 bug chunks of color |
| 454 | const unsigned char maxColor = 255; | 441 | const unsigned char maxColor = 255; |
| 455 | const unsigned char colorBands = 16; | 442 | const unsigned char colorBands = 16; |
| 456 | const unsigned char gradientOver = 128; | 443 | const unsigned char gradientOver = 128; |
| 457 | unsigned char colorBand = (colorBands*distanceRatio); | 444 | unsigned char colorBand = (colorBands * distanceRatio); |
| 458 | unsigned char newR = (colorBand*(gradientOver/colorBands))+(maxColor-gradientOver); | 445 | node->setFalseColor((colorBand * (gradientOver / colorBands)) + (maxColor - gradientOver), 0, 0); |
| 459 | unsigned char newG = 0; | ||
| 460 | unsigned char newB = 0; | ||
| 461 | node->setFalseColor(newR,newG,newB); | ||
| 462 | } | 446 | } |
| 463 | return true; // keep going! | 447 | return true; // keep going! |
| 464 | } | 448 | } |
| @@ -491,10 +475,10 @@ void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) { · 26 unmodified lines | |||
| 491 | _maxDistance = 0.0; | 475 | _maxDistance = 0.0; |
| 492 | _minDistance = FLT_MAX; | 476 | _minDistance = FLT_MAX; |
| 493 | _tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation,(void*)viewFrustum); | 477 | _tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation,(void*)viewFrustum); |
| 494 | printLog("determining distance range for %d nodes\n",_nodeCount); | 478 | printLog("determining distance range for %d nodes\n", _nodeCount); |
| 495 | _nodeCount = 0; | 479 | _nodeCount = 0; |
| 496 | _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum); | 480 | _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum); |
| 497 | printLog("setting in distance false color for %d nodes\n",_nodeCount); | 481 | printLog("setting in distance false color for %d nodes\n", _nodeCount); |
| 498 | setupNewVoxelsForDrawing(); | 482 | setupNewVoxelsForDrawing(); |
| 499 | } | 483 | } |
| 500 | 484 | ||