diff --git a/examples/controllers/neuron/neuronAvatar.js b/examples/controllers/neuron/neuronAvatar.js index a7146e0759..776cabd301 100644 --- a/examples/controllers/neuron/neuronAvatar.js +++ b/examples/controllers/neuron/neuronAvatar.js @@ -1,6 +1,5 @@ // maps controller joint names to avatar joint names var JOINT_NAME_MAP = { - HipsPosition: "", Hips: "Hips", RightUpLeg: "RightUpLeg", RightLeg: "RightLeg", @@ -124,11 +123,9 @@ NeuronAvatar.prototype.update = function (deltaTime) { var pose = Controller.getPoseValue(channel); var j = MyAvatar.getJointIndex(JOINT_NAME_MAP[keys[i]]); var defaultRot = MyAvatar.getDefaultJointRotation(j); - if (keys[i] == "Hips") { - MyAvatar.setJointRotation(j, Quat.multiply(pose.rotation, defaultRot)); - } else { - MyAvatar.setJointRotation(j, defaultRot); - } + var rot = Quat.multiply(Quat.inverse(defaultRot), Quat.multiply(pose.rotation, defaultRot)); + MyAvatar.setJointRotation(j, Quat.multiply(defaultRot, rot)); + //MyAvatar.setJointTranslation(j, Vec3.multiply(100.0, pose.translation)); } } }; diff --git a/libraries/controllers/src/controllers/StandardControls.h b/libraries/controllers/src/controllers/StandardControls.h index feed8a0fad..4294713238 100644 --- a/libraries/controllers/src/controllers/StandardControls.h +++ b/libraries/controllers/src/controllers/StandardControls.h @@ -88,8 +88,7 @@ namespace controller { // No correlation to SDL enum StandardPoseChannel { - HIPS_ROOT = 0, - HIPS, + HIPS = 0, RIGHT_UP_LEG, RIGHT_LEG, RIGHT_FOOT, diff --git a/plugins/hifiNeuron/src/NeuronPlugin.cpp b/plugins/hifiNeuron/src/NeuronPlugin.cpp index 4f52d8da98..152bce913d 100644 --- a/plugins/hifiNeuron/src/NeuronPlugin.cpp +++ b/plugins/hifiNeuron/src/NeuronPlugin.cpp @@ -17,6 +17,7 @@ #include #include #include +#include Q_DECLARE_LOGGING_CATEGORY(inputplugins) Q_LOGGING_CATEGORY(inputplugins, "hifi.inputplugins") @@ -30,8 +31,7 @@ const QString NeuronPlugin::NEURON_ID_STRING = "Perception Neuron"; // This matches controller::StandardPoseChannel enum JointIndex { - HipsPosition = 0, - Hips, + Hips = 0, RightUpLeg, RightLeg, RightFoot, @@ -204,8 +204,9 @@ void NeuronPlugin::activate() { if (!_socketRef) { // error qCCritical(inputplugins) << "NeuronPlugin: error connecting to " << _serverAddress.c_str() << ":" << _serverPort << "error = " << BRGetLastErrorMessage(); + } else { + qCDebug(inputplugins) << "NeuronPlugin: success connecting to " << _serverAddress.c_str() << ":" << _serverPort; } - qCDebug(inputplugins) << "NeuronPlugin: success connecting to " << _serverAddress.c_str() << ":" << _serverPort; } void NeuronPlugin::deactivate() { @@ -226,9 +227,9 @@ void NeuronPlugin::deactivate() { // convert between euler in degrees to quaternion static quat eulerToQuat(vec3 euler) { - return (glm::angleAxis(euler.y * RADIANS_PER_DEGREE, Vectors::UNIT_Y) * - glm::angleAxis(euler.x * RADIANS_PER_DEGREE, Vectors::UNIT_X) * - glm::angleAxis(euler.z * RADIANS_PER_DEGREE, Vectors::UNIT_Z)); + // euler.x and euler.y are swaped (thanks NOMICOM!) + glm::vec3 e = glm::vec3(euler.y, euler.x, euler.z) * RADIANS_PER_DEGREE; + return (glm::angleAxis(e.y, Vectors::UNIT_Y) * glm::angleAxis(e.x, Vectors::UNIT_X) * glm::angleAxis(e.z, Vectors::UNIT_Z)); } void NeuronPlugin::pluginUpdate(float deltaTime, bool jointsCaptured) { @@ -274,7 +275,6 @@ static controller::StandardPoseChannel neuronJointIndexToPoseIndex(JointIndex i) static const char* neuronJointName(JointIndex i) { switch (i) { - case HipsPosition: return "HipsPosition"; case Hips: return "Hips"; case RightUpLeg: return "RightUpLeg"; case RightLeg: return "RightLeg"; @@ -369,9 +369,17 @@ void NeuronPlugin::InputDevice::update(float deltaTime, const std::vector