From 9ba0e3bb0c25fb745ebf42d5a6d7c11772b23358 Mon Sep 17 00:00:00 2001 From: Mark Peng Date: Thu, 1 Aug 2013 13:03:17 -0700 Subject: [PATCH] Add reference lines to mouse voxel when adding/deleting voxels. --- interface/src/Application.cpp | 3 ++- interface/src/Util.cpp | 26 ++++++++++++++++++++++++++ interface/src/Util.h | 3 ++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9b292b3d50..7fc9bd7ac8 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2676,13 +2676,14 @@ void Application::displaySide(Camera& whichCamera) { if (_mouseVoxel.s != 0) { glDisable(GL_LIGHTING); glPushMatrix(); + glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE); + renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); if (_addVoxelMode->isChecked()) { // use a contrasting color so that we can see what we're doing glColor3ub(_mouseVoxel.red + 128, _mouseVoxel.green + 128, _mouseVoxel.blue + 128); } else { glColor3ub(_mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue); } - glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE); glTranslatef(_mouseVoxel.x + _mouseVoxel.s*0.5f, _mouseVoxel.y + _mouseVoxel.s*0.5f, _mouseVoxel.z + _mouseVoxel.s*0.5f); diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 0f2c3a8955..d2f9e56462 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -365,7 +365,33 @@ void renderGroundPlaneGrid(float size, float impact) { glEnd(); } +void renderMouseVoxelGrid(const float& mouseVoxelX, const float& mouseVoxelY, const float& mouseVoxelZ, const float& mouseVoxelS) { + glm::vec3 origin = glm::vec3(mouseVoxelX, mouseVoxelY, mouseVoxelZ); + glLineWidth(3.0); + + const int HALF_GRID_DIMENSIONS = 4; + glBegin(GL_LINES); + + glm::vec3 xColor(0.0, 0.6, 0.0); + glColor3fv(&xColor.x); + + glVertex3f(origin.x + HALF_GRID_DIMENSIONS * mouseVoxelS, 0, origin.z); + glVertex3f(origin.x - HALF_GRID_DIMENSIONS * mouseVoxelS, 0, origin.z); + + glm::vec3 zColor(0.0, 0.0, 0.6); + glColor3fv(&zColor.x); + + glVertex3f(origin.x, 0, origin.z + HALF_GRID_DIMENSIONS * mouseVoxelS); + glVertex3f(origin.x, 0, origin.z - HALF_GRID_DIMENSIONS * mouseVoxelS); + + glm::vec3 yColor(0.6, 0.0, 0.0); + glColor3fv(&yColor.x); + + glVertex3f(origin.x, 0, origin.z); + glVertex3f(origin.x, origin.y, origin.z); + glEnd(); +} void renderDiskShadow(glm::vec3 position, glm::vec3 upDirection, float radius, float darkness) { diff --git a/interface/src/Util.h b/interface/src/Util.h index fe59637a42..67ffebf4b3 100644 --- a/interface/src/Util.h +++ b/interface/src/Util.h @@ -59,8 +59,9 @@ double diffclock(timeval *clock1,timeval *clock2); void renderGroundPlaneGrid(float size, float impact); -void renderCollisionOverlay(int width, int height, float magnitude); +void renderMouseVoxelGrid(const float& mouseVoxelX, const float& mouseVoxelY, const float& mouseVoxelZ, const float& mouseVoxelS); +void renderCollisionOverlay(int width, int height, float magnitude); void renderDiskShadow(glm::vec3 position, glm::vec3 upDirection, float radius, float darkness);