More baseball test code

This commit is contained in:
Clément Brisset 2015-11-03 10:11:25 -08:00 committed by Atlante45
parent 40ce2416e8
commit c63fc8557c
2 changed files with 46 additions and 39 deletions

View file

@ -53,6 +53,7 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
glm::vec3 palmPosition;
glm::quat palmRotation;
#ifdef Q_OS_WIN
const auto& plugins = PluginManager::getInstance()->getInputPlugins();
auto it = std::find_if(std::begin(plugins), std::end(plugins), [](const InputPluginPointer& plugin) {
return plugin->getName() == ViveControllerManager::NAME;
@ -60,7 +61,7 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
if (it != std::end(plugins)) {
const auto& vive = it->dynamicCast<ViveControllerManager>();
auto index = (_hand == "right") ? 0 : 1;
auto index = (_hand == "left") ? 0 : 1;
auto userInputMapper = DependencyManager::get<UserInputMapper>();
auto translation = extractTranslation(userInputMapper->getSensorToWorldMat());
auto rotation = glm::quat_cast(userInputMapper->getSensorToWorldMat());
@ -69,8 +70,10 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
const glm::quat quarterX = glm::angleAxis(PI / 2.0f, glm::vec3(1.0f, 0.0f, 0.0f));
const glm::quat yFlip = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
palmPosition = translation + rotation * vive->getPosition(index);
palmRotation = rotation * vive->getRotation(index) * yFlip * quarterX;
} else if (_hand == "right") {
palmRotation = rotation * vive->getRotation(index) * yFlip * quarterX * glm::angleAxis(PI, glm::vec3(1.0f, 0.0f, 0.0f)) * glm::angleAxis(PI_OVER_TWO, glm::vec3(0.0f, 0.0f, 1.0f));
} else
#endif
if (_hand == "right") {
palmPosition = holdingAvatar->getRightPalmPosition();
palmRotation = holdingAvatar->getRightPalmRotation();
} else {

View file

@ -283,7 +283,13 @@ void ViveControllerManager::update(float deltaTime, bool jointsCaptured) {
handleButtonEvent(i, pressed, left);
}
for (uint32_t i = 0; i < vr::k_unControllerStateAxisCount; i++) {
auto mask = vr::ButtonMaskFromId((vr::EVRButtonId)(i + vr::k_EButton_Axis0));
bool pressed = 0 != (controllerState.ulButtonPressed & mask);
if (pressed || true) {
handleAxisEvent(i, controllerState.rAxis[i].x, controllerState.rAxis[i].y, left);
} else {
handleAxisEvent(i, 0.0f, 0.0f, left);
}
}
}
}
@ -412,7 +418,6 @@ void ViveControllerManager::handlePoseEvent(const mat4& mat, bool left) {
const glm::quat signedQuaterZ = glm::angleAxis(sign * PI / 2.0f, glm::vec3(0.0f, 0.0f, 1.0f));
const glm::quat eighthX = glm::angleAxis(PI / 4.0f, glm::vec3(1.0f, 0.0f, 0.0f));
const glm::quat rotationOffset = glm::inverse(signedQuaterZ * eighthX) * yFlip * quarterX;
const glm::vec3 translationOffset = glm::vec3(sign * CONTROLLER_LENGTH_OFFSET / 2.0f,
CONTROLLER_LENGTH_OFFSET / 2.0f,
@ -420,7 +425,6 @@ void ViveControllerManager::handlePoseEvent(const mat4& mat, bool left) {
position += rotation * translationOffset;
rotation = rotation * rotationOffset;
//{quat, x = 0.653281, y = -0.270598, z = 0.653281, w = 0.270598}{vec3, x = 0.0381, y = -0.0381, z = -0.1524}
_poseStateMap[left ? controller::LEFT_HAND : controller::RIGHT_HAND] = controller::Pose(position, rotation);
}