Showing the changes to interface/src/VoxelSystem.cpp (1 of 9 files). Show all
Unified · Split
| @@ -23,6 +23,8 @@ · 22 unmodified lines | ||
| 23 | 23 | #include <PacketHeaders.h> |
| 24 | 24 | #include <PerfStat.h> |
| 25 | 25 | #include <SharedUtil.h> |
| 26 | +#include <NodeList.h> | |
| 27 | +#include <NodeTypes.h> | |
| 26 | 28 | |
| 27 | 29 | #include "Application.h" |
| 28 | 30 | #include "CoverageMap.h" |
| @@ -61,6 +63,8 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels) : · 32 unmodified lines | ||
| 61 | 63 | |
| 62 | 64 | VoxelNode::addDeleteHook(this); |
| 63 | 65 | _abandonedVBOSlots = 0; |
| 66 | + _falseColorizeBySource = false; | |
| 67 | + _dataSourceID = UNKNOWN_NODE_ID; | |
| 64 | 68 | } |
| 65 | 69 | |
| 66 | 70 | void VoxelSystem::nodeDeleted(VoxelNode* node) { |
| @@ -153,13 +157,15 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 86 unmodified lines | ||
| 153 | 157 | case PACKET_TYPE_VOXEL_DATA: { |
| 154 | 158 | PerformanceWarning warn(_renderWarningsOn, "readBitstreamToTree()"); |
| 155 | 159 | // ask the VoxelTree to read the bitstream into the tree |
| 156 | − _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, WANT_COLOR, WANT_EXISTS_BITS); | |
| 160 | + ReadBitstreamToTreeParams args(WANT_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID()); | |
| 161 | + _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args); | |
| 157 | 162 | } |
| 158 | 163 | break; |
| 159 | 164 | case PACKET_TYPE_VOXEL_DATA_MONOCHROME: { |
| 160 | 165 | PerformanceWarning warn(_renderWarningsOn, "readBitstreamToTree()"); |
| 161 | 166 | // ask the VoxelTree to read the MONOCHROME bitstream into the tree |
| 162 | − _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, NO_COLOR, WANT_EXISTS_BITS); | |
| 167 | + ReadBitstreamToTreeParams args(NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID()); | |
| 168 | + _tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args); | |
| 163 | 169 | } |
| 164 | 170 | break; |
| 165 | 171 | case PACKET_TYPE_Z_COMMAND: |
| @@ -747,6 +753,7 @@ void VoxelSystem::randomizeVoxelColors() { · 581 unmodified lines | ||
| 747 | 753 | _nodeCount = 0; |
| 748 | 754 | _tree->recurseTreeWithOperation(randomColorOperation); |
| 749 | 755 | qDebug("setting randomized true color for %d nodes\n", _nodeCount); |
| 756 | + _tree->setDirtyBit(); | |
| 750 | 757 | setupNewVoxelsForDrawing(); |
| 751 | 758 | } |
| 752 | 759 | |
| @@ -761,6 +768,7 @@ void VoxelSystem::falseColorizeRandom() { · 8 unmodified lines | ||
| 761 | 768 | _nodeCount = 0; |
| 762 | 769 | _tree->recurseTreeWithOperation(falseColorizeRandomOperation); |
| 763 | 770 | qDebug("setting randomized false color for %d nodes\n", _nodeCount); |
| 771 | + _tree->setDirtyBit(); | |
| 764 | 772 | setupNewVoxelsForDrawing(); |
| 765 | 773 | } |
| 766 | 774 | |
| @@ -775,6 +783,7 @@ void VoxelSystem::trueColorize() { · 8 unmodified lines | ||
| 775 | 783 | _nodeCount = 0; |
| 776 | 784 | _tree->recurseTreeWithOperation(trueColorizeOperation); |
| 777 | 785 | qDebug("setting true color for %d nodes\n", _nodeCount); |
| 786 | + _tree->setDirtyBit(); | |
| 778 | 787 | setupNewVoxelsForDrawing(); |
| 779 | 788 | } |
| 780 | 789 | |
| @@ -795,6 +804,84 @@ void VoxelSystem::falseColorizeInView(ViewFrustum* viewFrustum) { · 14 unmodified lines | ||
| 795 | 804 | _nodeCount = 0; |
| 796 | 805 | _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum); |
| 797 | 806 | qDebug("setting in view false color for %d nodes\n", _nodeCount); |
| 807 | + _tree->setDirtyBit(); | |
| 808 | + setupNewVoxelsForDrawing(); | |
| 809 | +} | |
| 810 | + | |
| 811 | +// combines the removeOutOfView args into a single class | |
| 812 | +class groupColor { | |
| 813 | +public: | |
| 814 | + unsigned char red, green, blue; | |
| 815 | + groupColor(unsigned char red, unsigned char green, unsigned char blue) : | |
| 816 | + red(red), green(green), blue(blue) { }; | |
| 817 | + | |
| 818 | + groupColor(const groupColor& color) : | |
| 819 | + red(color.red), green(color.green), blue(color.blue) { }; | |
| 820 | + | |
| 821 | + groupColor() : | |
| 822 | + red(0), green(0), blue(0) { }; | |
| 823 | + | |
| 824 | +}; | |
| 825 | + | |
| 826 | +class colorizeBySourceArgs { | |
| 827 | +public: | |
| 828 | + std::map<uint16_t, groupColor> colors; | |
| 829 | +}; | |
| 830 | + | |
| 831 | +// Will false colorize voxels that are not in view | |
| 832 | +bool VoxelSystem::falseColorizeBySourceOperation(VoxelNode* node, void* extraData) { | |
| 833 | + colorizeBySourceArgs* args = (colorizeBySourceArgs*)extraData; | |
| 834 | + _nodeCount++; | |
| 835 | + if (node->isColored()) { | |
| 836 | + // pick a color based on the source - we want each source to be obviously different | |
| 837 | + uint16_t nodeID = node->getSourceID(); | |
| 838 | + | |
| 839 | + //printf("false colorizing from source %d, color: %d, %d, %d\n", nodeID, | |
| 840 | + // args->colors[nodeID].red, args->colors[nodeID].green, args->colors[nodeID].blue); | |
| 841 | + | |
| 842 | + node->setFalseColor(args->colors[nodeID].red, args->colors[nodeID].green, args->colors[nodeID].blue); | |
| 843 | + } | |
| 844 | + return true; // keep going! | |
| 845 | +} | |
| 846 | + | |
| 847 | +void VoxelSystem::falseColorizeBySource() { | |
| 848 | + _nodeCount = 0; | |
| 849 | + colorizeBySourceArgs args; | |
| 850 | + const int NUMBER_OF_COLOR_GROUPS = 3; | |
| 851 | + const unsigned char MIN_COLOR = 128; | |
| 852 | + int voxelServerCount = 0; | |
| 853 | + groupColor groupColors[NUMBER_OF_COLOR_GROUPS] = { groupColor(255, 0, 0), | |
| 854 | + groupColor(0, 255, 0), | |
| 855 | + groupColor(0, 0, 255)}; | |
| 856 | + | |
| 857 | + // create a bunch of colors we'll use during colorization | |
| 858 | + NodeList* nodeList = NodeList::getInstance(); | |
| 859 | + for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | |
| 860 | + if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | |
| 861 | + uint16_t nodeID = node->getNodeID(); | |
| 862 | + int groupColor = voxelServerCount % NUMBER_OF_COLOR_GROUPS; | |
| 863 | + args.colors[nodeID] = groupColors[groupColor]; | |
| 864 | + | |
| 865 | + //printf("assigning color for source %d, color: %d, %d, %d\n", nodeID, | |
| 866 | + // args.colors[nodeID].red, args.colors[nodeID].green, args.colors[nodeID].blue); | |
| 867 | + | |
| 868 | + if (groupColors[groupColor].red > 0) { | |
| 869 | + groupColors[groupColor].red = ((groupColors[groupColor].red - MIN_COLOR)/2) + MIN_COLOR; | |
| 870 | + } | |
| 871 | + if (groupColors[groupColor].green > 0) { | |
| 872 | + groupColors[groupColor].green = ((groupColors[groupColor].green - MIN_COLOR)/2) + MIN_COLOR; | |
| 873 | + } | |
| 874 | + if (groupColors[groupColor].blue > 0) { | |
| 875 | + groupColors[groupColor].blue = ((groupColors[groupColor].blue - MIN_COLOR)/2) + MIN_COLOR; | |
| 876 | + } | |
| 877 | + | |
| 878 | + voxelServerCount++; | |
| 879 | + } | |
| 880 | + } | |
| 881 | + | |
| 882 | + _tree->recurseTreeWithOperation(falseColorizeBySourceOperation, &args); | |
| 883 | + qDebug("setting false color by source for %d nodes\n", _nodeCount); | |
| 884 | + _tree->setDirtyBit(); | |
| 798 | 885 | setupNewVoxelsForDrawing(); |
| 799 | 886 | } |
| 800 | 887 | |
| @@ -848,6 +935,7 @@ void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) { · 47 unmodified lines | ||
| 848 | 935 | _nodeCount = 0; |
| 849 | 936 | _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum); |
| 850 | 937 | qDebug("setting in distance false color for %d nodes\n", _nodeCount); |
| 938 | + _tree->setDirtyBit(); | |
| 851 | 939 | setupNewVoxelsForDrawing(); |
| 852 | 940 | } |
| 853 | 941 | |
| @@ -1027,6 +1115,7 @@ void VoxelSystem::falseColorizeRandomEveryOther() { · 173 unmodified lines | ||
| 1027 | 1115 | _tree->recurseTreeWithOperation(falseColorizeRandomEveryOtherOperation,&args); |
| 1028 | 1116 | qDebug("randomized false color for every other node: total %ld, colorable %ld, colored %ld\n", |
| 1029 | 1117 | args.totalNodes, args.colorableNodes, args.coloredNodes); |
| 1118 | + _tree->setDirtyBit(); | |
| 1030 | 1119 | setupNewVoxelsForDrawing(); |
| 1031 | 1120 | } |
| 1032 | 1121 | |
| @@ -1331,6 +1420,7 @@ void VoxelSystem::falseColorizeOccluded() { · 298 unmodified lines | ||
| 1331 | 1420 | |
| 1332 | 1421 | //myCoverageMap.erase(); |
| 1333 | 1422 | |
| 1423 | + _tree->setDirtyBit(); | |
| 1334 | 1424 | setupNewVoxelsForDrawing(); |
| 1335 | 1425 | } |
| 1336 | 1426 | |
| @@ -1447,6 +1537,7 @@ void VoxelSystem::falseColorizeOccludedV2() { · 110 unmodified lines | ||
| 1447 | 1537 | //myCoverageMapV2.erase(); |
| 1448 | 1538 | |
| 1449 | 1539 | |
| 1540 | + _tree->setDirtyBit(); | |
| 1450 | 1541 | setupNewVoxelsForDrawing(); |
| 1451 | 1542 | } |
| 1452 | 1543 | |