Merge pull request #10059 from ZappoMan/addKinectHandRotation

some more kinect work
This commit is contained in:
Andrew Meadows 2017-03-30 11:05:44 -07:00 committed by GitHub
commit 76ef2b5d9f
2 changed files with 72 additions and 4 deletions

View file

@ -228,7 +228,8 @@ void KinectPlugin::init() {
{
auto getter = [this]()->bool { return _enabled; };
auto setter = [this](bool value) {
_enabled = value; saveSettings();
_enabled = value;
saveSettings();
if (!_enabled) {
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
userInputMapper->withLock([&, this]() {
@ -240,9 +241,10 @@ void KinectPlugin::init() {
preferences->addPreference(preference);
}
{
auto debugGetter = [this]()->bool { return _enabled; };
auto debugGetter = [this]()->bool { return _debug; };
auto debugSetter = [this](bool value) {
_debug = value; saveSettings();
_debug = value;
saveSettings();
};
auto preference = new CheckPreference(KINECT_PLUGIN, "Extra Debugging", debugGetter, debugSetter);
preferences->addPreference(preference);
@ -573,8 +575,8 @@ void KinectPlugin::loadSettings() {
QString idString = getID();
settings.beginGroup(idString);
{
// enabled
_enabled = settings.value("enabled", QVariant(DEFAULT_ENABLED)).toBool();
_debug = settings.value("extraDebug", QVariant(DEFAULT_ENABLED)).toBool();
}
settings.endGroup();
}

View file

@ -0,0 +1,66 @@
var handlerId = 0;
var ikTypes = {
RotationAndPosition: 0,
RotationOnly: 1,
HmdHead: 2,
HipsRelativeRotationAndPosition: 3,
Off: 4
};
var MAPPING_NAME = "com.highfidelity.examples.kinectToAnimation";
var mapping = Controller.newMapping(MAPPING_NAME);
var recentLeftHand;
var recentRightHand;
var recentLeftFoot;
var recentRightFoot;
mapping.from(Controller.Hardware.Kinect.LeftHand).debug(true).to(function(pose) { recentLeftHand = pose; });
mapping.from(Controller.Hardware.Kinect.RightHand).debug(true).to(function(pose) { recentRightHand = pose; });
mapping.from(Controller.Hardware.Kinect.LeftFoot).debug(true).to(function(pose) { recentLeftFoot = pose; });
mapping.from(Controller.Hardware.Kinect.RightFoot).debug(true).to(function(pose) { recentRightFoot = pose; });
function init() {
var t = 0;
var propList = [
"leftHandType", "leftHandPosition", "leftHandRotation", "rightHandType", "rightHandPosition", "rightHandRotation",
"leftFootType", "leftFootPosition", "leftFootRotation", "rightFootType", "rightFootPosition", "rightFootRotation"
];
handlerId = MyAvatar.addAnimationStateHandler(function (props) {
Vec3.print("recentRightHand.translation:", recentRightHand.translation);
Vec3.print("recentLeftHand.translation:", recentLeftHand.translation);
Vec3.print("recentRightFoot.translation:", recentRightFoot.translation);
Vec3.print("recentLeftFoot.translation:", recentLeftFoot.translation);
return {
rightHandType: ikTypes["RotationAndPosition"],
rightHandPosition: recentRightHand.translation,
rightHandRotation: recentRightHand.rotation,
leftHandType: ikTypes["RotationAndPosition"],
leftHandPosition: recentLeftHand.translation,
leftHandRotation: recentLeftHand.rotation,
rightFootType: ikTypes["RotationAndPosition"],
rightFootPosition: recentRightFoot.translation,
rightFootRotation: recentRightFoot.rotation,
leftFootType: ikTypes["RotationAndPosition"],
leftFootPosition: recentLeftFoot.translation,
leftFootRotation: recentLeftFoot.rotation,
};
}, propList);
Controller.enableMapping(MAPPING_NAME);
}
init();
Script.scriptEnding.connect(function(){
MyAvatar.removeAnimationStateHandler(handlerId);
mapping.disable();
});