History

fix sixense and vive rotation readings for palms

Andrew Meadows committed 11 years ago

Commit 992bd5c1 parent 3e118525 files · +18 −14Browse files

Showing the changes to libraries/input-plugins/src/input-plugins/ViveControllerManager.cpp (1 of 5 files). Show all

Unified · Split

libraries/input-plugins/src/input-plugins/ViveControllerManager.cpp+6−7
@@ -362,18 +362,17 @@ void ViveControllerManager::handlePoseEvent(const mat4& mat, int index) { · 361 unmodified lines
362 //362 //
363 // Qoffset = glm::inverse(deltaRotation when hand is posed fingers forward, palm down)363 // Qoffset = glm::inverse(deltaRotation when hand is posed fingers forward, palm down)
364 //364 //
365 // An approximate offset for the Vive can be obtained by inpection:365 // An approximate offset for the Vive can be obtained by inspection:
366 //366 //
367 // Qoffset = glm::inverse(glm::angleAxis(sign * PI/4.0f, zAxis) * glm::angleAxis(PI/2.0f, xAxis))367 // Qoffset = glm::inverse(glm::angleAxis(sign * PI/4.0f, zAxis) * glm::angleAxis(PI/2.0f, xAxis))
368 //368 //
369 369 // So the full equation is:
370 // Finally there is another flip around the yAxis to re-align from model to Vive space, so the full equation is:
371 //370 //
372 // Q = yFlip * combinedMeasurement * viveToHand371 // Q = combinedMeasurement * viveToHand
373 //372 //
374 // Q = yFlip * (deltaQ * QOffset) * (yFlip * quarterTurnAboutX)373 // Q = (deltaQ * QOffset) * (yFlip * quarterTurnAboutX)
375 //374 //
376 // Q = yFlip * (deltaQ * inverse(deltaQForAlignedHand)) * (yFlip * quarterTurnAboutX)375 // Q = (deltaQ * inverse(deltaQForAlignedHand)) * (yFlip * quarterTurnAboutX)
377 376
378 const glm::quat quarterX = glm::angleAxis(PI / 2.0f, glm::vec3(1.0f, 0.0f, 0.0f));377 const glm::quat quarterX = glm::angleAxis(PI / 2.0f, glm::vec3(1.0f, 0.0f, 0.0f));
379 const glm::quat yFlip = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));378 const glm::quat yFlip = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
@@ -381,7 +380,7 @@ void ViveControllerManager::handlePoseEvent(const mat4& mat, int index) { · 1 unmodified line
381 const glm::quat signedQuaterZ = glm::angleAxis(sign * PI / 2.0f, glm::vec3(0.0f, 0.0f, 1.0f)); 380 const glm::quat signedQuaterZ = glm::angleAxis(sign * PI / 2.0f, glm::vec3(0.0f, 0.0f, 1.0f));
382 const glm::quat eighthX = glm::angleAxis(PI / 4.0f, glm::vec3(1.0f, 0.0f, 0.0f));381 const glm::quat eighthX = glm::angleAxis(PI / 4.0f, glm::vec3(1.0f, 0.0f, 0.0f));
383 const glm::quat offset = glm::inverse(signedQuaterZ * eighthX);382 const glm::quat offset = glm::inverse(signedQuaterZ * eighthX);
384 rotation = yFlip * rotation * offset * yFlip * quarterX;383 rotation = rotation * offset * yFlip * quarterX;
385 384
386 position += rotation * glm::vec3(0, 0, -CONTROLLER_LENGTH_OFFSET);385 position += rotation * glm::vec3(0, 0, -CONTROLLER_LENGTH_OFFSET);
387 386