mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-03 23:24:35 +02:00
Merge branch 'sam/vive-hand-controllers' of github.com:hyperlogic/hifi into sam/vive-hand-controllers
This commit is contained in:
commit
aa66691a73
8 changed files with 35 additions and 79 deletions
|
@ -692,6 +692,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
auto applicationUpdater = DependencyManager::get<AutoUpdater>();
|
||||
connect(applicationUpdater.data(), &AutoUpdater::newVersionIsAvailable, dialogsManager.data(), &DialogsManager::showUpdateDialog);
|
||||
applicationUpdater->checkForUpdate();
|
||||
|
||||
// Now that menu is initalized we can sync myAvatar with it's state.
|
||||
_myAvatar->updateMotionBehaviorFromMenu();
|
||||
_myAvatar->updateStandingHMDModeFromMenu();
|
||||
}
|
||||
|
||||
void Application::aboutToQuit() {
|
||||
|
@ -969,15 +973,6 @@ void Application::paintGL() {
|
|||
} else {
|
||||
_myCamera.setRotation(glm::quat_cast(_myAvatar->getSensorToWorldMatrix() * getHMDSensorPose()));
|
||||
}
|
||||
|
||||
/*
|
||||
qCDebug(interfaceapp, "paintGL");
|
||||
glm::vec3 cameraPos = _myCamera.getPosition();
|
||||
glm::quat cameraRot = _myCamera.getRotation();
|
||||
qCDebug(interfaceapp, "\tcamera pos = (%.5f, %.5f, %.5f)", cameraPos.x, cameraPos.y, cameraPos.z);
|
||||
qCDebug(interfaceapp, "\tcamera rot = (%.5f, %.5f, %.5f, %.5f)", cameraRot.x, cameraRot.y, cameraRot.z, cameraRot.w);
|
||||
*/
|
||||
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||
if (isHMDMode()) {
|
||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation());
|
||||
|
@ -2803,11 +2798,6 @@ void Application::update(float deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
// AJT: hack for debug drawing.
|
||||
extern const int NUM_MARKERS;
|
||||
extern glm::mat4 markerMats[];
|
||||
extern glm::vec4 markerColors[];
|
||||
|
||||
void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, int index) {
|
||||
PalmData* palm;
|
||||
bool foundHand = false;
|
||||
|
@ -2838,9 +2828,6 @@ void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, int i
|
|||
|
||||
palm->setRawPosition(extractTranslation(objectPose));
|
||||
palm->setRawRotation(glm::quat_cast(objectPose));
|
||||
|
||||
// AJT: Hack for debug drawing.
|
||||
//markerMats[index] = sensorToWorldMat * poseMat;
|
||||
}
|
||||
|
||||
void Application::emulateMouse(Hand* hand, float click, float shift, int index) {
|
||||
|
|
|
@ -244,16 +244,16 @@ Menu::Menu() {
|
|||
SLOT(resetSize()));
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::KeyboardMotorControl,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_K, true, avatar, SLOT(updateMotionBehavior()));
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_K, true, avatar, SLOT(updateMotionBehaviorFromMenu()));
|
||||
addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::ScriptedMotorControl, 0, true,
|
||||
avatar, SLOT(updateMotionBehavior()));
|
||||
avatar, SLOT(updateMotionBehaviorFromMenu()));
|
||||
addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::NamesAboveHeads, 0, true);
|
||||
addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::GlowWhenSpeaking, 0, true);
|
||||
addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::BlueSpeechSphere, 0, true);
|
||||
addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::EnableCharacterController, 0, true,
|
||||
avatar, SLOT(updateMotionBehavior()));
|
||||
avatar, SLOT(updateMotionBehaviorFromMenu()));
|
||||
addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::ShiftHipsForIdleAnimations, 0, false,
|
||||
avatar, SLOT(updateMotionBehavior()));
|
||||
avatar, SLOT(updateMotionBehaviorFromMenu()));
|
||||
|
||||
MenuWrapper* viewMenu = addMenu("View");
|
||||
{
|
||||
|
@ -325,6 +325,9 @@ Menu::Menu() {
|
|||
|
||||
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::TurnWithHead, 0, false);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::StandingHMDSensorMode, 0, false,
|
||||
avatar, SLOT(updateStandingHMDModeFromMenu()));
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Stats);
|
||||
addActionToQMenuAndActionHash(viewMenu, MenuOption::Log,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_L,
|
||||
|
|
|
@ -274,6 +274,7 @@ namespace MenuOption {
|
|||
const QString SimpleShadows = "Simple";
|
||||
const QString SixenseEnabled = "Enable Hydra Support";
|
||||
const QString ShiftHipsForIdleAnimations = "Shift hips for idle animations";
|
||||
const QString StandingHMDSensorMode = "Standing HMD Sensor Mode";
|
||||
const QString Stars = "Stars";
|
||||
const QString Stats = "Stats";
|
||||
const QString StopAllScripts = "Stop All Scripts";
|
||||
|
|
|
@ -34,13 +34,6 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
// AJT HACK, I'm using these markers for debugging.
|
||||
// extern them and set them in other cpp files and they will be rendered
|
||||
// with the world box.
|
||||
const int NUM_MARKERS = 4;
|
||||
glm::mat4 markerMats[NUM_MARKERS];
|
||||
glm::vec4 markerColors[NUM_MARKERS] = {{1, 0, 0, 1}, {0, 1, 0, 1}, {0, 0, 1, 1}, {0, 1, 1, 1}};
|
||||
|
||||
void renderWorldBox(gpu::Batch& batch) {
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
|
||||
|
@ -79,26 +72,6 @@ void renderWorldBox(gpu::Batch& batch) {
|
|||
transform.setTranslation(glm::vec3(MARKER_DISTANCE, 0.0f, MARKER_DISTANCE));
|
||||
batch.setModelTransform(transform);
|
||||
geometryCache->renderSphere(batch, MARKER_RADIUS, 10, 10, grey);
|
||||
|
||||
// draw marker spheres
|
||||
for (int i = 0; i < NUM_MARKERS; i++) {
|
||||
transform.setTranslation(extractTranslation(markerMats[i]));
|
||||
batch.setModelTransform(transform);
|
||||
geometryCache->renderSphere(batch, 0.02f, 10, 10, markerColors[i]);
|
||||
}
|
||||
|
||||
// draw marker axes
|
||||
auto identity = Transform{};
|
||||
batch.setModelTransform(identity);
|
||||
for (int i = 0; i < NUM_MARKERS; i++) {
|
||||
glm::vec3 base = extractTranslation(markerMats[i]);
|
||||
glm::vec3 xAxis = transformPoint(markerMats[i], glm::vec3(1, 0, 0));
|
||||
glm::vec3 yAxis = transformPoint(markerMats[i], glm::vec3(0, 1, 0));
|
||||
glm::vec3 zAxis = transformPoint(markerMats[i], glm::vec3(0, 0, 1));
|
||||
geometryCache->renderLine(batch, base, xAxis, red);
|
||||
geometryCache->renderLine(batch, base, yAxis, green);
|
||||
geometryCache->renderLine(batch, base, zAxis, blue);
|
||||
}
|
||||
}
|
||||
|
||||
// Return a random vector of average length 1
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
static bool isRoomTracking = true;
|
||||
|
||||
Head::Head(Avatar* owningAvatar) :
|
||||
HeadData((AvatarData*)owningAvatar),
|
||||
_returnHeadToCenter(false),
|
||||
|
@ -120,7 +118,7 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!isRoomTracking) {
|
||||
if (!myAvatar->getStandingHMDSensorMode()) {
|
||||
// Twist the upper body to follow the rotation of the head, but only do this with my avatar,
|
||||
// since everyone else will see the full joint rotations for other people.
|
||||
const float BODY_FOLLOW_HEAD_YAW_RATE = 0.1f;
|
||||
|
@ -342,7 +340,7 @@ glm::quat Head::getCameraOrientation() const {
|
|||
// always the same.
|
||||
if (qApp->isHMDMode()) {
|
||||
MyAvatar* myAvatar = dynamic_cast<MyAvatar*>(_owningAvatar);
|
||||
if (isRoomTracking && myAvatar) {
|
||||
if (myAvatar && myAvatar->getStandingHMDSensorMode()) {
|
||||
return glm::quat_cast(myAvatar->getSensorToWorldMatrix()) * myAvatar->getHMDSensorOrientation();
|
||||
} else {
|
||||
return getOrientation();
|
||||
|
|
|
@ -77,8 +77,6 @@ const float MyAvatar::ZOOM_MIN = 0.5f;
|
|||
const float MyAvatar::ZOOM_MAX = 25.0f;
|
||||
const float MyAvatar::ZOOM_DEFAULT = 1.5f;
|
||||
|
||||
static bool isRoomTracking = true;
|
||||
|
||||
MyAvatar::MyAvatar() :
|
||||
Avatar(),
|
||||
_gravity(0.0f, 0.0f, 0.0f),
|
||||
|
@ -110,7 +108,8 @@ MyAvatar::MyAvatar() :
|
|||
_hmdSensorPosition(),
|
||||
_bodySensorMatrix(),
|
||||
_inverseBodySensorMatrix(),
|
||||
_sensorToWorldMatrix()
|
||||
_sensorToWorldMatrix(),
|
||||
_standingHMDSensorMode(false)
|
||||
{
|
||||
_firstPersonSkeletonModel.setIsFirstPerson(true);
|
||||
|
||||
|
@ -311,7 +310,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) {
|
|||
|
||||
Head* head = getHead();
|
||||
if (inHmd || isPlaying()) {
|
||||
if (!isRoomTracking) {
|
||||
if (!getStandingHMDSensorMode()) {
|
||||
head->setDeltaPitch(estimatedRotation.x);
|
||||
head->setDeltaYaw(estimatedRotation.y);
|
||||
head->setDeltaRoll(estimatedRotation.z);
|
||||
|
@ -337,7 +336,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) {
|
|||
relativePosition.x = -relativePosition.x;
|
||||
}
|
||||
|
||||
if (!(inHmd && isRoomTracking)) {
|
||||
if (!(inHmd && getStandingHMDSensorMode())) {
|
||||
head->setLeanSideways(glm::clamp(glm::degrees(atanf(relativePosition.x * _leanScale / TORSO_LENGTH)),
|
||||
-MAX_LEAN, MAX_LEAN));
|
||||
head->setLeanForward(glm::clamp(glm::degrees(atanf(relativePosition.z * _leanScale / TORSO_LENGTH)),
|
||||
|
@ -1340,7 +1339,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
|||
glm::mat4 sensorOffset = bodyMat * glm::mat4_cast(twist) * glm::inverse(bodyMat);
|
||||
_sensorToWorldMatrix = sensorOffset * _sensorToWorldMatrix;
|
||||
|
||||
if (!(qApp->isHMDMode() && isRoomTracking)) {
|
||||
if (!(qApp->isHMDMode() && getStandingHMDSensorMode())) {
|
||||
setOrientation(twist * getOrientation());
|
||||
}
|
||||
|
||||
|
@ -1532,7 +1531,7 @@ void MyAvatar::updatePosition(float deltaTime) {
|
|||
const float MOVING_SPEED_THRESHOLD = 0.01f;
|
||||
_moving = speed > MOVING_SPEED_THRESHOLD;
|
||||
|
||||
if (qApp->isHMDMode() && isRoomTracking) {
|
||||
if (qApp->isHMDMode() && getStandingHMDSensorMode()) {
|
||||
Avatar::setPosition(getWorldBodyPosition());
|
||||
}
|
||||
}
|
||||
|
@ -1626,7 +1625,7 @@ void MyAvatar::goToLocation(const glm::vec3& newPosition,
|
|||
qCDebug(interfaceapp).nospace() << "MyAvatar goToLocation - moving to " << newPosition.x << ", "
|
||||
<< newPosition.y << ", " << newPosition.z;
|
||||
|
||||
if (qApp->isHMDMode() && isRoomTracking) {
|
||||
if (qApp->isHMDMode() && getStandingHMDSensorMode()) {
|
||||
// AJT: FIXME, does not work with orientation.
|
||||
// AJT: FIXME, does not work with shouldFaceLocation flag.
|
||||
// Set the orientation of the sensor room, not the avatar itself.
|
||||
|
@ -1658,7 +1657,7 @@ void MyAvatar::goToLocation(const glm::vec3& newPosition,
|
|||
emit transformChanged();
|
||||
}
|
||||
|
||||
void MyAvatar::updateMotionBehavior() {
|
||||
void MyAvatar::updateMotionBehaviorFromMenu() {
|
||||
Menu* menu = Menu::getInstance();
|
||||
if (menu->isOptionChecked(MenuOption::KeyboardMotorControl)) {
|
||||
_motionBehaviors |= AVATAR_MOTION_KEYBOARD_MOTOR_ENABLED;
|
||||
|
@ -1674,6 +1673,11 @@ void MyAvatar::updateMotionBehavior() {
|
|||
_feetTouchFloor = menu->isOptionChecked(MenuOption::ShiftHipsForIdleAnimations);
|
||||
}
|
||||
|
||||
void MyAvatar::updateStandingHMDModeFromMenu() {
|
||||
Menu* menu = Menu::getInstance();
|
||||
_standingHMDSensorMode = menu->isOptionChecked(MenuOption::StandingHMDSensorMode);
|
||||
}
|
||||
|
||||
//Renders sixense laser pointers for UI selection with controllers
|
||||
void MyAvatar::renderLaserPointers(gpu::Batch& batch) {
|
||||
const float PALM_TIP_ROD_RADIUS = 0.002f;
|
||||
|
@ -1726,7 +1730,6 @@ void MyAvatar::relayDriveKeysToCharacterController() {
|
|||
}
|
||||
}
|
||||
|
||||
// overriden, because they must move the sensor mat, so that the avatar will be at the given location.
|
||||
void MyAvatar::setPosition(const glm::vec3 position, bool overideReferential) {
|
||||
|
||||
// update the sensor mat so that the body position will end up in the desired
|
||||
|
@ -1737,7 +1740,6 @@ void MyAvatar::setPosition(const glm::vec3 position, bool overideReferential) {
|
|||
Avatar::setPosition(position);
|
||||
}
|
||||
|
||||
// overriden, because they must move the sensor mat, so that the avatar will face the given orienation.
|
||||
void MyAvatar::setOrientation(const glm::quat& orientation, bool overideReferential) {
|
||||
|
||||
// update the sensor mat so that the body position will end up in the desired
|
||||
|
|
|
@ -192,6 +192,8 @@ public:
|
|||
static const float ZOOM_MAX;
|
||||
static const float ZOOM_DEFAULT;
|
||||
|
||||
bool getStandingHMDSensorMode() const { return _standingHMDSensorMode; }
|
||||
|
||||
public slots:
|
||||
void increaseSize();
|
||||
void decreaseSize();
|
||||
|
@ -206,7 +208,8 @@ public slots:
|
|||
glm::vec3 getThrust() { return _thrust; };
|
||||
void setThrust(glm::vec3 newThrust) { _thrust = newThrust; }
|
||||
|
||||
void updateMotionBehavior();
|
||||
void updateMotionBehaviorFromMenu();
|
||||
void updateStandingHMDModeFromMenu();
|
||||
|
||||
glm::vec3 getLeftPalmPosition();
|
||||
glm::quat getLeftPalmRotation();
|
||||
|
@ -226,6 +229,8 @@ public slots:
|
|||
|
||||
virtual void rebuildSkeletonBody();
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
void transformChanged();
|
||||
void newCollisionSoundURL(const QUrl& url);
|
||||
|
@ -326,6 +331,8 @@ private:
|
|||
|
||||
// used to transform any sensor into world space, including the _hmdSensorMat, or hand controllers.
|
||||
glm::mat4 _sensorToWorldMatrix;
|
||||
|
||||
bool _standingHMDSensorMode;
|
||||
};
|
||||
|
||||
#endif // hifi_MyAvatar_h
|
||||
|
|
|
@ -357,13 +357,6 @@ void DynamicCharacterController::preSimulation(btScalar timeStep) {
|
|||
glm::vec3 position = _avatarData->getPosition() + rotation * _shapeLocalOffset;
|
||||
_rigidBody->setWorldTransform(btTransform(glmToBullet(rotation), glmToBullet(position)));
|
||||
|
||||
/*
|
||||
qCDebug(physics, "preSimulation()");
|
||||
qCDebug(physics, "\trigidbody position = (%.5f, %.5f, %.5f)", position.x, position.y, position.z);
|
||||
glm::vec3 p = _avatarData->getPosition();
|
||||
qCDebug(physics, "\tavatar position = (%.5f, %.5f, %.5f)", p.x, p.y, p.z);
|
||||
*/
|
||||
|
||||
// the rotation is dictated by AvatarData
|
||||
btTransform xform = _rigidBody->getWorldTransform();
|
||||
xform.setRotation(glmToBullet(rotation));
|
||||
|
@ -419,13 +412,5 @@ void DynamicCharacterController::postSimulation() {
|
|||
_avatarData->setOrientation(rotation);
|
||||
_avatarData->setPosition(position - rotation * _shapeLocalOffset);
|
||||
_avatarData->setVelocity(bulletToGLM(_rigidBody->getLinearVelocity()));
|
||||
|
||||
/*
|
||||
qCDebug(physics, "postSimulation()");
|
||||
qCDebug(physics, "\trigidbody position = (%.5f, %.5f, %.5f)", position.x, position.y, position.z);
|
||||
glm::vec3 p = position - rotation * _shapeLocalOffset;
|
||||
qCDebug(physics, "\tavatar position = (%.5f, %.5f, %.5f)", p.x, p.y, p.z);
|
||||
qCDebug(physics, "\t_shapeLocalOffset = (%.5f, %.5f, %.5f)", _shapeLocalOffset.x, _shapeLocalOffset.y, _shapeLocalOffset.z);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue