added visulization for voxel add/kill

This commit is contained in:
ZappoMan 2013-08-06 12:05:43 -07:00
parent 73510ec975
commit 88e2e3dd3f
6 changed files with 138 additions and 1 deletions

View file

@ -3069,6 +3069,19 @@ void Application::displaySide(Camera& whichCamera) {
// brad's frustum for debugging
if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum);
// render voxel fades if they exist
if (_voxelFades.size() > 0) {
for(std::vector<VoxelFade>::iterator fade = _voxelFades.begin(); fade != _voxelFades.end();) {
fade->render();
if(fade->isDone()) {
fade = _voxelFades.erase(fade);
} else {
++fade;
}
}
}
}
void Application::displayOverlay() {
@ -3839,6 +3852,15 @@ void Application::nodeKilled(Node* node) {
printf("voxel server going away...... v[%f, %f, %f, %f]\n",
jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s);
// Add the jurisditionDetails object to the list of "fade outs"
const float NODE_KILLED_RED = 1.0f;
const float NODE_KILLED_GREEN = 0.0f;
const float NODE_KILLED_BLUE = 0.0f;
VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE);
fade.voxelDetails = jurisditionDetails;
_voxelFades.push_back(fade);
}
}
}
@ -3860,6 +3882,15 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng
if (_voxelServerJurisdictions.find(nodeID) == _voxelServerJurisdictions.end()) {
printf("stats from new voxel server... v[%f, %f, %f, %f]\n",
jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s);
// Add the jurisditionDetails object to the list of "fade outs"
const float NODE_ADDED_RED = 0.0f;
const float NODE_ADDED_GREEN = 1.0f;
const float NODE_ADDED_BLUE = 0.0f;
VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE);
fade.voxelDetails = jurisditionDetails;
_voxelFades.push_back(fade);
}
// store jurisdiction details for later use
_voxelServerJurisdictions[nodeID] = jurisditionDetails;

View file

@ -37,6 +37,7 @@
#include "Swatch.h"
#include "ToolsPalette.h"
#include "ViewFrustum.h"
#include "VoxelFade.h"
#include "VoxelSystem.h"
#include "Webcam.h"
#include "PieMenu.h"
@ -452,6 +453,8 @@ private:
int parseVoxelStats(unsigned char* messageData, ssize_t messageLength, sockaddr senderAddress);
std::map<uint16_t,VoxelPositionSize> _voxelServerJurisdictions;
std::vector<VoxelFade> _voxelFades;
};
#endif /* defined(__interface__Application__) */

View file

@ -0,0 +1,59 @@
//
// VoxelFade.cpp
// interface
//
// Created by Brad Hefta-Gaub on 8/6/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#include <gl.h> // Header File For The OpenGL32 Library
#include <GLUT/GLUT.h>
#include <VoxelConstants.h>
#include "VoxelFade.h"
const float VoxelFade::FADE_OUT_START = 0.5f;
const float VoxelFade::FADE_OUT_END = 0.0f;
const float VoxelFade::FADE_OUT_STEP = -0.005f;
const float VoxelFade::FADE_IN_START = 0.0f;
const float VoxelFade::FADE_IN_END = 0.5f;
const float VoxelFade::FADE_IN_STEP = 0.005f;
const float VoxelFade::DEFAULT_RED = 0.5f;
const float VoxelFade::DEFAULT_GREEN = 0.5f;
const float VoxelFade::DEFAULT_BLUE = 0.5f;
VoxelFade::VoxelFade(FadeDirection direction, float red, float green, float blue) :
direction(direction),
red(red),
green(green),
blue(blue)
{
opacity = (direction == FADE_OUT) ? FADE_OUT_START : FADE_IN_START;
}
void VoxelFade::render() {
glDisable(GL_LIGHTING);
glPushMatrix();
glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
glColor4f(red, green, blue, opacity);
glTranslatef(voxelDetails.x + voxelDetails.s * 0.5f,
voxelDetails.y + voxelDetails.s * 0.5f,
voxelDetails.z + voxelDetails.s * 0.5f);
glLineWidth(1.0f);
glutSolidCube(voxelDetails.s);
glLineWidth(1.0f);
glPopMatrix();
glEnable(GL_LIGHTING);
opacity += (direction == FADE_OUT) ? FADE_OUT_STEP : FADE_IN_STEP;
}
bool VoxelFade::isDone() const {
if (direction == FADE_OUT) {
return opacity <= FADE_OUT_END;
} else {
return opacity >= FADE_IN_END;
}
return true; // unexpected case, assume we're done
}

43
interface/src/VoxelFade.h Normal file
View file

@ -0,0 +1,43 @@
//
// VoxelFade.h
// interface
//
// Created by Brad Hefta-Gaub on 8/6/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__VoxelFade__
#define __interface__VoxelFade__
#include <OctalCode.h> // for VoxelPositionSize
class VoxelFade {
public:
enum FadeDirection { FADE_OUT, FADE_IN};
static const float FADE_OUT_START;
static const float FADE_OUT_END;
static const float FADE_OUT_STEP;
static const float FADE_IN_START;
static const float FADE_IN_END;
static const float FADE_IN_STEP;
static const float DEFAULT_RED;
static const float DEFAULT_GREEN;
static const float DEFAULT_BLUE;
VoxelPositionSize voxelDetails;
FadeDirection direction;
float opacity;
float red;
float green;
float blue;
VoxelFade(FadeDirection direction = FADE_OUT, float red = DEFAULT_RED,
float green = DEFAULT_GREEN, float blue = DEFAULT_BLUE);
void render();
bool isDone() const;
};
#endif // __interface__VoxelFade__

View file

@ -37,7 +37,7 @@ float * firstVertexForCode(unsigned char * octalCode);
void copyFirstVertexForCode(unsigned char * octalCode, float* output);
struct VoxelPositionSize {
float x,y,z,s;
float x, y, z, s;
};
void voxelDetailsForCode(unsigned char * octalCode, VoxelPositionSize& voxelPositionSize);

View file

@ -14,6 +14,7 @@
#include <limits.h>
#include <OctalCode.h>
#include <glm/glm.hpp>
// this is where the coordinate system is represented
const glm::vec3 IDENTITY_RIGHT = glm::vec3( 1.0f, 0.0f, 0.0f);