Merge pull request #133 from ey6es/master

Normals for voxel geometry.
This commit is contained in:
birarda 2013-04-24 11:59:27 -07:00
commit 3c36c7b726
2 changed files with 91 additions and 65 deletions

View file

@ -23,25 +23,27 @@
const int MAX_VOXELS_PER_SYSTEM = 250000; const int MAX_VOXELS_PER_SYSTEM = 250000;
const int VERTICES_PER_VOXEL = 8; const int VERTICES_PER_VOXEL = 24;
const int VERTEX_POINTS_PER_VOXEL = 3 * VERTICES_PER_VOXEL; const int VERTEX_POINTS_PER_VOXEL = 3 * VERTICES_PER_VOXEL;
const int INDICES_PER_VOXEL = 3 * 12; const int INDICES_PER_VOXEL = 3 * 12;
float identityVertices[] = { 0, 0, 0, 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,
1, 0, 0, 0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1,
1, 1, 0, 0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1 };
0, 1, 0,
0, 0, 1,
1, 0, 1,
1, 1, 1,
0, 1, 1 };
GLubyte identityIndices[] = { 0,1,2, 0,2,3, GLfloat identityNormals[] = { 0,0,-1, 0,0,-1, 0,0,-1, 0,0,-1,
0,1,5, 0,4,5, 0,0,+1, 0,0,+1, 0,0,+1, 0,0,+1,
0,3,7, 0,4,7, 0,-1,0, 0,-1,0, 0,+1,0, 0,+1,0,
1,2,6, 1,5,6, 0,-1,0, 0,-1,0, 0,+1,0, 0,+1,0,
2,3,7, 2,6,7, -1,0,0, +1,0,0, +1,0,0, -1,0,0,
4,5,6, 4,6,7 }; -1,0,0, +1,0,0, +1,0,0, -1,0,0 };
GLubyte identityIndices[] = { 0,2,1, 0,3,2, // Z- .
8,9,13, 8,13,12, // Y-
16,23,19, 16,20,23, // X-
17,18,22, 17,22,21, // X+
10,11,15, 10,15,14, // Y+
4,5,6, 4,6,7 }; // Z+ .
VoxelSystem::VoxelSystem() { VoxelSystem::VoxelSystem() {
voxelsRendered = 0; voxelsRendered = 0;
@ -49,7 +51,7 @@ VoxelSystem::VoxelSystem() {
pthread_mutex_init(&bufferWriteLock, NULL); pthread_mutex_init(&bufferWriteLock, NULL);
} }
VoxelSystem::~VoxelSystem() { VoxelSystem::~VoxelSystem() {
delete[] readVerticesArray; delete[] readVerticesArray;
delete[] writeVerticesArray; delete[] writeVerticesArray;
delete[] readColorsArray; delete[] readColorsArray;
@ -70,9 +72,9 @@ void VoxelSystem::setViewerHead(Head *newViewerHead) {
// Complaints: Brad :) // Complaints: Brad :)
// To Do: Need to add color data to the file. // To Do: Need to add color data to the file.
void VoxelSystem::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) { void VoxelSystem::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) {
tree->loadVoxelsFile(fileName,wantColorRandomizer); tree->loadVoxelsFile(fileName,wantColorRandomizer);
copyWrittenDataToReadArrays(); copyWrittenDataToReadArrays();
} }
@ -118,7 +120,7 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
unsigned char command = *sourceBuffer; unsigned char command = *sourceBuffer;
unsigned char *voxelData = sourceBuffer + 1; unsigned char *voxelData = sourceBuffer + 1;
switch(command) { switch(command) {
case PACKET_HEADER_VOXEL_DATA: case PACKET_HEADER_VOXEL_DATA:
// ask the VoxelTree to read the bitstream into the tree // ask the VoxelTree to read the bitstream into the tree
@ -131,7 +133,7 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
case PACKET_HEADER_Z_COMMAND: case PACKET_HEADER_Z_COMMAND:
// the Z command is a special command that allows the sender to send high level semantic // the Z command is a special command that allows the sender to send high level semantic
// requests, like erase all, or add sphere scene, different receivers may handle these // requests, like erase all, or add sphere scene, different receivers may handle these
// messages differently // messages differently
char* packetData = (char *)sourceBuffer; char* packetData = (char *)sourceBuffer;
char* command = &packetData[1]; // start of the command char* command = &packetData[1]; // start of the command
@ -152,7 +154,7 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
} }
break; break;
} }
setupNewVoxelsForDrawing(); setupNewVoxelsForDrawing();
return numBytes; return numBytes;
} }
@ -212,11 +214,11 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosi
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
// check if there is a child here // check if there is a child here
if (currentNode->children[i] != NULL) { if (currentNode->children[i] != NULL) {
glm::vec3 childNodePosition; glm::vec3 childNodePosition;
copyFirstVertexForCode(currentNode->children[i]->octalCode,(float*)&childNodePosition); copyFirstVertexForCode(currentNode->children[i]->octalCode,(float*)&childNodePosition);
childNodePosition *= (float)TREE_SCALE; // scale it up childNodePosition *= (float)TREE_SCALE; // scale it up
/**** disabled ************************************************************************************************ /**** disabled ************************************************************************************************
// Note: Stephen, I intentionally left this in so you would talk to me about it. Here's the deal, this code // Note: Stephen, I intentionally left this in so you would talk to me about it. Here's the deal, this code
// doesn't seem to work correctly. It returns X and Z flipped and the values are negative. Since we use the // doesn't seem to work correctly. It returns X and Z flipped and the values are negative. Since we use the
@ -226,7 +228,7 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosi
// calculate the child's position based on the parent position // calculate the child's position based on the parent position
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
childNodePosition[j] = nodePosition[j]; childNodePosition[j] = nodePosition[j];
if (oneAtBit(branchIndexWithDescendant(currentNode->octalCode,currentNode->children[i]->octalCode),(7 - j))) { if (oneAtBit(branchIndexWithDescendant(currentNode->octalCode,currentNode->children[i]->octalCode),(7 - j))) {
childNodePosition[j] -= (powf(0.5, *currentNode->children[i]->octalCode) * TREE_SCALE); childNodePosition[j] -= (powf(0.5, *currentNode->children[i]->octalCode) * TREE_SCALE);
} }
@ -243,13 +245,13 @@ int VoxelSystem::treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosi
float startVertex[3]; float startVertex[3];
copyFirstVertexForCode(currentNode->octalCode,(float*)&startVertex); copyFirstVertexForCode(currentNode->octalCode,(float*)&startVertex);
float voxelScale = 1 / powf(2, *currentNode->octalCode); float voxelScale = 1 / powf(2, *currentNode->octalCode);
// populate the array with points for the 8 vertices // populate the array with points for the 8 vertices
// and RGB color for each added vertex // and RGB color for each added vertex
for (int j = 0; j < VERTEX_POINTS_PER_VOXEL; j++ ) { for (int j = 0; j < VERTEX_POINTS_PER_VOXEL; j++ ) {
*writeVerticesEndPointer = startVertex[j % 3] + (identityVertices[j] * voxelScale); *writeVerticesEndPointer = startVertex[j % 3] + (identityVertices[j] * voxelScale);
*(writeColorsArray + (writeVerticesEndPointer - writeVerticesArray)) = currentNode->getColor()[j % 3]; *(writeColorsArray + (writeVerticesEndPointer - writeVerticesArray)) = currentNode->getColor()[j % 3];
writeVerticesEndPointer++; writeVerticesEndPointer++;
} }
voxelsAdded++; voxelsAdded++;
@ -271,7 +273,7 @@ void VoxelSystem::init() {
readColorsArray = new GLubyte[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM]; readColorsArray = new GLubyte[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
GLuint *indicesArray = new GLuint[INDICES_PER_VOXEL * MAX_VOXELS_PER_SYSTEM]; GLuint *indicesArray = new GLuint[INDICES_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
// populate the indicesArray // populate the indicesArray
// this will not change given new voxels, so we can set it all up now // this will not change given new voxels, so we can set it all up now
for (int n = 0; n < MAX_VOXELS_PER_SYSTEM; n++) { for (int n = 0; n < MAX_VOXELS_PER_SYSTEM; n++) {
@ -279,84 +281,107 @@ void VoxelSystem::init() {
int voxelIndexOffset = n * INDICES_PER_VOXEL; int voxelIndexOffset = n * INDICES_PER_VOXEL;
GLuint *currentIndicesPos = indicesArray + voxelIndexOffset; GLuint *currentIndicesPos = indicesArray + voxelIndexOffset;
int startIndex = (n * VERTICES_PER_VOXEL); int startIndex = (n * VERTICES_PER_VOXEL);
for (int i = 0; i < INDICES_PER_VOXEL; i++) { for (int i = 0; i < INDICES_PER_VOXEL; i++) {
// add indices for this side of the cube // add indices for this side of the cube
currentIndicesPos[i] = startIndex + identityIndices[i]; currentIndicesPos[i] = startIndex + identityIndices[i];
} }
} }
GLfloat *normalsArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
GLfloat *normalsArrayEndPointer = normalsArray;
// populate the normalsArray
for (int n = 0; n < MAX_VOXELS_PER_SYSTEM; n++) {
for (int i = 0; i < VERTEX_POINTS_PER_VOXEL; i++) {
*(normalsArrayEndPointer++) = identityNormals[i];
}
}
// VBO for the verticesArray // VBO for the verticesArray
glGenBuffers(1, &vboVerticesID); glGenBuffers(1, &vboVerticesID);
glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID); glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID);
glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW);
// VBO for the normalsArray
glGenBuffers(1, &vboNormalsID);
glBindBuffer(GL_ARRAY_BUFFER, vboNormalsID);
glBufferData(GL_ARRAY_BUFFER,
VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * MAX_VOXELS_PER_SYSTEM,
normalsArray, GL_STATIC_DRAW);
// VBO for colorsArray // VBO for colorsArray
glGenBuffers(1, &vboColorsID); glGenBuffers(1, &vboColorsID);
glBindBuffer(GL_ARRAY_BUFFER, vboColorsID); glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);
glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLubyte) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLubyte) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW);
// VBO for the indicesArray // VBO for the indicesArray
glGenBuffers(1, &vboIndicesID); glGenBuffers(1, &vboIndicesID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, glBufferData(GL_ELEMENT_ARRAY_BUFFER,
INDICES_PER_VOXEL * sizeof(GLuint) * MAX_VOXELS_PER_SYSTEM, INDICES_PER_VOXEL * sizeof(GLuint) * MAX_VOXELS_PER_SYSTEM,
indicesArray, GL_STATIC_DRAW); indicesArray, GL_STATIC_DRAW);
// delete the indices array that is no longer needed // delete the indices and normals arrays that are no longer needed
delete[] indicesArray; delete[] indicesArray;
delete[] normalsArray;
} }
void VoxelSystem::render() { void VoxelSystem::render() {
glPushMatrix(); glPushMatrix();
if (readVerticesEndPointer != readVerticesArray) { if (readVerticesEndPointer != readVerticesArray) {
// try to lock on the buffer write // try to lock on the buffer write
// just avoid pulling new data if it is currently being written // just avoid pulling new data if it is currently being written
if (pthread_mutex_trylock(&bufferWriteLock) == 0) { if (pthread_mutex_trylock(&bufferWriteLock) == 0) {
glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID); glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID);
glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLfloat), readVerticesArray); glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLfloat), readVerticesArray);
glBindBuffer(GL_ARRAY_BUFFER, vboColorsID); glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);
glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLubyte), readColorsArray); glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLubyte), readColorsArray);
readVerticesEndPointer = readVerticesArray; readVerticesEndPointer = readVerticesArray;
pthread_mutex_unlock(&bufferWriteLock); pthread_mutex_unlock(&bufferWriteLock);
} }
} }
// tell OpenGL where to find vertex and color information // tell OpenGL where to find vertex and color information
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID); glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID);
glVertexPointer(3, GL_FLOAT, 0, 0); glVertexPointer(3, GL_FLOAT, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, vboNormalsID);
glNormalPointer(GL_FLOAT, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, vboColorsID); glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);
glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0); glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);
// draw the number of voxels we have // draw the number of voxels we have
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID);
glScalef(10, 10, 10); glScalef(10, 10, 10);
glDrawElements(GL_TRIANGLES, 36 * voxelsRendered, GL_UNSIGNED_INT, 0); glDrawElements(GL_TRIANGLES, 36 * voxelsRendered, GL_UNSIGNED_INT, 0);
// deactivate vertex and color arrays after drawing // deactivate vertex and color arrays after drawing
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_COLOR_ARRAY);
// bind with 0 to switch back to normal operation // bind with 0 to switch back to normal operation
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
// scale back down to 1 so heads aren't massive // scale back down to 1 so heads aren't massive
glPopMatrix(); glPopMatrix();
} }
void VoxelSystem::simulate(float deltaTime) { void VoxelSystem::simulate(float deltaTime) {
} }
int VoxelSystem::_nodeCount = 0; int VoxelSystem::_nodeCount = 0;
@ -367,7 +392,7 @@ bool VoxelSystem::randomColorOperation(VoxelNode* node, bool down, void* extraDa
if (down) { if (down) {
return true; return true;
} }
_nodeCount++; _nodeCount++;
if (node->isColored()) { if (node->isColored()) {
nodeColor newColor = { 0,0,0,1 }; nodeColor newColor = { 0,0,0,1 };
@ -398,9 +423,9 @@ bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, bool down, void*
if (down) { if (down) {
return true; return true;
} }
_nodeCount++; _nodeCount++;
// always false colorize // always false colorize
unsigned char newR = randomColorValue(150); unsigned char newR = randomColorValue(150);
unsigned char newG = randomColorValue(150); unsigned char newG = randomColorValue(150);
@ -427,7 +452,7 @@ bool VoxelSystem::trueColorizeOperation(VoxelNode* node, bool down, void* extraD
if (down) { if (down) {
return true; return true;
} }
_nodeCount++; _nodeCount++;
node->setFalseColored(false); node->setFalseColored(false);
//printf("setting true color for node %d\n",_nodeCount); //printf("setting true color for node %d\n",_nodeCount);
@ -448,23 +473,23 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, bool down, void*
if (down) { if (down) {
return true; return true;
} }
ViewFrustum* viewFrustum = (ViewFrustum*) extraData; ViewFrustum* viewFrustum = (ViewFrustum*) extraData;
_nodeCount++; _nodeCount++;
// only do this for truely colored voxels... // only do this for truely colored voxels...
if (node->isColored()) { if (node->isColored()) {
// first calculate the AAbox for the voxel // first calculate the AAbox for the voxel
AABox voxelBox; AABox voxelBox;
node->getAABox(voxelBox); node->getAABox(voxelBox);
voxelBox.scale(TREE_SCALE); voxelBox.scale(TREE_SCALE);
printf("voxelBox corner=(%f,%f,%f) x=%f\n", printf("voxelBox corner=(%f,%f,%f) x=%f\n",
voxelBox.getCorner().x, voxelBox.getCorner().y, voxelBox.getCorner().z, voxelBox.getCorner().x, voxelBox.getCorner().y, voxelBox.getCorner().z,
voxelBox.getSize().x); voxelBox.getSize().x);
// If the voxel is outside of the view frustum, then false color it red // If the voxel is outside of the view frustum, then false color it red
if (ViewFrustum::OUTSIDE == viewFrustum->boxInFrustum(voxelBox)) { if (ViewFrustum::OUTSIDE == viewFrustum->boxInFrustum(voxelBox)) {
// Out of view voxels are colored RED // Out of view voxels are colored RED
@ -481,7 +506,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, bool down, void*
} else { } else {
printf("voxel not colored, don't consider it\n"); printf("voxel not colored, don't consider it\n");
} }
return true; // keep going! return true; // keep going!
} }
@ -503,7 +528,7 @@ bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, bool d
} }
ViewFrustum* viewFrustum = (ViewFrustum*) extraData; ViewFrustum* viewFrustum = (ViewFrustum*) extraData;
// only do this for truly colored voxels... // only do this for truly colored voxels...
if (node->isColored()) { if (node->isColored()) {
@ -517,10 +542,10 @@ bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, bool d
// scale up the node position // scale up the node position
nodePosition = nodePosition*(float)TREE_SCALE; nodePosition = nodePosition*(float)TREE_SCALE;
float halfUnitForVoxel = powf(0.5, *node->octalCode) * (0.5 * TREE_SCALE); float halfUnitForVoxel = powf(0.5, *node->octalCode) * (0.5 * TREE_SCALE);
glm::vec3 viewerPosition = viewFrustum->getPosition(); glm::vec3 viewerPosition = viewFrustum->getPosition();
//printf("halfUnitForVoxel=%f\n",halfUnitForVoxel); //printf("halfUnitForVoxel=%f\n",halfUnitForVoxel);
//printf("viewer.x=%f y=%f z=%f \n", viewerPosition.x, viewerPosition.y, viewerPosition.z); //printf("viewer.x=%f y=%f z=%f \n", viewerPosition.x, viewerPosition.y, viewerPosition.z);
//printf("node.x=%f y=%f z=%f \n", nodePosition.x, nodePosition.y, nodePosition.z); //printf("node.x=%f y=%f z=%f \n", nodePosition.x, nodePosition.y, nodePosition.z);
@ -533,7 +558,7 @@ bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, bool d
_nodeCount++; _nodeCount++;
float distanceRatio = (_minDistance==_maxDistance) ? 1 : (distance - _minDistance)/(_maxDistance - _minDistance); float distanceRatio = (_minDistance==_maxDistance) ? 1 : (distance - _minDistance)/(_maxDistance - _minDistance);
// We want to colorize this in 16 bug chunks of color // We want to colorize this in 16 bug chunks of color
const unsigned char maxColor = 255; const unsigned char maxColor = 255;
const unsigned char colorBands = 16; const unsigned char colorBands = 16;
@ -542,7 +567,7 @@ bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, bool d
unsigned char newR = (colorBand*(gradientOver/colorBands))+(maxColor-gradientOver); unsigned char newR = (colorBand*(gradientOver/colorBands))+(maxColor-gradientOver);
unsigned char newG = 0; unsigned char newG = 0;
unsigned char newB = 0; unsigned char newB = 0;
//printf("Setting color down=%s distance=%f min=%f max=%f distanceRatio=%f color=%d \n", //printf("Setting color down=%s distance=%f min=%f max=%f distanceRatio=%f color=%d \n",
// (down ? "TRUE" : "FALSE"), distance, _minDistance, _maxDistance, distanceRatio, (int)newR); // (down ? "TRUE" : "FALSE"), distance, _minDistance, _maxDistance, distanceRatio, (int)newR);
node->setFalseColor(newR,newG,newB); node->setFalseColor(newR,newG,newB);
@ -568,7 +593,7 @@ bool VoxelSystem::getDistanceFromViewRangeOperation(VoxelNode* node, bool down,
//printf("getDistanceFromViewRangeOperation() down=%s\n",(down ? "TRUE" : "FALSE")); //printf("getDistanceFromViewRangeOperation() down=%s\n",(down ? "TRUE" : "FALSE"));
ViewFrustum* viewFrustum = (ViewFrustum*) extraData; ViewFrustum* viewFrustum = (ViewFrustum*) extraData;
// only do this for truly colored voxels... // only do this for truly colored voxels...
if (node->isColored()) { if (node->isColored()) {
@ -614,7 +639,7 @@ void VoxelSystem::falseColorizeDistanceFromView(ViewFrustum* viewFrustum) {
printf("determining distance range for %d nodes\n",_nodeCount); printf("determining distance range for %d nodes\n",_nodeCount);
_nodeCount = 0; _nodeCount = 0;
tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum); tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation,(void*)viewFrustum);
printf("setting in distance false color for %d nodes\n",_nodeCount); printf("setting in distance false color for %d nodes\n",_nodeCount);
setupNewVoxelsForDrawing(); setupNewVoxelsForDrawing();

View file

@ -25,10 +25,10 @@ class VoxelSystem : public AgentData {
public: public:
VoxelSystem(); VoxelSystem();
~VoxelSystem(); ~VoxelSystem();
int parseData(unsigned char* sourceBuffer, int numBytes); int parseData(unsigned char* sourceBuffer, int numBytes);
VoxelSystem* clone() const; VoxelSystem* clone() const;
void init(); void init();
void simulate(float deltaTime); void simulate(float deltaTime);
void render(); void render();
@ -76,6 +76,7 @@ private:
GLubyte *writeColorsArray; GLubyte *writeColorsArray;
GLfloat *writeVerticesEndPointer; GLfloat *writeVerticesEndPointer;
GLuint vboVerticesID; GLuint vboVerticesID;
GLuint vboNormalsID;
GLuint vboColorsID; GLuint vboColorsID;
GLuint vboIndicesID; GLuint vboIndicesID;
pthread_mutex_t bufferWriteLock; pthread_mutex_t bufferWriteLock;