History

Fixed getCommandOption and cmOptionExists to be more porable added support for --NoConnect command line option to test running without connecting added pruneTree to VoxelTree

ZappoMan committed 13 years ago

Commit 2f6b2461 parent 07115396 files · +101 −21Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 6 files). Show all

Unified · Split

interface/src/VoxelSystem.cpp+25−7
@@ -56,6 +56,7 @@ VoxelSystem::~VoxelSystem() { · 55 unmodified lines
5656 // Complaints: Brad :)
5757 // To Do: Need to add color data to the file.
5858 void VoxelSystem::loadVoxelsFile(char* fileName) {
59+ int vCount = 0;
5960
6061 std::ifstream file(fileName, std::ios::in|std::ios::binary);
6162
@@ -65,10 +66,11 @@ void VoxelSystem::loadVoxelsFile(char* fileName) { · 3 unmodified lines
6566 int totalBytesRead = 0;
6667 if(file.is_open())
6768 {
68− while (!file.eof()) {
69+ bool bail = false;
70+ while (!file.eof() && !bail) {
6971 file.get(octets);
7072 totalBytesRead++;
71− lengthInBytes = (octets*3/8)+1;
73+ lengthInBytes = bytesRequiredForCodeLength(octets)-1; //(octets*3/8)+1;
7274 unsigned char * voxelData = new unsigned char[lengthInBytes+1+3];
7375 voxelData[0]=octets;
7476 char byte;
@@ -78,16 +80,32 @@ void VoxelSystem::loadVoxelsFile(char* fileName) { · 3 unmodified lines
7880 totalBytesRead++;
7981 voxelData[i+1] = byte;
8082 }
81− // random color data
82− voxelData[lengthInBytes+1] = randomColorValue(65);
83− voxelData[lengthInBytes+2] = randomColorValue(65);
84− voxelData[lengthInBytes+3] = randomColorValue(65);
85−
83+ // read color data
84+ char red,green,blue;
85+ file.get(red);
86+ file.get(green);
87+ file.get(blue);
88+
89+ //printf("red:%d\n",red);
90+ //printf("green:%d\n",green);
91+ //printf("blue:%d\n",blue);
92+ vCount++;
93+ //printf("vCount:%d\n",vCount);
94+
95+ //randomColorValue(65);
96+ float rf = randFloatInRange(.5,1); // add a little bit of variance to colors so we can see the voxels
97+ voxelData[lengthInBytes+1] = red * rf;
98+ voxelData[lengthInBytes+2] = green * rf;
99+ voxelData[lengthInBytes+3] = blue * rf;
100+
101+ //printVoxelCode(voxelData);
86102 tree->readCodeColorBufferToTree(voxelData);
87103 delete voxelData;
88104 }
89105 file.close();
90106 }
107+
108+ tree->pruneTree(tree->rootNode);
91109
92110 // reset the verticesEndPointer so we're writing to the beginning of the array
93111 verticesEndPointer = verticesArray;