From 61da1826c7ab084dd90da6601b6cc31a00f66686 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 2 Aug 2013 11:12:41 -0700 Subject: [PATCH 01/11] Reduce bitrate for full frame mode. --- interface/src/Webcam.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/Webcam.cpp b/interface/src/Webcam.cpp index b30d72aec6..3be88c7ea0 100644 --- a/interface/src/Webcam.cpp +++ b/interface/src/Webcam.cpp @@ -465,6 +465,8 @@ void FrameGrabber::grabFrame() { color = image; } + const int ENCODED_FACE_WIDTH = 128; + const int ENCODED_FACE_HEIGHT = 128; int encodedWidth; int encodedHeight; int depthBitrateMultiplier = 1; @@ -510,8 +512,6 @@ void FrameGrabber::grabFrame() { Rect imageBounds(0, 0, color.cols, color.rows); _searchWindow = Rect(clip(faceBounds.tl(), imageBounds), clip(faceBounds.br(), imageBounds)); } - const int ENCODED_FACE_WIDTH = 128; - const int ENCODED_FACE_HEIGHT = 128; encodedWidth = ENCODED_FACE_WIDTH; encodedHeight = ENCODED_FACE_HEIGHT; depthBitrateMultiplier = 2; @@ -595,7 +595,7 @@ void FrameGrabber::grabFrame() { // initialize encoder context(s) vpx_codec_enc_cfg_t codecConfig; vpx_codec_enc_config_default(vpx_codec_vp8_cx(), &codecConfig, 0); - codecConfig.rc_target_bitrate = encodedWidth * encodedHeight * + codecConfig.rc_target_bitrate = ENCODED_FACE_WIDTH * ENCODED_FACE_HEIGHT * codecConfig.rc_target_bitrate / codecConfig.g_w / codecConfig.g_h; codecConfig.g_w = encodedWidth; codecConfig.g_h = encodedHeight; From 90502a3ce5bafcc6cd8e6232134b409a92119214 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Fri, 2 Aug 2013 14:08:56 -0700 Subject: [PATCH 02/11] removed rendering of finger root positions --- interface/src/avatar/Hand.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 45a2117285..85c52f31a8 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -14,7 +14,7 @@ #include "Util.h" #include "renderer/ProgramObject.h" -const bool SHOW_LEAP_HAND = false; +const bool SHOW_LEAP_HAND = true; using namespace std; @@ -225,20 +225,7 @@ void Hand::renderLeapHandSpheres() { glPopMatrix(); } } - - for (size_t i = 0; i < _leapFingerRootBalls.size(); i++) { - float alpha = 1.0f; - if (alpha > 0.0f) { - glColor4f(0.3f, 0.4f, 0.6f, alpha); - - glPushMatrix(); - glTranslatef(_leapFingerRootBalls[i].position.x, _leapFingerRootBalls[i].position.y, _leapFingerRootBalls[i].position.z); - glutSolidSphere(_leapFingerRootBalls[i].radius, 20.0f, 20.0f); - glPopMatrix(); - } - } - // Draw the finger root cones for (size_t i = 0; i < getNumPalms(); ++i) { PalmData& palm = getPalms()[i]; From 17f1c82e6f63c5320c94f9ca00aa3ce77fee8861 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Fri, 2 Aug 2013 14:12:32 -0700 Subject: [PATCH 03/11] cleanup --- interface/src/avatar/Hand.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 85c52f31a8..eabd9e7ffc 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -85,7 +85,7 @@ void Hand::calculateGeometry() { } } - // generate finger rot balls.... + // generate finger root balls.... _leapFingerRootBalls.clear(); for (size_t i = 0; i < getNumPalms(); ++i) { PalmData& palm = getPalms()[i]; From 5df4fc95f1187195fdd51acbb7cdfd5409662f04 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 2 Aug 2013 14:21:21 -0700 Subject: [PATCH 04/11] Up the bitrate for full frame video to 4x. --- interface/src/Webcam.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/interface/src/Webcam.cpp b/interface/src/Webcam.cpp index 5050681fcf..3965bf887b 100644 --- a/interface/src/Webcam.cpp +++ b/interface/src/Webcam.cpp @@ -469,7 +469,8 @@ void FrameGrabber::grabFrame() { const int ENCODED_FACE_HEIGHT = 128; int encodedWidth; int encodedHeight; - int depthBitrateMultiplier = 1; + float colorBitrateMultiplier = 1.0f; + float depthBitrateMultiplier = 1.0f; Mat faceTransform; float aspectRatio; if (_videoSendMode == FULL_FRAME_VIDEO) { @@ -478,6 +479,7 @@ void FrameGrabber::grabFrame() { encodedWidth = color.cols; encodedHeight = color.rows; aspectRatio = FULL_FRAME_ASPECT; + colorBitrateMultiplier = 4.0f; } else { // if we don't have a search window (yet), try using the face cascade @@ -514,7 +516,7 @@ void FrameGrabber::grabFrame() { } encodedWidth = ENCODED_FACE_WIDTH; encodedHeight = ENCODED_FACE_HEIGHT; - depthBitrateMultiplier = 2; + depthBitrateMultiplier = 2.0f; // correct for 180 degree rotations if (faceRect.angle < -90.0f) { @@ -595,7 +597,7 @@ void FrameGrabber::grabFrame() { // initialize encoder context(s) vpx_codec_enc_cfg_t codecConfig; vpx_codec_enc_config_default(vpx_codec_vp8_cx(), &codecConfig, 0); - codecConfig.rc_target_bitrate = ENCODED_FACE_WIDTH * ENCODED_FACE_HEIGHT * + codecConfig.rc_target_bitrate = ENCODED_FACE_WIDTH * ENCODED_FACE_HEIGHT * colorBitrateMultiplier * codecConfig.rc_target_bitrate / codecConfig.g_w / codecConfig.g_h; codecConfig.g_w = encodedWidth; codecConfig.g_h = encodedHeight; From 574752c774dcf578bee0d9c03062ad022efc1c2b Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 2 Aug 2013 14:58:59 -0700 Subject: [PATCH 05/11] Use saturate_cast when converting from YV12 to RGB to prevent overflow errors. --- interface/src/avatar/Face.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/interface/src/avatar/Face.cpp b/interface/src/avatar/Face.cpp index 0541b3c21c..ffc88d4b5b 100644 --- a/interface/src/avatar/Face.cpp +++ b/interface/src/avatar/Face.cpp @@ -163,21 +163,21 @@ int Face::processVideoMessage(unsigned char* packetData, size_t dataBytes) { int ybr = ysrc[image->w + 1]; ysrc += 2; - tl[0] = ytl + redOffset; - tl[1] = ytl - greenOffset; - tl[2] = ytl + blueOffset; + tl[0] = saturate_cast(ytl + redOffset); + tl[1] = saturate_cast(ytl - greenOffset); + tl[2] = saturate_cast(ytl + blueOffset); - tr[0] = ytr + redOffset; - tr[1] = ytr - greenOffset; - tr[2] = ytr + blueOffset; + tr[0] = saturate_cast(ytr + redOffset); + tr[1] = saturate_cast(ytr - greenOffset); + tr[2] = saturate_cast(ytr + blueOffset); - bl[0] = ybl + redOffset; - bl[1] = ybl - greenOffset; - bl[2] = ybl + blueOffset; + bl[0] = saturate_cast(ybl + redOffset); + bl[1] = saturate_cast(ybl - greenOffset); + bl[2] = saturate_cast(ybl + blueOffset); - br[0] = ybr + redOffset; - br[1] = ybr - greenOffset; - br[2] = ybr + blueOffset; + br[0] = saturate_cast(ybr + redOffset); + br[1] = saturate_cast(ybr - greenOffset); + br[2] = saturate_cast(ybr + blueOffset); } yline += image->stride[0] * 2; vline += image->stride[1]; From 2e150b97deed95745f827a0d7089136443d5f449 Mon Sep 17 00:00:00 2001 From: atlante45 Date: Fri, 2 Aug 2013 15:24:09 -0700 Subject: [PATCH 06/11] Fixed shortcuts issues on mac --- interface/src/Application.cpp | 98 ++++++++++++++++++++++++++++++----- interface/src/Application.h | 2 + 2 files changed, 88 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0c7820d673..5ff2b1fe82 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -565,7 +565,7 @@ void Application::keyPressEvent(QKeyEvent* event) { } return; } - + bool meta = event->modifiers().testFlag(Qt::MetaModifier); bool shifted = event->modifiers().testFlag(Qt::ShiftModifier); switch (event->key()) { case Qt::Key_BracketLeft: @@ -639,7 +639,14 @@ void Application::keyPressEvent(QKeyEvent* event) { break; case Qt::Key_C: - _myAvatar.setDriveKeys(DOWN, 1); + if (shifted) { + _occlusionCulling->toggle(); + disableOcclusionCulling(_occlusionCulling->isChecked()); + } else if (meta) { + chooseVoxelPaintColor(); + } else { + _myAvatar.setDriveKeys(DOWN, 1); + } break; case Qt::Key_W: @@ -647,7 +654,11 @@ void Application::keyPressEvent(QKeyEvent* event) { break; case Qt::Key_S: - _myAvatar.setDriveKeys(BACK, 1); + if (shifted) { + doTreeStats(); + } else { + _myAvatar.setDriveKeys(BACK, 1); + } break; case Qt::Key_Space: @@ -656,11 +667,20 @@ void Application::keyPressEvent(QKeyEvent* event) { break; case Qt::Key_G: - goHome(); + if (shifted) { + _gravityUse->toggle(); + } else { + _eyedropperMode->toggle(); + updateVoxelModeActions(); + } break; case Qt::Key_A: - _myAvatar.setDriveKeys(ROT_LEFT, 1); + if (shifted) { + _renderAtmosphereOn->toggle(); + } else { + _myAvatar.setDriveKeys(ROT_LEFT, 1); + } break; case Qt::Key_D: @@ -750,6 +770,60 @@ void Application::keyPressEvent(QKeyEvent* event) { } resizeGL(_glWidget->width(), _glWidget->height()); break; + case Qt::Key_H: + _noise->toggle(); + setNoise(_noise->isChecked()); + break; + case Qt::Key_N: + _lookingInMirror->toggle(); + setRenderMirrored(_lookingInMirror->isChecked()); + break; + case Qt::Key_F: + if (shifted) { + _frustumOn->toggle(); + } else { + _fullScreenMode->toggle(); + setFullscreen(_fullScreenMode->isChecked()); + } + break; + case Qt::Key_V: + if (shifted) { + _renderVoxels->toggle(); + setRenderVoxels(_renderVoxels->isChecked()); + } else { + _addVoxelMode->toggle(); + updateVoxelModeActions(); + } + break; + case Qt::Key_P: + _manualFirstPerson->toggle(); + setRenderFirstPerson(_manualFirstPerson->isChecked()); + break; + case Qt::Key_R: + if (shifted) { + _frustumRenderModeAction->toggle(); + cycleFrustumRenderMode(); + } else { + _deleteVoxelMode->toggle(); + updateVoxelModeActions(); + } + break; + case Qt::Key_B: + _colorVoxelMode->toggle(); + updateVoxelModeActions(); + break; + case Qt::Key_O: + if (shifted) { + _viewFrustumFromOffset->toggle(); + setFrustumOffset(_viewFrustumFromOffset->isChecked()); + } else { + _selectVoxelMode->toggle(); + updateVoxelModeActions(); + } + break; + case Qt::Key_Slash: + _renderStatsOn->toggle(); + break; case Qt::Key_Backspace: case Qt::Key_Delete: if (_selectVoxelMode->isChecked()) { @@ -1710,7 +1784,7 @@ void Application::initMenu() { (_lookingInMirror = optionsMenu->addAction("Mirror", this, SLOT(setRenderMirrored(bool)), Qt::Key_H))->setCheckable(true); (_echoAudioMode = optionsMenu->addAction("Echo Audio"))->setCheckable(true); - optionsMenu->addAction("Noise", this, SLOT(setNoise(bool)), Qt::Key_N)->setCheckable(true); + (_noise = optionsMenu->addAction("Noise", this, SLOT(setNoise(bool)), Qt::Key_N))->setCheckable(true); (_gyroLook = optionsMenu->addAction("Smooth Gyro Look"))->setCheckable(true); _gyroLook->setChecked(true); (_showHeadMouse = optionsMenu->addAction("Head Mouse"))->setCheckable(true); @@ -1724,7 +1798,7 @@ void Application::initMenu() { _testPing->setChecked(true); (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true); optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true); - optionsMenu->addAction("Go Home", this, SLOT(goHome())); + optionsMenu->addAction("Go Home", this, SLOT(goHome()), Qt::CTRL | Qt::Key_G); QMenu* renderMenu = menuBar->addMenu("Render"); (_renderVoxels = renderMenu->addAction("Voxels", this, SLOT(setRenderVoxels(bool)), Qt::SHIFT | Qt::Key_V))->setCheckable(true); @@ -1792,8 +1866,8 @@ void Application::initMenu() { "Get Color Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_G))->setCheckable(true); _voxelModeActions->addAction(_eyedropperMode); - voxelMenu->addAction("Decrease Voxel Size", this, SLOT(decreaseVoxelSize()), QKeySequence::ZoomOut); - voxelMenu->addAction("Increase Voxel Size", this, SLOT(increaseVoxelSize()), QKeySequence::ZoomIn); + voxelMenu->addAction("Decrease Voxel Size", this, SLOT(decreaseVoxelSize()), QKeySequence::ZoomOut); + voxelMenu->addAction("Increase Voxel Size", this, SLOT(increaseVoxelSize()), QKeySequence::ZoomIn); voxelMenu->addAction("Reset Swatch Colors", this, SLOT(resetSwatchColors())); _voxelPaintColor = voxelMenu->addAction("Voxel Paint Color", this, @@ -1820,7 +1894,7 @@ void Application::initMenu() { (_viewFrustumFromOffset = frustumMenu->addAction( "Use Offset Camera", this, SLOT(setFrustumOffset(bool)), Qt::SHIFT | Qt::Key_O))->setCheckable(true); _frustumRenderModeAction = frustumMenu->addAction( - "Render Mode", this, SLOT(cycleFrustumRenderMode()), Qt::SHIFT | Qt::Key_R); + "Render Mode", this, SLOT(cycleFrustumRenderMode()), Qt::SHIFT | Qt::Key_R); updateFrustumRenderModeAction(); debugMenu->addAction("Run Timing Tests", this, SLOT(runTests())); @@ -1843,8 +1917,8 @@ void Application::initMenu() { debugMenu->addAction("Wants Monochrome", this, SLOT(setWantsMonochrome(bool)))->setCheckable(true); debugMenu->addAction("Use Lower Resolution While Moving", this, SLOT(setWantsLowResMoving(bool)))->setCheckable(true); debugMenu->addAction("Disable Delta Sending", this, SLOT(disableDeltaSending(bool)))->setCheckable(true); - debugMenu->addAction("Disable Occlusion Culling", this, SLOT(disableOcclusionCulling(bool)), - Qt::SHIFT | Qt::Key_C)->setCheckable(true); + (_occlusionCulling = debugMenu->addAction("Disable Occlusion Culling", this, SLOT(disableOcclusionCulling(bool)), + Qt::SHIFT | Qt::Key_C))->setCheckable(true); (_renderCoverageMap = debugMenu->addAction("Render Coverage Map"))->setCheckable(true); _renderCoverageMap->setShortcut(Qt::SHIFT | Qt::CTRL | Qt::Key_O); diff --git a/interface/src/Application.h b/interface/src/Application.h index 1c3d61ffc9..f9ce5e96b3 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -279,6 +279,8 @@ private: QAction* _fullScreenMode; // whether we are in full screen mode QAction* _frustumRenderModeAction; QAction* _settingsAutosave; // Whether settings are saved automatically + QAction* _noise; + QAction* _occlusionCulling; QAction* _renderCoverageMapV2; QAction* _renderCoverageMap; From b9a8d6080e9d681c3ee0298a66738797c92d8c71 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Fri, 2 Aug 2013 15:43:37 -0700 Subject: [PATCH 07/11] Render world box goes out to edge of world. --- interface/src/Application.cpp | 24 +++++++++++++++--------- interface/src/Util.cpp | 14 +++++++------- interface/src/Util.h | 2 +- interface/src/world.h | 1 - 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e5330252ac..0240aa50b4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2150,15 +2150,21 @@ void Application::update(float deltaTime) { // If we have clicked on a voxel, update it's color if (_isHoverVoxelSounding) { VoxelNode* hoveredNode = _voxels.getVoxelAt(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s); - float bright = _audio.getCollisionSoundMagnitude(); - nodeColor clickColor = { 255 * bright + _hoverVoxelOriginalColor[0] * (1.f - bright), - _hoverVoxelOriginalColor[1] * (1.f - bright), - _hoverVoxelOriginalColor[2] * (1.f - bright), 1 }; - hoveredNode->setColor(clickColor); - if (bright < 0.01f) { - hoveredNode->setColor(_hoverVoxelOriginalColor); + if (hoveredNode) { + float bright = _audio.getCollisionSoundMagnitude(); + nodeColor clickColor = { 255 * bright + _hoverVoxelOriginalColor[0] * (1.f - bright), + _hoverVoxelOriginalColor[1] * (1.f - bright), + _hoverVoxelOriginalColor[2] * (1.f - bright), 1 }; + hoveredNode->setColor(clickColor); + if (bright < 0.01f) { + hoveredNode->setColor(_hoverVoxelOriginalColor); + _isHoverVoxelSounding = false; + } + } else { + // Voxel is not found, clear all _isHoverVoxelSounding = false; - } + _isHoverVoxel = false; + } } else { // Check for a new hover voxel glm::vec4 oldVoxel(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s); @@ -2839,7 +2845,7 @@ void Application::displaySide(Camera& whichCamera) { } // Render the world box - if (!_lookingInMirror->isChecked() && _renderStatsOn->isChecked()) { render_world_box(); } + if (!_lookingInMirror->isChecked() && _renderStatsOn->isChecked()) { renderWorldBox(); } // brad's frustum for debugging if (_frustumOn->isChecked()) renderViewFrustum(_viewFrustum); diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 5d77c124f4..f39dc91267 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -223,7 +223,7 @@ void noiseTest(int w, int h) { glEnd(); } -void render_world_box() { +void renderWorldBox() { // Show edge of world glDisable(GL_LIGHTING); glColor4f(1.0, 1.0, 1.0, 1.0); @@ -231,28 +231,28 @@ void render_world_box() { glBegin(GL_LINES); glColor3f(1, 0, 0); glVertex3f(0, 0, 0); - glVertex3f(WORLD_SIZE, 0, 0); + glVertex3f(TREE_SCALE, 0, 0); glColor3f(0, 1, 0); glVertex3f(0, 0, 0); - glVertex3f(0, WORLD_SIZE, 0); + glVertex3f(0, TREE_SCALE, 0); glColor3f(0, 0, 1); glVertex3f(0, 0, 0); - glVertex3f(0, 0, WORLD_SIZE); + glVertex3f(0, 0, TREE_SCALE); glEnd(); // Draw little marker dots along the axis glEnable(GL_LIGHTING); glPushMatrix(); - glTranslatef(WORLD_SIZE, 0, 0); + glTranslatef(TREE_SCALE, 0, 0); glColor3f(1, 0, 0); glutSolidSphere(0.125, 10, 10); glPopMatrix(); glPushMatrix(); - glTranslatef(0, WORLD_SIZE, 0); + glTranslatef(0, TREE_SCALE, 0); glColor3f(0, 1, 0); glutSolidSphere(0.125, 10, 10); glPopMatrix(); glPushMatrix(); - glTranslatef(0, 0, WORLD_SIZE); + glTranslatef(0, 0, TREE_SCALE); glColor3f(0, 0, 1); glutSolidSphere(0.125, 10, 10); glPopMatrix(); diff --git a/interface/src/Util.h b/interface/src/Util.h index 67ffebf4b3..6fc797e3e3 100644 --- a/interface/src/Util.h +++ b/interface/src/Util.h @@ -33,7 +33,7 @@ float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float float randFloat(); const glm::vec3 randVector(); -void render_world_box(); +void renderWorldBox(); int widthText(float scale, int mono, char const* string); float widthChar(float scale, int mono, char ch); void drawtext(int x, int y, float scale, float rotate, float thick, int mono, diff --git a/interface/src/world.h b/interface/src/world.h index 9a1b506ae2..f53db4ff49 100644 --- a/interface/src/world.h +++ b/interface/src/world.h @@ -12,7 +12,6 @@ #define __interface__world__ -const float WORLD_SIZE = 10.0; #define PIf 3.14159265f const float GRAVITY_EARTH = 9.80665f; From 8aa8b5dbfe128463a6ccea2ffe6dc42439367bb7 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Fri, 2 Aug 2013 16:03:34 -0700 Subject: [PATCH 08/11] Marker lines all the way out to 128Meters --- interface/src/Application.cpp | 2 +- interface/src/Util.cpp | 33 ++++++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0240aa50b4..972c935f64 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -857,7 +857,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { const bool MAKE_SOUND_ON_VOXEL_HOVER = false; const bool MAKE_SOUND_ON_VOXEL_CLICK = true; -const float HOVER_VOXEL_FREQUENCY = 14080.f; +const float HOVER_VOXEL_FREQUENCY = 7040.f; const float HOVER_VOXEL_DECAY = 0.999f; void Application::mousePressEvent(QMouseEvent* event) { diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index f39dc91267..61b9b2d7ca 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -224,38 +224,53 @@ void noiseTest(int w, int h) { } void renderWorldBox() { - // Show edge of world + // Show edge of world + float red[] = {1, 0, 0}; + float green[] = {0, 1, 0}; + float blue[] = {0, 0, 1}; + float gray[] = {0.5, 0.5, 0.5}; + glDisable(GL_LIGHTING); - glColor4f(1.0, 1.0, 1.0, 1.0); glLineWidth(1.0); glBegin(GL_LINES); - glColor3f(1, 0, 0); + glColor3fv(red); glVertex3f(0, 0, 0); glVertex3f(TREE_SCALE, 0, 0); - glColor3f(0, 1, 0); + glColor3fv(green); glVertex3f(0, 0, 0); glVertex3f(0, TREE_SCALE, 0); - glColor3f(0, 0, 1); + glColor3fv(blue); glVertex3f(0, 0, 0); glVertex3f(0, 0, TREE_SCALE); + glColor3fv(gray); + glVertex3f(0, 0, TREE_SCALE); + glVertex3f(TREE_SCALE, 0, TREE_SCALE); + glVertex3f(TREE_SCALE, 0, TREE_SCALE); + glVertex3f(TREE_SCALE, 0, 0); glEnd(); - // Draw little marker dots along the axis + // Draw marker dots at very end glEnable(GL_LIGHTING); glPushMatrix(); glTranslatef(TREE_SCALE, 0, 0); - glColor3f(1, 0, 0); + glColor3fv(red); glutSolidSphere(0.125, 10, 10); glPopMatrix(); glPushMatrix(); glTranslatef(0, TREE_SCALE, 0); - glColor3f(0, 1, 0); + glColor3fv(green); glutSolidSphere(0.125, 10, 10); glPopMatrix(); glPushMatrix(); glTranslatef(0, 0, TREE_SCALE); - glColor3f(0, 0, 1); + glColor3fv(blue); glutSolidSphere(0.125, 10, 10); glPopMatrix(); + glPushMatrix(); + glColor3fv(gray); + glTranslatef(TREE_SCALE, 0, TREE_SCALE); + glutSolidSphere(0.125, 10, 10); + glPopMatrix(); + } double diffclock(timeval *clock1,timeval *clock2) From 95f15fceb5205e05c4a275d765bd1253286a5be4 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Fri, 2 Aug 2013 16:07:33 -0700 Subject: [PATCH 09/11] added avatar nose --- interface/src/avatar/Head.cpp | 81 ++++++++++++++++++++++++++++------- interface/src/avatar/Head.h | 10 +++++ 2 files changed, 76 insertions(+), 15 deletions(-) diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index 76cf13a44d..6f6afb550c 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -17,7 +17,7 @@ #include "renderer/ProgramObject.h" using namespace std; - + const int MOHAWK_TRIANGLES = 50; const bool USING_PHYSICAL_MOHAWK = true; const float EYE_RIGHT_OFFSET = 0.27f; @@ -36,6 +36,11 @@ const float HAIR_GRAVITY_FORCE = 0.05f; const float HAIR_DRAG = 10.0f; const float HAIR_LENGTH = 0.09f; const float HAIR_THICKNESS = 0.03f; +const float NOSE_LENGTH = 0.025; +const float NOSE_WIDTH = 0.03; +const float NOSE_HEIGHT = 0.034; +const float NOSE_UP_OFFSET = -0.07; +const float NOSE_UPTURN = 0.005; const float IRIS_RADIUS = 0.007; const float IRIS_PROTRUSION = 0.0145f; const char IRIS_TEXTURE_FILENAME[] = "resources/images/iris.png"; @@ -100,7 +105,7 @@ void Head::init() { _irisProgram->setUniformValue("texture", 0); _eyePositionLocation = _irisProgram->uniformLocation("eyePosition"); - + QImage image = QImage(IRIS_TEXTURE_FILENAME).convertToFormat(QImage::Format_ARGB32); glGenTextures(1, &_irisTextureID); @@ -262,31 +267,40 @@ void Head::calculateGeometry() { glm::vec3 up = orientation * IDENTITY_UP; glm::vec3 front = orientation * IDENTITY_FRONT; + float scale = _scale * BODY_BALL_RADIUS_HEAD_BASE; + //calculate the eye positions _leftEyePosition = _position - - right * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_RIGHT_OFFSET - + up * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_UP_OFFSET - + front * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_FRONT_OFFSET; + - right * scale * EYE_RIGHT_OFFSET + + up * scale * EYE_UP_OFFSET + + front * scale * EYE_FRONT_OFFSET; _rightEyePosition = _position - + right * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_RIGHT_OFFSET - + up * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_UP_OFFSET - + front * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_FRONT_OFFSET; + + right * scale * EYE_RIGHT_OFFSET + + up * scale * EYE_UP_OFFSET + + front * scale * EYE_FRONT_OFFSET; - _eyeLevelPosition = _rightEyePosition - right * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_RIGHT_OFFSET; + _eyeLevelPosition = _rightEyePosition - right * scale * EYE_RIGHT_OFFSET; //calculate the eyebrow positions _leftEyeBrowPosition = _leftEyePosition; _rightEyeBrowPosition = _rightEyePosition; //calculate the ear positions - _leftEarPosition = _position - right * _scale * BODY_BALL_RADIUS_HEAD_BASE * EAR_RIGHT_OFFSET; - _rightEarPosition = _position + right * _scale * BODY_BALL_RADIUS_HEAD_BASE * EAR_RIGHT_OFFSET; + _leftEarPosition = _position - right * scale * EAR_RIGHT_OFFSET; + _rightEarPosition = _position + right * scale * EAR_RIGHT_OFFSET; //calculate the mouth position - _mouthPosition = _position + up * _scale * BODY_BALL_RADIUS_HEAD_BASE * MOUTH_UP_OFFSET - + front * _scale * BODY_BALL_RADIUS_HEAD_BASE; -} + _mouthPosition = _position + up * scale * MOUTH_UP_OFFSET + front * scale; + // calculate nose geometry + glm::vec3 noseBase = _position + front * 0.95f * scale + up * NOSE_UP_OFFSET * scale; + + _nose.top = noseBase + up * _scale * NOSE_HEIGHT; + _nose.left = noseBase - right * _scale * NOSE_WIDTH * ONE_HALF; + _nose.right = noseBase + right * _scale * NOSE_WIDTH * ONE_HALF; + _nose.front = noseBase + front * _scale * NOSE_LENGTH + + up * _scale * NOSE_UPTURN; +} void Head::render(float alpha) { @@ -302,7 +316,8 @@ void Head::render(float alpha) { renderHeadSphere(); renderEyeBalls(); renderEars(); - renderMouth(); + renderMouth(); + renderNose(); renderEyeBrows(); } @@ -441,6 +456,42 @@ void Head::renderEars() { glPopMatrix(); } + +void Head::renderNose() { + + glm::vec3 bridgeVector = _nose.front - _nose.top; + glm::vec3 leftvector = _nose.front - _nose.left; + glm::vec3 rightvector = _nose.front - _nose.right; + + glm::vec3 leftNormal (glm::normalize(glm::cross(leftvector, bridgeVector))); + glm::vec3 rightNormal (glm::normalize(glm::cross(bridgeVector, rightvector ))); + glm::vec3 bottomNormal(glm::normalize(glm::cross(rightvector, leftvector ))); + + glColor4f(_skinColor.x, _skinColor.y, _skinColor.z, _renderAlpha); + + glBegin(GL_TRIANGLES); + + glNormal3f(leftNormal.x, leftNormal.y, leftNormal.z); + glVertex3f(_nose.top.x, _nose.top.y, _nose.top.z ); + glVertex3f(_nose.left.x, _nose.left.y, _nose.left.z ); + glVertex3f(_nose.front.x, _nose.front.y, _nose.front.z ); + + glNormal3f(rightNormal.x, rightNormal.y, rightNormal.z); + glVertex3f(_nose.top.x, _nose.top.y, _nose.top.z ); + glVertex3f(_nose.right.x, _nose.right.y, _nose.right.z ); + glVertex3f(_nose.front.x, _nose.front.y, _nose.front.z ); + + glNormal3f(bottomNormal.x, bottomNormal.y, bottomNormal.z); + glVertex3f(_nose.left.x, _nose.left.y, _nose.left.z ); + glVertex3f(_nose.right.x, _nose.right.y, _nose.right.z ); + glVertex3f(_nose.front.x, _nose.front.y, _nose.front.z ); + + glEnd(); +} + + + + void Head::renderMouth() { float s = sqrt(_averageLoudness); diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index 4c1429e1d6..58414fd8be 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -92,6 +92,14 @@ private: glm::vec3 endVelocity; }; + struct Nose + { + glm::vec3 top; + glm::vec3 left; + glm::vec3 right; + glm::vec3 front; + }; + float _renderAlpha; bool _returnHeadToCenter; glm::vec3 _skinColor; @@ -105,6 +113,7 @@ private: glm::vec3 _leftEarPosition; glm::vec3 _rightEarPosition; glm::vec3 _mouthPosition; + Nose _nose; float _scale; float _browAudioLift; glm::vec3 _gravity; @@ -141,6 +150,7 @@ private: void renderEyeBalls(); void renderEyeBrows(); void renderEars(); + void renderNose(); void renderMouth(); void renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition); void calculateGeometry(); From 1b4cdc003db9f634e448f7499e0c5c8ec15f5708 Mon Sep 17 00:00:00 2001 From: atlante45 Date: Fri, 2 Aug 2013 16:36:53 -0700 Subject: [PATCH 10/11] Fix shortcuts : done --- interface/src/Application.cpp | 69 ++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index bb1c0527cd..884624bbb4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -571,6 +571,7 @@ void Application::keyPressEvent(QKeyEvent* event) { _myAvatar.getHand().setRaveGloveEffectsMode((QKeyEvent*)event); } + bool alt = event->modifiers().testFlag(Qt::AltModifier); bool meta = event->modifiers().testFlag(Qt::MetaModifier); bool shifted = event->modifiers().testFlag(Qt::ShiftModifier); switch (event->key()) { @@ -646,8 +647,7 @@ void Application::keyPressEvent(QKeyEvent* event) { case Qt::Key_C: if (shifted) { - _occlusionCulling->toggle(); - disableOcclusionCulling(_occlusionCulling->isChecked()); + _occlusionCulling->trigger(); } else if (meta) { chooseVoxelPaintColor(); } else { @@ -674,16 +674,15 @@ void Application::keyPressEvent(QKeyEvent* event) { case Qt::Key_G: if (shifted) { - _gravityUse->toggle(); + _gravityUse->trigger(); } else { - _eyedropperMode->toggle(); - updateVoxelModeActions(); + _eyedropperMode->trigger(); } break; case Qt::Key_A: if (shifted) { - _renderAtmosphereOn->toggle(); + _renderAtmosphereOn->trigger(); } else { _myAvatar.setDriveKeys(ROT_LEFT, 1); } @@ -776,59 +775,48 @@ void Application::keyPressEvent(QKeyEvent* event) { } resizeGL(_glWidget->width(), _glWidget->height()); break; - case Qt::Key_H: - _noise->toggle(); - setNoise(_noise->isChecked()); - break; case Qt::Key_N: - _lookingInMirror->toggle(); - setRenderMirrored(_lookingInMirror->isChecked()); + _noise->trigger(); + break; + case Qt::Key_H: + _lookingInMirror->trigger(); break; case Qt::Key_F: if (shifted) { - _frustumOn->toggle(); + _frustumOn->trigger(); } else { - _fullScreenMode->toggle(); - setFullscreen(_fullScreenMode->isChecked()); + _fullScreenMode->trigger(); } break; case Qt::Key_V: if (shifted) { - _renderVoxels->toggle(); - setRenderVoxels(_renderVoxels->isChecked()); + _renderVoxels->trigger(); } else { - _addVoxelMode->toggle(); - updateVoxelModeActions(); + _addVoxelMode->trigger(); } break; case Qt::Key_P: - _manualFirstPerson->toggle(); - setRenderFirstPerson(_manualFirstPerson->isChecked()); + _manualFirstPerson->trigger(); break; case Qt::Key_R: if (shifted) { - _frustumRenderModeAction->toggle(); - cycleFrustumRenderMode(); + _frustumRenderModeAction->trigger(); } else { - _deleteVoxelMode->toggle(); - updateVoxelModeActions(); + _deleteVoxelMode->trigger(); } break; case Qt::Key_B: - _colorVoxelMode->toggle(); - updateVoxelModeActions(); + _colorVoxelMode->trigger(); break; case Qt::Key_O: if (shifted) { - _viewFrustumFromOffset->toggle(); - setFrustumOffset(_viewFrustumFromOffset->isChecked()); + _viewFrustumFromOffset->trigger(); } else { - _selectVoxelMode->toggle(); - updateVoxelModeActions(); + _selectVoxelMode->trigger(); } break; case Qt::Key_Slash: - _renderStatsOn->toggle(); + _renderStatsOn->trigger(); break; case Qt::Key_Backspace: case Qt::Key_Delete: @@ -836,6 +824,17 @@ void Application::keyPressEvent(QKeyEvent* event) { deleteVoxelUnderCursor(); } break; + case Qt::Key_Plus: + if (alt) { + increaseAvatarSize(); + } + break; + case Qt::Key_Minus: + if (alt) { + decreaseAvatarSize(); + } + break; + case Qt::Key_1: case Qt::Key_2: case Qt::Key_3: @@ -1866,10 +1865,12 @@ void Application::initMenu() { _window->setMenuBar(menuBar); QMenu* fileMenu = menuBar->addMenu("File"); - fileMenu->addAction("Quit", this, SLOT(quit()), Qt::CTRL | Qt::Key_Q); + QAction* quitAction = fileMenu->addAction("Quit", this, SLOT(quit()), Qt::CTRL | Qt::Key_Q); + quitAction->setMenuRole(QAction::QuitRole); QMenu* editMenu = menuBar->addMenu("Edit"); - editMenu->addAction("Preferences...", this, SLOT(editPreferences())); + QAction* preferencesAction = editMenu->addAction("Preferences...", this, SLOT(editPreferences()), Qt::CTRL | Qt::Key_Comma); + preferencesAction->setMenuRole(QAction::PreferencesRole); QMenu* pairMenu = menuBar->addMenu("Pair"); pairMenu->addAction("Pair", this, SLOT(pair())); From 936209fd313a87fa9ef5601d8cfbce47487d853a Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Fri, 2 Aug 2013 16:37:49 -0700 Subject: [PATCH 11/11] When no hovered voxel, lookAt vectors point to distant horizon --- interface/src/Application.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2f3c6ac74c..f8aaa34aa8 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2162,7 +2162,8 @@ void Application::update(float deltaTime) { _myAvatar.getHead().setLookAtPosition(lookAtSpot); } else { // Just look in direction of the mouse ray - glm::vec3 myLookAtFromMouse(mouseRayOrigin + mouseRayDirection); + const float FAR_AWAY_STARE = TREE_SCALE; + glm::vec3 myLookAtFromMouse(mouseRayOrigin + mouseRayDirection * FAR_AWAY_STARE); _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); } @@ -2855,8 +2856,9 @@ void Application::displaySide(Camera& whichCamera) { _myAvatar.getHead().setLookAtPosition(_myCamera.getPosition()); } _myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked()); + _myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked()); - if (_renderLookatIndicatorOn->isChecked() && _isLookingAtOtherAvatar) { + if (_renderLookatIndicatorOn->isChecked()) { renderLookatIndicator(_lookatOtherPosition, whichCamera); } }