head puck working

This commit is contained in:
Dante Ruiz 2017-06-30 23:43:12 +01:00
parent 3e1aee4d8a
commit 577969481d
5 changed files with 38 additions and 16 deletions

View file

@ -34,36 +34,32 @@
{ "from": "Vive.RSCenter", "to": "Standard.RightPrimaryThumb" },
{ "from": "Vive.RightApplicationMenu", "to": "Standard.RightSecondaryThumb" },
{ "from": "Vive.LeftHand", "to": "Standard.LeftHand", "when": [ "Application.InHMD" ] },
{ "from": "Vive.RightHand", "to": "Standard.RightHand", "when": [ "Application.InHMD" ] },
{ "from": "Vive.LeftHand", "to": "Standard.LeftHand"},
{ "from": "Vive.RightHand", "to": "Standard.RightHand"},
{
"from": "Vive.LeftFoot", "to" : "Standard.LeftFoot",
"filters" : [{"type" : "lowVelocity", "rotation" : 1.0, "translation": 1.0}],
"when": [ "Application.InHMD" ]
"filters" : [{"type" : "lowVelocity", "rotation" : 1.0, "translation": 1.0}]
},
{
"from": "Vive.RightFoot", "to" : "Standard.RightFoot",
"filters" : [{"type" : "lowVelocity", "rotation" : 1.0, "translation": 1.0}],
"when": [ "Application.InHMD" ]
"filters" : [{"type" : "lowVelocity", "rotation" : 1.0, "translation": 1.0}]
},
{
"from": "Vive.Hips", "to" : "Standard.Hips",
"filters" : [{"type" : "lowVelocity", "rotation" : 0.01, "translation": 0.01}],
"when": [ "Application.InHMD" ]
"filters" : [{"type" : "lowVelocity", "rotation" : 0.01, "translation": 0.01}]
},
{
"from": "Vive.Spine2", "to" : "Standard.Spine2",
"filters" : [{"type" : "lowVelocity", "rotation" : 0.01, "translation": 0.01}],
"when": [ "Application.InHMD" ]
"filters" : [{"type" : "lowVelocity", "rotation" : 0.01, "translation": 0.01}]
},
{ "from": "Vive.Head", "to" : "Standard.Head", "when": [ "Application.InHMD" ] },
{ "from": "Vive.Head", "to" : "Standard.Head"},
{ "from": "Vive.RightArm", "to" : "Standard.RightArm", "when": [ "Application.InHMD" ] },
{ "from": "Vive.LeftArm", "to" : "Standard.LeftArm", "when": [ "Application.InHMD" ] }
{ "from": "Vive.RightArm", "to" : "Standard.RightArm"},
{ "from": "Vive.LeftArm", "to" : "Standard.LeftArm"}
]
}

View file

@ -1620,7 +1620,8 @@ void MyAvatar::prepareForPhysicsSimulation() {
_characterController.setParentVelocity(parentVelocity);
_characterController.setPositionAndOrientation(getPosition(), getOrientation());
if (qApp->isHMDMode()) {
auto headPose = getHeadControllerPoseInAvatarFrame();
if (headPose.isValid()) {
_follow.prePhysicsUpdate(*this, deriveBodyFromHMDSensor(), _bodySensorMatrix, hasDriveInput());
} else {
_follow.deactivate();

View file

@ -525,7 +525,7 @@ void OpenVrDisplayPlugin::resetSensors() {
_sensorResetMat = glm::inverse(cancelOutRollAndPitch(m));
}
static bool isBadPose(vr::HmdMatrix34_t* mat) {
/static bool isBadPose(vr::HmdMatrix34_t* mat) {
if (mat->m[1][3] < -0.2f) {
return true;
}

View file

@ -123,6 +123,22 @@ static QString deviceTrackingResultToString(vr::ETrackingResult trackingResult)
return result;
}
static glm::mat4 calculateResetMat() {
auto chaperone = vr::VRChaperone();
if (chaperone) {
float const UI_RADIUS = 1.0f;
float const UI_HEIGHT = 1.6f;
float const UI_Z_OFFSET = 0.5;
float xSize, zSize;
chaperone->GetPlayAreaSize(&xSize, &zSize);
glm::vec3 uiPos(0.0f, UI_HEIGHT, UI_RADIUS - (0.5f * zSize) - UI_Z_OFFSET);
return glm::inverse(createMatFromQuatAndPos(glm::quat(), uiPos));
}
return glm::mat4();
}
bool ViveControllerManager::isDesktopMode() {
if (_container) {
return !_container->getActiveDisplayPlugin()->isHmd();
@ -228,7 +244,13 @@ void ViveControllerManager::pluginUpdate(float deltaTime, const controller::Inpu
}
if (isDesktopMode()) {
qDebug() << "In desktop mode";
if (!_resetMatCalculated) {
_resetMat = calculateResetMat();
_resetMatCalculated = true;
}
_system->GetDeviceToAbsoluteTrackingPose(vr::TrackingUniverseStanding, 0, _nextSimPoseData.vrPoses, vr::k_unMaxTrackedDeviceCount);
_nextSimPoseData.update(_resetMat);
}
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();

View file

@ -192,6 +192,9 @@ private:
bool isDesktopMode();
bool _registeredWithInputMapper { false };
bool _modelLoaded { false };
bool _resetMatCalculated { false };
bool _pullInputData { false };
glm::mat4 _resetMat { glm::mat4() };
model::Geometry _modelGeometry;
gpu::TexturePointer _texture;