Merge branch 'master' of https://github.com/worklist/hifi into kinected

This commit is contained in:
Andrzej Kapolka 2013-07-10 14:08:03 -07:00
commit 0aa1b396db
15 changed files with 739 additions and 26 deletions

View file

@ -66,7 +66,7 @@ if (APPLE)
endif (APPLE)
find_package(Qt4 REQUIRED QtCore QtGui QtNetwork QtOpenGL QtWebKit)
find_package(Qt4 REQUIRED QtCore QtGui QtNetwork QtOpenGL QtWebKit QtSvg)
include(${QT_USE_FILE})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${QT_QTGUI_INCLUDE_DIR}")

View file

@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="124px" height="400px" viewBox="-0.5 0.5 124 400" enable-background="new -0.5 0.5 124 400" xml:space="preserve">
<g>
<g>
<rect x="-0.5" y="120.382" width="62" height="40"/>
</g>
<g>
<g>
<path fill="#999999" d="M13.77,149.864c0.296,0.296,0.665,0.102,0.665,0.102s0.527-0.615,1.101-0.328
c0.811,0.405,1.315-0.113,1.315-0.113l10.611-10.611l-1.419-1.419l-1.161-1.161l-10.61,10.61c0,0-0.575,0.449-0.169,1.261
c0.287,0.573-0.384,1.045-0.384,1.045S13.474,149.569,13.77,149.864"/>
</g>
<g>
<path fill="#CCCCCC" d="M25.913,135.042l2.173-2.173c0,0,1.898-1.905,3.256-0.547c0.68,0.68,1.083,1.627-0.546,3.257
c-1.549,1.548-2.173,2.172-2.173,2.172L25.913,135.042z"/>
</g>
<g>
<rect x="22.984" y="135.651" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 -52.0828 253.0143)" fill="#CCCCCC" width="6.751" height="3.285"/>
</g>
</g>
<g>
<path fill="#FFFFFF" d="M46.482,138.915h3.697v4.617c-1.004,0.344-2.107,0.516-3.311,0.516c-1.32,0-2.341-0.383-3.062-1.148
s-1.081-1.857-1.081-3.275c0-1.383,0.395-2.459,1.184-3.229s1.895-1.154,3.316-1.154c0.539,0,1.048,0.051,1.526,0.152
s0.896,0.23,1.251,0.387l-0.732,1.816c-0.617-0.305-1.295-0.457-2.033-0.457c-0.676,0-1.198,0.22-1.567,0.659
s-0.554,1.067-0.554,1.884c0,0.801,0.167,1.411,0.501,1.831s0.815,0.63,1.444,0.63c0.344,0,0.66-0.033,0.949-0.1v-1.342h-1.529
L46.482,138.915L46.482,138.915z"/>
</g>
</g>
<g>
<g>
<rect x="-0.5" y="80.5" width="62" height="40"/>
</g>
<g>
<path fill="#FFFFFF" d="M43.84,96.434h2.988c1.164,0,2.028,0.173,2.593,0.519s0.847,0.884,0.847,1.614
c0,0.48-0.123,0.891-0.369,1.23s-0.57,0.559-0.973,0.656v0.059c0.531,0.141,0.916,0.375,1.154,0.703s0.357,0.754,0.357,1.277
c0,0.777-0.292,1.39-0.876,1.837S48.182,105,47.174,105H43.84V96.434z M46.154,99.721h0.697c0.332,0,0.589-0.068,0.771-0.205
s0.272-0.34,0.272-0.609c0-0.48-0.363-0.721-1.09-0.721h-0.65C46.154,98.186,46.154,99.721,46.154,99.721z M46.154,101.414v1.799
h0.814c0.723,0,1.084-0.305,1.084-0.914c0-0.285-0.097-0.504-0.29-0.656s-0.474-0.229-0.841-0.229
C46.921,101.414,46.154,101.414,46.154,101.414z"/>
</g>
<g>
<path fill="#FFFFFF" d="M18,106.06c-3,1-3,3-7,3c2,1,8,4,9,0C20.47,107.181,18,106.06,18,106.06z"/>
<path fill="#CCCCCC" d="M19,105.06l2,2c0,0,3.952-4.712,7-9c3.048-4.287,7.32-10.785,3-7C28.399,93.338,22.048,100.772,19,105.06z
"/>
</g>
</g>
<g>
<g>
<rect x="-0.5" y="40.5" width="62" height="40"/>
</g>
<g>
<g>
<g>
<polygon fill="#A5A5A5" points="26,58.63 39,53.893 39,67.213 26,72.394 "/>
</g>
<g>
<g>
<path fill="#333333" d="M38,54.5v12.59l-12,5.032V58.757l12.204-4.468 M39,53.63l-13,4.873v14.162l13-5.33V53.63L39,53.63z"/>
</g>
</g>
</g>
<g>
<g>
<polygon fill="#BFBFBF" points="13,67.213 13,53.893 25,58.63 25,72.394 "/>
</g>
<g>
<path fill="#BFBFBF" d="M12.887,54.289L25,58.757v13.365L13,67.09V54.5 M13,53.63v13.705l13,5.33V58.503L13,53.63L13,53.63z"/>
</g>
</g>
<g>
<g>
<polygon fill="#FFFFFF" points="13.173,53.63 25.746,48.952 38.318,53.63 25.746,58.309 "/>
</g>
<g>
<path fill="#333333" d="M25.746,49.146l12.049,4.483l-12.049,4.483L13.697,53.63L25.746,49.146 M25.746,48.758L12.65,53.63
l13.096,4.873l13.096-4.873L25.746,48.758L25.746,48.758z"/>
</g>
</g>
</g>
<g>
<path fill="#FFFFFF" d="M46.119,62.383V65.5h-2.314v-8.566h2.807c2.328,0,3.492,0.844,3.492,2.531c0,0.992-0.484,1.76-1.453,2.303
l2.495,3.732h-2.625l-1.816-3.117H46.119z M46.119,60.643h0.434c0.809,0,1.213-0.357,1.213-1.072c0-0.59-0.396-0.885-1.189-0.885
H46.12L46.119,60.643L46.119,60.643z"/>
</g>
<g>
<polygon fill="#333333" points="7,59.5 9,59.5 10,59.5 15,59.5 16,59.5 18,59.5 18,64.5 16,64.5 15,64.5 10,64.5 9,64.5 7,64.5
"/>
<g>
<g>
<rect x="8" y="60.5" fill="#FFFFFF" width="9" height="3"/>
</g>
</g>
</g>
</g>
<g>
<rect x="-0.5" y="0.5" width="62" height="40"/>
</g>
<g>
<g>
<g>
<polygon fill="#A5A5A5" points="26,18.63 39,13.893 39,27.213 26,32.394 "/>
</g>
<g>
<g>
<path fill="#333333" d="M38,14.5v12.59l-12,5.032V18.757l12.204-4.468 M39,13.63l-13,4.873v14.162l13-5.33V13.63L39,13.63z"/>
</g>
</g>
</g>
<g>
<g>
<polygon fill="#BFBFBF" points="13,27.213 13,13.893 25,18.63 25,32.394 "/>
</g>
<g>
<path fill="#BFBFBF" d="M12.887,14.289L25,18.757v13.365L13,27.09V14.5 M13,13.63v13.705l13,5.33V18.503L13,13.63L13,13.63z"/>
</g>
</g>
<g>
<g>
<polygon fill="#FFFFFF" points="13.173,13.63 25.746,8.952 38.318,13.63 25.746,18.309 "/>
</g>
<g>
<path fill="#333333" d="M25.746,9.146l12.049,4.483l-12.049,4.483L13.697,13.63L25.746,9.146 M25.746,8.758L12.65,13.63
l13.096,4.873l13.096-4.873L25.746,8.758L25.746,8.758z"/>
</g>
</g>
</g>
<g>
<path fill="#FFFFFF" d="M48.41,16.934H51L48.193,25.5h-2.725l-2.795-8.566h2.602l1.166,4.342c0.242,0.965,0.375,1.637,0.398,2.016
c0.027-0.273,0.082-0.615,0.164-1.025s0.154-0.732,0.217-0.967L48.41,16.934z"/>
</g>
<g>
<polygon fill="#333333" points="7,19.5 10,19.5 10,16.5 15,16.5 15,19.5 18,19.5 18,24.5 15,24.5 15,27.5 10,27.5 10,24.5 7,24.5
"/>
<g>
<g>
<rect x="11" y="17.5" fill="#FFFFFF" width="3" height="9"/>
</g>
<g>
<rect x="8" y="20.5" fill="#FFFFFF" width="9" height="3"/>
</g>
</g>
</g>
<g>
<g>
<rect x="-0.5" y="160.5" width="62" height="40"/>
</g>
<g>
<path fill="#FFFFFF" d="M50.379,179.205c0,1.441-0.354,2.537-1.061,3.287s-1.742,1.125-3.105,1.125
c-1.344,0-2.374-0.377-3.091-1.131s-1.075-1.852-1.075-3.293c0-1.426,0.356-2.515,1.069-3.267s1.749-1.128,3.108-1.128
c1.363,0,2.396,0.373,3.1,1.119S50.379,177.76,50.379,179.205z M44.484,179.205c0,1.656,0.576,2.484,1.729,2.484
c0.586,0,1.021-0.201,1.304-0.604s0.425-1.029,0.425-1.881c0-0.855-0.144-1.487-0.431-1.896s-0.716-0.612-1.286-0.612
C45.064,176.697,44.484,177.533,44.484,179.205z"/>
</g>
<g>
<g>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" points="19.944,187.389 19.944,188.389 19.031,187.981 "/>
<line fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="1.9973,1.9973" x1="17.208" y1="187.166" x2="10.825" y2="184.315"/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" points="9.913,183.908 9,183.5 9,182.5 "/>
<line fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="2,2" x1="8.5" y1="180.5" x2="8.5" y2="173.5"/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" points="9,172.5 9,171.5 9.927,171.876 "/>
<line fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="1.9625,1.9625" x1="11.745" y1="172.615" x2="18.109" y2="175.199"/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" points="19.018,175.568 19.944,175.944 19.944,176.944 "/>
<line fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="2,2" x1="19.5" y1="179.5" x2="19.5" y2="186.5"/>
</g>
</g>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="2,2" points="19.944,175.944 30,171.5 20,168.5
9,171.5 "/>
<polyline fill="none" stroke="#CCCCCC" stroke-miterlimit="10" stroke-dasharray="2,2" points="20.333,188.611 29.5,183.5
29.5,171.5 "/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.5 KiB

View file

@ -8,6 +8,7 @@
#include <sstream>
#include <stdlib.h>
#include <cmath>
#ifdef _WIN32
#include "Syssocket.h"
@ -63,6 +64,7 @@
#include "Util.h"
#include "renderer/ProgramObject.h"
#include "ui/TextRenderer.h"
#include "Swatch.h"
#include "fvupdater.h"
using namespace std;
@ -198,7 +200,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
_packetCount(0),
_packetsPerSecond(0),
_bytesPerSecond(0),
_bytesCount(0)
_bytesCount(0),
_swatch(NULL)
{
_applicationStartupTime = startup_time;
_window->setWindowTitle("Interface");
@ -274,7 +277,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
FvUpdater::sharedUpdater()->SetFeedURL("https://s3-us-west-1.amazonaws.com/highfidelity/appcast.xml");
FvUpdater::sharedUpdater()->CheckForUpdatesSilent();
#endif
initMenu();
QRect available = desktop()->availableGeometry();
@ -727,7 +730,16 @@ void Application::keyPressEvent(QKeyEvent* event) {
deleteVoxelUnderCursor();
}
break;
case Qt::Key_1:
case Qt::Key_2:
case Qt::Key_3:
case Qt::Key_4:
case Qt::Key_5:
case Qt::Key_6:
case Qt::Key_7:
case Qt::Key_8:
_swatch.handleEvent(event->key(), _eyedropperMode->isChecked());
break;
default:
event->ignore();
break;
@ -1252,7 +1264,11 @@ void Application::decreaseVoxelSize() {
void Application::increaseVoxelSize() {
_mouseVoxelScale *= 2;
}
void Application::resetSwatchColors() {
_swatch.reset();
}
static QIcon createSwatchIcon(const QColor& color) {
QPixmap map(16, 16);
map.fill(color);
@ -1496,7 +1512,7 @@ void Application::initMenu() {
QMenu* renderMenu = menuBar->addMenu("Render");
(_renderVoxels = renderMenu->addAction("Voxels"))->setCheckable(true);
_renderVoxels->setChecked(true);
_renderVoxels->setShortcut(Qt::Key_V);
_renderVoxels->setShortcut(Qt::SHIFT | Qt::Key_V);
(_renderVoxelTextures = renderMenu->addAction("Voxel Textures"))->setCheckable(true);
(_renderStarsOn = renderMenu->addAction("Stars"))->setCheckable(true);
_renderStarsOn->setChecked(true);
@ -1538,26 +1554,29 @@ void Application::initMenu() {
_voxelModeActions->setExclusive(false); // exclusivity implies one is always checked
(_addVoxelMode = voxelMenu->addAction(
"Add Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::CTRL | Qt::Key_A))->setCheckable(true);
"Add Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_V))->setCheckable(true);
_voxelModeActions->addAction(_addVoxelMode);
(_deleteVoxelMode = voxelMenu->addAction(
"Delete Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::CTRL | Qt::Key_D))->setCheckable(true);
"Delete Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_R))->setCheckable(true);
_voxelModeActions->addAction(_deleteVoxelMode);
(_colorVoxelMode = voxelMenu->addAction(
"Color Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::CTRL | Qt::Key_B))->setCheckable(true);
"Color Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_B))->setCheckable(true);
_voxelModeActions->addAction(_colorVoxelMode);
(_selectVoxelMode = voxelMenu->addAction(
"Select Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::CTRL | Qt::Key_S))->setCheckable(true);
"Select Voxel Mode", this, SLOT(updateVoxelModeActions()), Qt::Key_O))->setCheckable(true);
_voxelModeActions->addAction(_selectVoxelMode);
(_eyedropperMode = voxelMenu->addAction(
"Get Color Mode", this, SLOT(updateVoxelModeActions()), Qt::CTRL | Qt::Key_G))->setCheckable(true);
"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("Reset Swatch Colors", this, SLOT(resetSwatchColors()));
_voxelPaintColor = voxelMenu->addAction("Voxel Paint Color", this,
SLOT(chooseVoxelPaintColor()), Qt::META | Qt::Key_C);
_swatch.setAction(_voxelPaintColor);
QColor paintColor(128, 128, 128);
_voxelPaintColor->setData(paintColor);
_voxelPaintColor->setIcon(createSwatchIcon(paintColor));
@ -1688,6 +1707,14 @@ void Application::init() {
sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL());
_palette.init(_glWidget->width(), _glWidget->height());
_palette.addAction(_addVoxelMode, 0, 0);
_palette.addAction(_deleteVoxelMode, 0, 1);
_palette.addTool(&_swatch);
_palette.addAction(_colorVoxelMode, 0, 2);
_palette.addAction(_eyedropperMode, 0, 3);
_palette.addAction(_selectVoxelMode, 0, 4);
}
const float MAX_AVATAR_EDIT_VELOCITY = 1.0f;
@ -1920,7 +1947,7 @@ void Application::update(float deltaTime) {
if (_bandwidthDialog) {
_bandwidthDialog->update();
}
// Update audio stats for procedural sounds
#ifndef _WIN32
_audio.setLastAcceleration(_myAvatar.getThrust());
@ -2434,7 +2461,52 @@ void Application::displayOverlay() {
// render the webcam input frame
_webcam.renderPreview(_glWidget->width(), _glWidget->height());
_palette.render(_glWidget->width(), _glWidget->height());
if (_eyedropperMode->isChecked() && _voxelPaintColor->data().value<QColor>() != _swatch.getColor()) {
QColor color = _voxelPaintColor->data().value<QColor>();
TextRenderer textRenderer(SANS_FONT_FAMILY, 11, 50);
const char line1[] = "Assign this color to a swatch";
const char line2[] = "by choosing a key from 1 to 8.";
int left = (_glWidget->width() - POPUP_WIDTH - 2 * POPUP_MARGIN) / 2;
int top = _glWidget->height() / 40;
glBegin(GL_POLYGON);
glColor3f(0.0f, 0.0f, 0.0f);
for (double a = M_PI; a < 1.5f * M_PI; a += POPUP_STEP) {
glVertex2f(left + POPUP_MARGIN * cos(a) , top + POPUP_MARGIN * sin(a));
}
for (double a = 1.5f * M_PI; a < 2.0f * M_PI; a += POPUP_STEP) {
glVertex2f(left + POPUP_WIDTH + POPUP_MARGIN * cos(a), top + POPUP_MARGIN * sin(a));
}
for (double a = 0.0f; a < 0.5f * M_PI; a += POPUP_STEP) {
glVertex2f(left + POPUP_WIDTH + POPUP_MARGIN * cos(a), top + POPUP_HEIGHT + POPUP_MARGIN * sin(a));
}
for (double a = 0.5f * M_PI; a < 1.0f * M_PI; a += POPUP_STEP) {
glVertex2f(left + POPUP_MARGIN * cos(a) , top + POPUP_HEIGHT + POPUP_MARGIN * sin(a));
}
glEnd();
glBegin(GL_QUADS);
glColor3f(color.redF(),
color.greenF(),
color.blueF());
glVertex2f(left , top);
glVertex2f(left + SWATCH_WIDTH, top);
glVertex2f(left + SWATCH_WIDTH, top + SWATCH_HEIGHT);
glVertex2f(left , top + SWATCH_HEIGHT);
glEnd();
glColor3f(1.0f, 1.0f, 1.0f);
textRenderer.draw(left + SWATCH_WIDTH + POPUP_MARGIN, top + FIRST_LINE_OFFSET , line1);
textRenderer.draw(left + SWATCH_WIDTH + POPUP_MARGIN, top + SECOND_LINE_OFFSET, line2);
}
else {
_swatch.checkColor();
}
glPopMatrix();
}
@ -2984,7 +3056,8 @@ void Application::loadSettings(QSettings* settings) {
settings->endGroup();
scanMenuBar(&Application::loadAction, settings);
getAvatar()->loadData(settings);
getAvatar()->loadData(settings);
_swatch.loadData(settings);
}
@ -3006,6 +3079,7 @@ void Application::saveSettings(QSettings* settings) {
scanMenuBar(&Application::saveAction, settings);
getAvatar()->saveData(settings);
_swatch.saveData(settings);
}
void Application::importSettings() {

View file

@ -39,6 +39,8 @@
#include "Webcam.h"
#include "renderer/GeometryCache.h"
#include "ui/ChatEntry.h"
#include "ToolsPalette.h"
#include "Swatch.h"
class QAction;
class QActionGroup;
@ -139,6 +141,7 @@ private slots:
void updateVoxelModeActions();
void decreaseVoxelSize();
void increaseVoxelSize();
void resetSwatchColors();
void chooseVoxelPaintColor();
void loadSettings(QSettings* set = NULL);
void saveSettings(QSettings* set = NULL);
@ -362,6 +365,8 @@ private:
int _bytesPerSecond;
int _bytesCount;
ToolsPalette _palette;
Swatch _swatch;
};
#endif /* defined(__interface__Application__) */

View file

@ -151,10 +151,6 @@ public:
// Get the position/rotation of a single body ball
void getBodyBallTransform(AvatarJointID jointID, glm::vec3& position, glm::quat& rotation) const;
//read/write avatar data
void writeAvatarDataToFile();
void readAvatarDataFromFile();
static void renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2, float radius1, float radius2);

169
interface/src/Swatch.cpp Normal file
View file

@ -0,0 +1,169 @@
#include "Swatch.h"
#include <iostream>
Swatch::Swatch(QAction* action) :
Tool(action, 0, -1, -1),
_textRenderer(MONO_FONT_FAMILY, 10, 100),
_selected(1) {
}
void Swatch::reset() {
for (int i = 0; i < 8; ++i) {
_colors[i].setRgb(colorBase[i][0],
colorBase[i][1],
colorBase[i][2]);
}
}
QColor Swatch::getColor() {
return _colors[_selected - 1];
}
void Swatch::checkColor() {
if (_action->data().value<QColor>() == _colors[_selected - 1]) {
return;
}
QPixmap map(16, 16);
map.fill(_colors[_selected - 1]);
_action->setData(_colors[_selected - 1]) ;
_action->setIcon(map);
}
void Swatch::saveData(QSettings* settings) {
settings->beginGroup("Swatch");
for (int i(0); i < SWATCH_SIZE; ++i) {
QString rx("R1"), gx("G1"), bx("B1");
rx[1] = '1' + i;
gx[1] = rx[1];
bx[1] = rx[1];
settings->setValue(rx, _colors[i].red());
settings->setValue(gx, _colors[i].green());
settings->setValue(bx, _colors[i].blue());
}
settings->endGroup();
}
void Swatch::loadData(QSettings* settings) {
settings->beginGroup("Swatch");
for (int i = 0; i < SWATCH_SIZE; ++i) {
QString rx("R1"), gx("G1"), bx("B1");
rx[1] = '1' + i;
gx[1] = rx[1];
bx[1] = rx[1];
_colors[i].setRgb(settings->value(rx, colorBase[i][0]).toInt(),
settings->value(gx, colorBase[i][1]).toInt(),
settings->value(bx, colorBase[i][2]).toInt());
}
settings->endGroup();
checkColor();
}
void Swatch::handleEvent(int key, bool getColor) {
int next(0);
switch (key) {
case Qt::Key_1:
next = 1;
break;
case Qt::Key_2:
next = 2;
break;
case Qt::Key_3:
next = 3;
break;
case Qt::Key_4:
next = 4;
break;
case Qt::Key_5:
next = 5;
break;
case Qt::Key_6:
next = 6;
break;
case Qt::Key_7:
next = 7;
break;
case Qt::Key_8:
next = 8;
break;
default:
break;
}
if (getColor) {
if (_action->data().value<QColor>() != _colors[_selected - 1]) {
_selected = next;
_colors[_selected - 1] = _action->data().value<QColor>();
}
} else {
_selected = next;
QPixmap map(16, 16);
map.fill(_colors[_selected - 1]);
_action->setData(_colors[_selected - 1]) ;
_action->setIcon(map);
}
}
void Swatch::render(int width, int height) {
char str[2];
int margin = 0.10f * height;
height = 0.75f * height;
glBegin(GL_QUADS);
glColor3f(0.0f, 0.0f, 0.0f);
glVertex2f(0, 8 * (height - margin) + margin);
glVertex2f(width, 8 * (height - margin) + margin);
glVertex2f(width, 0);
glVertex2f(0, 0);
glEnd();
for (unsigned int i = 0; i < SWATCH_SIZE; ++i) {
glBegin(GL_QUADS);
glColor3f(_colors[i].redF(),
_colors[i].greenF(),
_colors[i].blueF());
glVertex2f(margin , (i + 1) * (height - margin));
glVertex2f(width - margin, (i + 1) * (height - margin));
glVertex2f(width - margin, i * (height - margin) + margin);
glVertex2f(margin , i * (height - margin) + margin);
glEnd();
if (_colors[i].lightness() < 50) {
glBegin(GL_LINES);
glColor3f(1.0f, 1.0f, 1.0f);
glVertex2f(margin , (i + 1) * (height - margin));
glVertex2f(width - margin, (i + 1) * (height - margin));
glVertex2f(width - margin, (i + 1) * (height - margin));
glVertex2f(width - margin, i * (height - margin) + margin);
glVertex2f(width - margin, i * (height - margin) + margin);
glVertex2f(margin , i * (height - margin) + margin);
glVertex2f(margin , i * (height - margin) + margin);
glVertex2f(margin , (i + 1) * (height - margin));
glEnd();
} else {
glColor3f(0.0f, 0.0f, 0.0f);
}
if (_selected == i + 1) {
glBegin(GL_TRIANGLES);
glVertex2f(margin , (i + 1) * (height - margin) - margin);
glVertex2f(width/4 - margin, i * (height - margin) + height / 2.0f);
glVertex2f(margin , i * (height - margin) + margin + margin);
glEnd();
}
sprintf(str, "%d", i + 1);
_textRenderer.draw(3 * width/4, (i + 1) * (height - margin) - 0.2f * height, str);
}
glTranslated(0, 8 * (height - margin) + margin + 0.075f * height, 0);
}

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

@ -0,0 +1,43 @@
//
// Swatch.h
// interface
//
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__Swatch__
#define __interface__Swatch__
#include "Tool.h"
#include "ui/TextRenderer.h"
static const int SWATCH_SIZE = 8;
static const int colorBase[8][3] = {{237, 175, 0},
{61, 211, 72},
{51, 204, 204},
{63, 169, 245},
{193, 99, 122},
{255, 54, 69},
{124, 36, 36},
{63, 35, 19}};
class Swatch : public Tool {
public:
Swatch(QAction* action);
QColor getColor();
void checkColor();
void saveData(QSettings* settings);
void loadData(QSettings* settings);
void reset();
void render(int width, int height);
void handleEvent(int key, bool getColor);
private:
TextRenderer _textRenderer;
QColor _colors[SWATCH_SIZE];
int _selected;
};
#endif /* defined(__interface__Swatch__) */

51
interface/src/Tool.cpp Normal file
View file

@ -0,0 +1,51 @@
#include "Tool.h"
#include <QSvgRenderer>
#include <QPainter>
#include <QGLWidget>
Tool::Tool(QAction *action, GLuint texture, int x, int y) :
_action(action),
_texture(texture),
_x(x),
_y(y) {
}
void Tool::setAction(QAction* action) {
_action = action;
}
bool Tool::isActive() {
return _action->isChecked();
}
void Tool::render(int width, int height) {
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, _texture);
if (_action == 0 || _action->isChecked()) {
glColor3f(1.0f, 1.0f, 1.0f); // reset gl color
} else {
glColor3f(0.3f, 0.3f, 0.3f);
}
glBegin(GL_QUADS);
glTexCoord2f( _x / NUM_TOOLS_COLS, 1.0f - (_y + 1) / NUM_TOOLS_ROWS);
glVertex2f(0 , height);
glTexCoord2f((_x + 1) / NUM_TOOLS_COLS, 1.0f - (_y + 1) / NUM_TOOLS_ROWS);
glVertex2f(width, height);
glTexCoord2f((_x + 1) / NUM_TOOLS_COLS, 1.0f - _y / NUM_TOOLS_ROWS);
glVertex2f(width, 0);
glTexCoord2f( _x / NUM_TOOLS_COLS, 1.0f - _y / NUM_TOOLS_ROWS);
glVertex2f(0 , 0);
glEnd();
glDisable(GL_TEXTURE_2D);
glTranslated(0, 1.10f * height, 0);
}

55
interface/src/Tool.h Normal file
View file

@ -0,0 +1,55 @@
//
// Tool.h
// interface
//
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__Tool__
#define __interface__Tool__
#include <QAction>
#include "InterfaceConfig.h"
#include "Util.h"
class QAction;
// Number of rows and columns in the SVG file for the tool palette
static const int NUM_TOOLS_ROWS = 10;
static const int NUM_TOOLS_COLS = 2;
static const int SWATCHS_TOOLS_COUNT = 13; // 8 swatch + 5 tools
static const int WIDTH_MIN = 47; // Minimal tools width
static const float TOOLS_RATIO = 40.0f / 60.0f; // ratio height/width of tools icons
static const float PAL_SCREEN_RATIO = 3.0f / 100.0f; // Percentage of the screeen width the palette is going to occupy
// Swatch popup consts
static const float POPUP_STEP = 0.05f;
static const float POPUP_MARGIN = 10.0f;
static const int POPUP_WIDTH = 280;
static const int POPUP_HEIGHT = 30;
static const int SWATCH_WIDTH = 64;
static const int SWATCH_HEIGHT = 30;
static const int FIRST_LINE_OFFSET = 12;
static const int SECOND_LINE_OFFSET = 28;
class Tool {
public:
Tool(QAction* action, GLuint texture, int x, int y);
void setAction(QAction* action);
bool isActive();
virtual void render(int width, int height);
protected:
QAction* _action;
GLuint _texture;
// position in the SVG grid
double _x;
double _y;
};
#endif /* defined(__interface__Tool__) */

View file

@ -0,0 +1,79 @@
#include "ToolsPalette.h"
#include <QSvgRenderer>
#include <QPainter>
#include <QGLWidget>
#include <SharedUtil.h>
void ToolsPalette::init(int screenWidth, int screenHeight) {
_width = (PAL_SCREEN_RATIO * screenWidth < WIDTH_MIN) ? WIDTH_MIN : PAL_SCREEN_RATIO * screenWidth;
_height = TOOLS_RATIO * _width;
_left = screenWidth / 150;
_top = (screenHeight - SWATCHS_TOOLS_COUNT * _height) / 2;
// Load SVG
switchToResourcesParentIfRequired();
QSvgRenderer renderer(QString("./resources/images/hifi-interface-tools.svg"));
// Prepare a QImage with desired characteritisc
QImage image(NUM_TOOLS_COLS * _width, NUM_TOOLS_ROWS * _height, QImage::Format_ARGB32);
// Get QPainter that paints to the image
QPainter painter(&image);
renderer.render(&painter);
//get the OpenGL-friendly image
_textureImage = QGLWidget::convertToGLFormat(image);
glGenTextures(1, &_textureID);
glBindTexture(GL_TEXTURE_2D, _textureID);
//generate the texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
_textureImage.width(),
_textureImage.height(),
0, GL_RGBA, GL_UNSIGNED_BYTE,
_textureImage.bits());
//texture parameters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
void ToolsPalette::addAction(QAction* action, int x, int y) {
Tool* tmp = new Tool(action, _textureID, x, y);
_tools.push_back(tmp);
}
void ToolsPalette::addTool(Tool* tool) {
_tools.push_back(tool);
}
void ToolsPalette::render(int screenWidth, int screenHeight) {
_width = (PAL_SCREEN_RATIO * screenWidth < WIDTH_MIN) ? WIDTH_MIN : PAL_SCREEN_RATIO * screenWidth;
_height = TOOLS_RATIO * _width;
_left = screenWidth / 150;
_top = (screenHeight - SWATCHS_TOOLS_COUNT * _height) / 2;
glPushMatrix();
glTranslated(_left, _top, 0);
bool show = false;
for (unsigned int i = 0; i < _tools.size(); ++i) {
if (_tools[i]->isActive()) {
show = true;
break;
}
}
if (show) {
for (unsigned int i = 0; i < _tools.size(); ++i) {
_tools[i]->render(_width, _height);
}
}
glPopMatrix();
}

View file

@ -0,0 +1,35 @@
//
// ToolsPalette.h
// interface
//
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__ToolsPalette__
#define __interface__ToolsPalette__
#include "Tool.h"
#include "Swatch.h"
#include <vector>
class ToolsPalette {
public:
void init(int screenWidth, int screenHeight);
void addAction(QAction* action, int x, int y);
void addTool(Tool* tool);
void render(int screenWidth, int screenHeight);
private:
QImage _textureImage;
GLuint _textureID;
std::vector<Tool*> _tools;
int _top;
int _left;
int _width;
int _height;
};
#endif /* defined(__interface__ToolsPalette__) */

View file

@ -25,7 +25,6 @@
// the standard mono font family
#define MONO_FONT_FAMILY "Courier"
void eulerToOrthonormals(glm::vec3 * angles, glm::vec3 * fwd, glm::vec3 * left, glm::vec3 * up);
float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos);

View file

@ -22,7 +22,7 @@ int SimpleMovingAverage::updateAverage(float sample) {
if (_numSamples > 0) {
_average = (ONE_MINUS_WEIGHTING * _average) + (WEIGHTING * sample);
float eventDelta = (usecTimestampNow() - _lastEventTimestamp) / 1000000;
float eventDelta = (usecTimestampNow() - _lastEventTimestamp) / 1000000.0f;
if (_numSamples > 1) {
_eventDeltaAverage = (ONE_MINUS_WEIGHTING * _eventDeltaAverage) +
@ -46,7 +46,7 @@ void SimpleMovingAverage::reset() {
float SimpleMovingAverage::getEventDeltaAverage() {
return (ONE_MINUS_WEIGHTING * _eventDeltaAverage) +
(WEIGHTING * ((usecTimestampNow() - _lastEventTimestamp) / 1000000));
(WEIGHTING * ((usecTimestampNow() - _lastEventTimestamp) / 1000000.0f));
}
float SimpleMovingAverage::getAverageSampleValuePerSecond() {

View file

@ -17,7 +17,7 @@
#include "AABox.h"
#include "VoxelProjectedPolygon.h"
const float DEFAULT_KEYHOLE_RADIUS = 2.0f;
const float DEFAULT_KEYHOLE_RADIUS = 3.0f;
class ViewFrustum {
public:

View file

@ -1270,9 +1270,39 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp
bool childWasInView = (childNode && params.deltaViewFrustum &&
(params.lastViewFrustum && ViewFrustum::INSIDE == childNode->inFrustum(*params.lastViewFrustum)));
// There are two types of nodes for which we want to send colors:
// 1) Leaves - obviously
// 2) Non-leaves who's children would be visible and beyond our LOD.
// NOTE: This code works, but it's pretty expensive, because we're calculating distances for all the grand
// children, which we'll end up doing again later in the next level of recursion. We need to optimize this
// in the future.
bool isLeafOrLOD = childNode->isLeaf();
if (params.viewFrustum && childNode->isColored() && !childNode->isLeaf()) {
int grandChildrenInView = 0;
int grandChildrenInLOD = 0;
for (int grandChildIndex = 0; grandChildIndex < NUMBER_OF_CHILDREN; grandChildIndex++) {
VoxelNode* grandChild = childNode->getChildAtIndex(grandChildIndex);
if (grandChild && grandChild->isColored() && grandChild->isInView(*params.viewFrustum)) {
grandChildrenInView++;
float grandChildDistance = grandChild->distanceToCamera(*params.viewFrustum);
float grandChildBoundaryDistance = boundaryDistanceForRenderLevel(grandChild->getLevel() + 1);
if (grandChildDistance < grandChildBoundaryDistance) {
grandChildrenInLOD++;
}
}
}
// if any of our grandchildren ARE in view, then we don't want to include our color. If none are, then
// we do want to include our color
if (grandChildrenInView > 0 && grandChildrenInLOD==0) {
isLeafOrLOD = true;
}
}
// track children with actual color, only if the child wasn't previously in view!
if (childNode && childNode->isColored() && !childWasInView && !childIsOccluded) {
if (childNode && isLeafOrLOD && childNode->isColored() && !childWasInView && !childIsOccluded) {
childrenColoredBits += (1 << (7 - originalIndex));
inViewWithColorCount++;
}