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

Conflicts:
	interface/src/Application.cpp
	interface/src/Menu.cpp
	interface/src/Menu.h
	interface/src/avatar/Hand.cpp
This commit is contained in:
ZappoMan 2013-12-16 12:11:33 -08:00
commit 6203e9dc2e
14 changed files with 107 additions and 13 deletions

View file

@ -17,6 +17,14 @@ set(OPENCV_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/OpenCV)
set(SIXENSE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/Sixense)
set(UVCCAMERACONTROL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/UVCCameraControl)
if (DEFINED ENV{JOB_ID})
set(BUILD_SEQ $ENV{JOB_ID})
else ()
set(BUILD_SEQ "0")
endif ()
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{QT_CMAKE_PREFIX_PATH})
if (APPLE)
set(GL_HEADERS "#include <GLUT/glut.h>\n#include <OpenGL/glext.h>")
else (APPLE)
@ -35,6 +43,7 @@ include_glm(${TARGET_NAME} ${ROOT_DIR})
# create the InterfaceConfig.h file based on GL_HEADERS above
configure_file(InterfaceConfig.h.in ${PROJECT_BINARY_DIR}/includes/InterfaceConfig.h)
configure_file(InterfaceVersion.h.in ${PROJECT_BINARY_DIR}/includes/InterfaceVersion.h)
# grab the implementation and header files from src dirs
file(GLOB INTERFACE_SRCS src/*.cpp src/*.h)

View file

@ -12,5 +12,4 @@
#define GL_GLEXT_PROTOTYPES 1
@GL_HEADERS@
#endif

View file

@ -0,0 +1,9 @@
//
// InterfaceVersion.h
// Declaration of version and build data
//
// Created by Leonardo Murillo on 12/16/13.
// Copyright (c) 2013 High Fidelity, Inc.. All rights reserved.
//
const int BUILD_VERSION = @BUILD_SEQ@;

View file

@ -49,6 +49,7 @@
#include "Application.h"
#include "DataServerClient.h"
#include "InterfaceVersion.h"
#include "LogDisplay.h"
#include "Menu.h"
#include "Swatch.h"
@ -144,6 +145,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
_applicationStartupTime = startup_time;
_window->setWindowTitle("Interface");
qDebug( "[VERSION] Build sequence: %i", BUILD_VERSION);
qInstallMessageHandler(messageHandler);
unsigned int listenPort = 0; // bind to an ephemeral port by default
@ -215,9 +218,11 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);
QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
_networkAccessManager = new QNetworkAccessManager(this);
QNetworkDiskCache* cache = new QNetworkDiskCache(_networkAccessManager);
cache->setCacheDirectory("interfaceCache");
cache->setCacheDirectory(!cachePath.isEmpty() ? cachePath : "interfaceCache");
_networkAccessManager->setCache(cache);
_window->setCentralWidget(_glWidget);
@ -241,10 +246,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
// allow you to move a particle around in your hand
_particleEditSender.setPacketsPerSecond(3000); // super high!!
printf("Application::Application() _voxelEditSender=%p\n", &_voxelEditSender);
printf("Application::Application() _particleEditSender=%p\n", &_particleEditSender);
// Set the sixense filtering
_sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
}
Application::~Application() {
@ -4106,12 +4109,14 @@ void Application::attachNewHeadToNode(Node* newNode) {
void Application::updateWindowTitle(){
QString title = "";
QString buildVersion = " (build " + QString::number(BUILD_VERSION) + ")";
QString username = _profile.getUsername();
if(!username.isEmpty()){
title += _profile.getUsername();
title += " @ ";
}
title += _profile.getLastDomain();
title += buildVersion;
qDebug("Application title set to: %s.\n", title.toStdString().c_str());
_window->setWindowTitle(title);

View file

@ -152,6 +152,7 @@ public:
SerialInterface* getSerialHeadSensor() { return &_serialHeadSensor; }
Webcam* getWebcam() { return &_webcam; }
Faceshift* getFaceshift() { return &_faceshift; }
SixenseManager* getSixenseManager() { return &_sixenseManager; }
BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; }
QSettings* getSettings() { return _settings; }
Swatch* getSwatch() { return &_swatch; }

View file

@ -363,6 +363,12 @@ Menu::Menu() :
QMenu* handOptionsMenu = developerMenu->addMenu("Hand Options");
addCheckableActionToQMenuAndActionHash(handOptionsMenu,
MenuOption::FilterSixense,
0,
true,
appInstance->getSixenseManager(),
SLOT(setFilter(bool)));
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::SimulateLeapHand);
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayLeapHands, 0, true);
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::LeapDrive, 0, false);

View file

@ -176,6 +176,7 @@ namespace MenuOption {
const QString DisplayFrustum = "Display Frustum";
const QString DisplayLeapHands = "Display Leap Hands";
const QString DisplayHandTargets = "Display Hand Targets";
const QString FilterSixense = "Smooth Sixense Movement";
const QString DontRenderVoxels = "Don't call _voxels.render()";
const QString DontCallOpenGLForVoxels = "Don't call glDrawRangeElementsEXT() for Voxels";
const QString EnableOcclusionCulling = "Enable Occlusion Culling";

View file

@ -48,7 +48,9 @@ Hand::Hand(Avatar* owningAvatar) :
_collisionCenter(0,0,0),
_collisionAge(0),
_collisionDuration(0),
_pitchUpdate(0)
_pitchUpdate(0),
_grabDelta(0, 0, 0),
_grabDeltaVelocity(0, 0, 0)
{
for (int i = 0; i < MAX_HANDS; i++) {
_toyBallInHand[i] = false;
@ -74,7 +76,6 @@ void Hand::reset() {
void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, float deltaTime) {
bool ballFromHand = Menu::getInstance()->isOptionChecked(MenuOption::BallFromHand);
int handID = palm.getSixenseID();
glm::vec3 targetPosition = palm.getPosition() / (float)TREE_SCALE;
float targetRadius = (TOY_BALL_RADIUS * 4.0f) / (float)TREE_SCALE;
const Particle* closestParticle = Application::getInstance()->getParticles()
@ -137,8 +138,6 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f
// Is the controller button being held down....
if (palm.getControllerButtons() & BUTTON_FWD) {
// If grabbing toy ball, add forces to it.
// If we don't currently have a ball in hand, then create it...
if (!_toyBallInHand[handID]) {
// Test for whether close enough to catch and catch....
@ -209,6 +208,23 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f
}
}
glm::vec3 Hand::getAndResetGrabDelta() {
const float HAND_GRAB_SCALE_DISTANCE = 5.f;
glm::vec3 delta = _grabDelta * _owningAvatar->getScale() * HAND_GRAB_SCALE_DISTANCE;
_grabDelta = glm::vec3(0,0,0);
glm::quat avatarRotation = _owningAvatar->getOrientation();
return avatarRotation * -delta;
}
glm::vec3 Hand::getAndResetGrabDeltaVelocity() {
const float HAND_GRAB_SCALE_VELOCITY = 5.f;
glm::vec3 delta = _grabDeltaVelocity * _owningAvatar->getScale() * HAND_GRAB_SCALE_VELOCITY;
_grabDeltaVelocity = glm::vec3(0,0,0);
glm::quat avatarRotation = _owningAvatar->getOrientation();
return avatarRotation * -delta;
}
void Hand::simulate(float deltaTime, bool isMine) {
if (_collisionAge > 0.f) {
@ -239,6 +255,13 @@ void Hand::simulate(float deltaTime, bool isMine) {
simulateToyBall(palm, fingerTipPosition, deltaTime);
if (palm.getControllerButtons() & BUTTON_4) {
_grabDelta += palm.getRawVelocity() * deltaTime;
}
if ((palm.getLastControllerButtons() & BUTTON_4) && !(palm.getControllerButtons() & BUTTON_4)) {
_grabDeltaVelocity = palm.getRawVelocity();
}
if (palm.getControllerButtons() & BUTTON_1) {
if (glm::length(fingerTipPosition - _lastFingerAddVoxel) > (FINGERTIP_VOXEL_SIZE / 2.f)) {
QColor paintColor = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor)->data().value<QColor>();
@ -285,6 +308,7 @@ void Hand::simulate(float deltaTime, bool isMine) {
}
}
}
palm.setLastControllerButtons(palm.getControllerButtons());
}
}
}

View file

@ -61,6 +61,10 @@ public:
const float getPitchUpdate() const { return _pitchUpdate; }
void setPitchUpdate(float pitchUpdate) { _pitchUpdate = pitchUpdate; }
// Get the drag distance to move
glm::vec3 getAndResetGrabDelta();
glm::vec3 getAndResetGrabDeltaVelocity();
private:
// disallow copies of the Hand, copy of owning Avatar is disallowed too
Hand(const Hand&);
@ -95,6 +99,7 @@ private:
void handleVoxelCollision(PalmData* palm, const glm::vec3& fingerTipPosition, VoxelTreeElement* voxel, float deltaTime);
void simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, float deltaTime);
#define MAX_HANDS 2
bool _toyBallInHand[MAX_HANDS];
@ -103,6 +108,9 @@ private:
int _lastControllerButtons;
float _pitchUpdate;
glm::vec3 _grabDelta;
glm::vec3 _grabDeltaVelocity;
};

View file

@ -271,6 +271,14 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) {
updateChatCircle(deltaTime);
// Get any position or velocity update from Grab controller
glm::vec3 moveFromGrab = _hand.getAndResetGrabDelta();
if (glm::length(moveFromGrab) > EPSILON) {
_position += moveFromGrab;
_velocity = glm::vec3(0, 0, 0);
}
_velocity += _hand.getAndResetGrabDeltaVelocity();
_position += _velocity * deltaTime;
// update avatar skeleton and simulate hand and head

View file

@ -127,6 +127,9 @@ bool operator<(const IndexValue& firstIndex, const IndexValue& secondIndex) {
void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJointIndices,
const QVector<int>& fingertipJointIndices, PalmData& palm) {
if (jointIndex == -1) {
return;
}
const FBXGeometry& geometry = _geometry->getFBXGeometry();
setJointPosition(jointIndex, palm.getPosition());
float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f;

View file

@ -16,7 +16,6 @@
SixenseManager::SixenseManager() {
#ifdef HAVE_SIXENSE
sixenseInit();
sixenseSetFilterEnabled(1);
#endif
}
@ -26,6 +25,18 @@ SixenseManager::~SixenseManager() {
#endif
}
void SixenseManager::setFilter(bool filter) {
#ifdef HAVE_SIXENSE
if (filter) {
qDebug("Sixense Filter ON\n");
sixenseSetFilterEnabled(1);
} else {
qDebug("Sixense Filter OFF\n");
sixenseSetFilterEnabled(0);
}
#endif
}
void SixenseManager::update(float deltaTime) {
#ifdef HAVE_SIXENSE
if (sixenseGetNumActiveControllers() == 0) {

View file

@ -10,13 +10,19 @@
#define __interface__SixenseManager__
/// Handles interaction with the Sixense SDK (e.g., Razer Hydra).
class SixenseManager {
class SixenseManager : public QObject {
Q_OBJECT
public:
SixenseManager();
~SixenseManager();
void update(float deltaTime);
public slots:
void setFilter(bool filter);
};
#endif /* defined(__interface__SixenseManager__) */

View file

@ -158,8 +158,11 @@ public:
// Controller buttons
void setControllerButtons(int controllerButtons) { _controllerButtons = controllerButtons; }
int getControllerButtons() { return _controllerButtons; }
void setLastControllerButtons(int controllerButtons) { _lastControllerButtons = controllerButtons; }
int getControllerButtons() { return _controllerButtons; }
int getLastControllerButtons() { return _lastControllerButtons; }
void setTrigger(float trigger) { _trigger = trigger; }
float getTrigger() { return _trigger; }
void setJoystick(float joystickX, float joystickY) { _joystickX = joystickX; _joystickY = joystickY; }
@ -181,6 +184,7 @@ private:
glm::vec3 _tipPosition;
glm::vec3 _tipVelocity;
int _controllerButtons;
int _lastControllerButtons;
float _trigger;
float _joystickX, _joystickY;