misc. changes

This commit is contained in:
Anthony J. Thibault 2015-07-08 18:11:51 -07:00
parent 0f30da64bc
commit 2ac6b6cd32
5 changed files with 22 additions and 26 deletions

View file

@ -2628,22 +2628,21 @@ void Application::update(float deltaTime) {
_myAvatar->setDriveKeys(ROT_DOWN, userInputMapper->getActionState(UserInputMapper::PITCH_DOWN));
_myAvatar->setDriveKeys(ROT_LEFT, userInputMapper->getActionState(UserInputMapper::YAW_LEFT));
_myAvatar->setDriveKeys(ROT_RIGHT, userInputMapper->getActionState(UserInputMapper::YAW_RIGHT));
// TODO: set hand positions somehow
UserInputMapper::PoseValue leftHand = userInputMapper->getPoseState(UserInputMapper::LEFT_HAND);
UserInputMapper::PoseValue rightHand = userInputMapper->getPoseState(UserInputMapper::RIGHT_HAND);
Hand* hand = DependencyManager::get<AvatarManager>()->getMyAvatar()->getHand();
setPalmData(hand, leftHand, LEFT_HAND_INDEX);
setPalmData(hand, rightHand, RIGHT_HAND_INDEX);
if (Menu::getInstance()->isOptionChecked(MenuOption::HandMouseInput)) {
emulateMouse(hand, userInputMapper->getActionState(UserInputMapper::LEFT_HAND_CLICK),
userInputMapper->getActionState(UserInputMapper::SHIFT), LEFT_HAND_INDEX);
emulateMouse(hand, userInputMapper->getActionState(UserInputMapper::RIGHT_HAND_CLICK),
userInputMapper->getActionState(UserInputMapper::SHIFT), RIGHT_HAND_INDEX);
}
}
_myAvatar->setDriveKeys(BOOM_IN, userInputMapper->getActionState(UserInputMapper::BOOM_IN));
_myAvatar->setDriveKeys(BOOM_OUT, userInputMapper->getActionState(UserInputMapper::BOOM_OUT));
}
UserInputMapper::PoseValue leftHand = userInputMapper->getPoseState(UserInputMapper::LEFT_HAND);
UserInputMapper::PoseValue rightHand = userInputMapper->getPoseState(UserInputMapper::RIGHT_HAND);
Hand* hand = DependencyManager::get<AvatarManager>()->getMyAvatar()->getHand();
setPalmData(hand, leftHand, LEFT_HAND_INDEX);
setPalmData(hand, rightHand, RIGHT_HAND_INDEX);
if (Menu::getInstance()->isOptionChecked(MenuOption::HandMouseInput)) {
emulateMouse(hand, userInputMapper->getActionState(UserInputMapper::LEFT_HAND_CLICK),
userInputMapper->getActionState(UserInputMapper::SHIFT), LEFT_HAND_INDEX);
emulateMouse(hand, userInputMapper->getActionState(UserInputMapper::RIGHT_HAND_CLICK),
userInputMapper->getActionState(UserInputMapper::SHIFT), RIGHT_HAND_INDEX);
}
updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process...
@ -2804,6 +2803,7 @@ void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, int i
if (hand->getPalms()[j].getSixenseID() == index) {
palm = &(hand->getPalms()[j]);
foundHand = true;
break;
}
}
if (!foundHand) {
@ -2813,11 +2813,7 @@ void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, int i
palm->setSixenseID(index);
}
if (foundHand) {
palm->setActive(pose.isValid());
} else {
palm->setActive(false); // if this isn't a Sixsense ID palm, always make it inactive
}
palm->setActive(pose.isValid());
// TODO: velocity filters, tip velocities, et.c
// see SixenseManager
@ -2843,8 +2839,10 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index)
if (hand->getPalms()[j].getSixenseID() == index) {
palm = &(hand->getPalms()[j]);
foundHand = true;
break;
}
}
//qDebug() << "emulateMouse" << !foundHand << !palm->isActive();
if (!foundHand || !palm->isActive()) {
return;
}
@ -2874,6 +2872,8 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index)
}
//qDebug() << index << " " << click << " " << shift << " " << pos;
//If we are off screen then we should stop processing, and if a trigger or bumper is pressed,
//we should unpress them.
if (pos.x() == INT_MAX) {

View file

@ -470,15 +470,12 @@ Menu::Menu() {
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::HandLasers, 0, false);
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::ShowIKConstraints, 0, false);
#if 0
MenuWrapper* sixenseOptionsMenu = handOptionsMenu->addMenu("Sixense");
#ifdef __APPLE__
addCheckableActionToQMenuAndActionHash(sixenseOptionsMenu,
MenuOption::SixenseEnabled,
0, false,
&SixenseManager::getInstance(),
SLOT(toggleSixense(bool)));
#endif
addCheckableActionToQMenuAndActionHash(sixenseOptionsMenu,
MenuOption::FilterSixense,
0,
@ -491,7 +488,6 @@ Menu::Menu() {
true,
qApp,
SLOT(setLowVelocityFilter(bool)));
#endif
MenuWrapper* leapOptionsMenu = handOptionsMenu->addMenu("Leap Motion");
addCheckableActionToQMenuAndActionHash(leapOptionsMenu, MenuOption::LeapMotionOnHMD, 0, false);

View file

@ -1378,7 +1378,7 @@ glm::vec3 MyAvatar::applyKeyboardMotor(float deltaTime, const glm::vec3& localVe
glm::vec3 direction = front + right + up;
float directionLength = glm::length(direction);
qCDebug(interfaceapp, "direction = (%.5f, %.5f, %.5f)", direction.x, direction.y, direction.z);
//qCDebug(interfaceapp, "direction = (%.5f, %.5f, %.5f)", direction.x, direction.y, direction.z);
// Compute motor magnitude
if (directionLength > EPSILON) {

View file

@ -157,6 +157,7 @@ void SixenseManager::update(float deltaTime) {
if (_deviceID != 0) {
Application::getUserInputMapper()->removeDevice(_deviceID);
_deviceID = 0;
_poseStateMap.clear();
// if (_prevPalms[0]) {
// _prevPalms[0]->setActive(false);
// }
@ -481,7 +482,7 @@ void SixenseManager::handleButtonEvent(unsigned int buttons, int index) {
}
void SixenseManager::handlePoseEvent(glm::vec3 position, glm::quat rotation, int index) {
#if HAS_SIXENSE
#ifdef HAVE_SIXENSE
// Transform the measured position into body frame.
glm::vec3 neck = _neckBase;
// Zeroing y component of the "neck" effectively raises the measured position a little bit.
@ -539,7 +540,7 @@ void SixenseManager::handlePoseEvent(glm::vec3 position, glm::quat rotation, int
// palm->setTipPosition(newTipPosition);
_poseStateMap[makeInput(JointChannel(index)).getChannel()] = UserInputMapper::PoseValue(position, rotation);
#endif
#endif // HAVE_SIXENSE
}
void SixenseManager::registerToUserInputMapper(UserInputMapper& mapper) {

View file

@ -152,8 +152,7 @@ void ViveControllerManager::update() {
if (_deviceID != 0) {
userInputMapper->removeDevice(_deviceID);
_deviceID = 0;
//_poseStateMap[makeInput(LEFT_HAND).getChannel()] = UserInputMapper::PoseValue();
//_poseStateMap[makeInput(RIGHT_HAND).getChannel()] = UserInputMapper::PoseValue();
_poseStateMap.clear();
}
}