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
56// Complaints: Brad :)56// Complaints: Brad :)
57// To Do: Need to add color data to the file.57// To Do: Need to add color data to the file.
58void VoxelSystem::loadVoxelsFile(char* fileName) {58void VoxelSystem::loadVoxelsFile(char* fileName) {
59 int vCount = 0;
59 60
60 std::ifstream file(fileName, std::ios::in|std::ios::binary);61 std::ifstream file(fileName, std::ios::in|std::ios::binary);
61 62
@@ -65,10 +66,11 @@ void VoxelSystem::loadVoxelsFile(char* fileName) { · 3 unmodified lines
65 int totalBytesRead = 0;66 int totalBytesRead = 0;
66 if(file.is_open())67 if(file.is_open())
67 {68 {
68 while (!file.eof()) {69 bool bail = false;
70 while (!file.eof() && !bail) {
69 file.get(octets);71 file.get(octets);
70 totalBytesRead++;72 totalBytesRead++;
71 lengthInBytes = (octets*3/8)+1;73 lengthInBytes = bytesRequiredForCodeLength(octets)-1; //(octets*3/8)+1;
72 unsigned char * voxelData = new unsigned char[lengthInBytes+1+3];74 unsigned char * voxelData = new unsigned char[lengthInBytes+1+3];
73 voxelData[0]=octets;75 voxelData[0]=octets;
74 char byte;76 char byte;
@@ -78,16 +80,32 @@ void VoxelSystem::loadVoxelsFile(char* fileName) { · 3 unmodified lines
78 totalBytesRead++;80 totalBytesRead++;
79 voxelData[i+1] = byte;81 voxelData[i+1] = byte;
80 }82 }
81 // random color data83 // read color data
82 voxelData[lengthInBytes+1] = randomColorValue(65);84 char red,green,blue;
83 voxelData[lengthInBytes+2] = randomColorValue(65);85 file.get(red);
84 voxelData[lengthInBytes+3] = randomColorValue(65);86 file.get(green);
85 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);
86 tree->readCodeColorBufferToTree(voxelData);102 tree->readCodeColorBufferToTree(voxelData);
87 delete voxelData;103 delete voxelData;
88 }104 }
89 file.close();105 file.close();
90 }106 }
107
108 tree->pruneTree(tree->rootNode);
91 109
92 // reset the verticesEndPointer so we're writing to the beginning of the array110 // reset the verticesEndPointer so we're writing to the beginning of the array
93 verticesEndPointer = verticesArray;111 verticesEndPointer = verticesArray;