void m_bang() { Frame frame; t_atom generalInfo[6]; int num_hands, num_tools, num_gestures; frame = dispatcher.frame; num_hands = frame.hands().count(); num_tools = frame.tools().count(); num_gestures = frame.gestures().count(); if(general_flag){ SETFLOAT(&generalInfo[0], (float)frame.id()); SETFLOAT(&generalInfo[1], (float)frame.timestamp()); SETFLOAT(&generalInfo[2], (float)num_hands); SETFLOAT(&generalInfo[3], (float)frame.fingers().count()); SETFLOAT(&generalInfo[4], (float)frame.tools().count()); SETFLOAT(&generalInfo[5], (float)frame.gestures().count()); ToOutList(0, 6, generalInfo); } // tools for(int i = 0; i<num_tools; i++){ Tool tool; tool = frame.tools()[i]; t_atom toolInfo[5]; if(tools_position_flag) { SETFLOAT(&toolInfo[0], i); SETSYMBOL(&toolInfo[1], gensym("direction")); SETFLOAT(&toolInfo[2], tool.direction().x); SETFLOAT(&toolInfo[3], tool.direction().y); SETFLOAT(&toolInfo[4], tool.direction().z); ToOutAnything(1, gensym("tool"), 5, toolInfo); } if(tools_position_flag) { SETFLOAT(&toolInfo[0], i); SETSYMBOL(&toolInfo[1], gensym("position")); SETFLOAT(&toolInfo[2], tool.tipPosition().x); SETFLOAT(&toolInfo[3], tool.tipPosition().y); SETFLOAT(&toolInfo[4], tool.tipPosition().z); ToOutAnything(1, gensym("tool"), 5, toolInfo); } if(tools_velocity_flag){ SETFLOAT(&toolInfo[0], i); SETSYMBOL(&toolInfo[1], gensym("velocity")); SETFLOAT(&toolInfo[2], tool.tipVelocity().x); SETFLOAT(&toolInfo[3], tool.tipVelocity().y); SETFLOAT(&toolInfo[4], tool.tipVelocity().z); ToOutAnything(1, gensym("tool"), 5, toolInfo); } if(tools_size_flag){ SETFLOAT(&toolInfo[0], i); SETSYMBOL(&toolInfo[1], gensym("size")); SETFLOAT(&toolInfo[2], tool.width()); SETFLOAT(&toolInfo[3], tool.length()); ToOutAnything(1, gensym("tool"), 4, toolInfo); } } // hands and fingers for(int i = 0; i<num_hands; i++){ Hand hand; hand = frame.hands()[i]; int num_fingers = hand.fingers().count(); int num_tools = hand.tools().count(); t_atom handInfo[5]; if(hands_direction_flag){ // direction SETFLOAT(&handInfo[0], i); SETSYMBOL(&handInfo[1], gensym("direction")); SETFLOAT(&handInfo[2], hand.direction().x); SETFLOAT(&handInfo[3], hand.direction().y); SETFLOAT(&handInfo[4], hand.direction().z); ToOutAnything(1, gensym("hand"), 5, handInfo); } if(hands_palm_position_flag){ // position SETFLOAT(&handInfo[0], i); SETSYMBOL(&handInfo[1], gensym("palm_position")); SETFLOAT(&handInfo[2], hand.palmPosition().x); SETFLOAT(&handInfo[3], hand.palmPosition().y); SETFLOAT(&handInfo[4], hand.palmPosition().z); ToOutAnything(1, gensym("hand"), 5, handInfo); } if(hands_palm_velocity_flag){ // velocity SETFLOAT(&handInfo[0], i); SETSYMBOL(&handInfo[1], gensym("palm_velocity")); SETFLOAT(&handInfo[2], hand.palmVelocity().x); SETFLOAT(&handInfo[3], hand.palmVelocity().y); SETFLOAT(&handInfo[4], hand.palmVelocity().z); ToOutAnything(1, gensym("hand"), 5, handInfo); } if(hands_palm_normal_flag){ // normal SETFLOAT(&handInfo[0], i); SETSYMBOL(&handInfo[1], gensym("palm_normal")); SETFLOAT(&handInfo[2], hand.palmNormal().x); SETFLOAT(&handInfo[3], hand.palmNormal().y); SETFLOAT(&handInfo[4], hand.palmNormal().z); ToOutAnything(1, gensym("hand"), 5, handInfo); } if(hands_sphere_radius_flag){ // sphere radius SETFLOAT(&handInfo[0], i); SETSYMBOL(&handInfo[1], gensym("sphere_radius")); SETFLOAT(&handInfo[2], hand.sphereRadius()); ToOutAnything(1, gensym("hand"), 3, handInfo); } if(hands_sphere_center_flag){ // sphere center SETFLOAT(&handInfo[0], i); SETSYMBOL(&handInfo[1], gensym("sphere_center")); SETFLOAT(&handInfo[2], hand.sphereCenter().x); SETFLOAT(&handInfo[3], hand.sphereCenter().y); SETFLOAT(&handInfo[4], hand.sphereCenter().z); ToOutAnything(1, gensym("hand"), 5, handInfo); } if(hands_finger_count_flag){ // finger count SETFLOAT(&handInfo[0], i); SETSYMBOL(&handInfo[1], gensym("finger_count")); SETFLOAT(&handInfo[2], num_fingers); ToOutAnything(1, gensym("hand"), 3, handInfo); } if(hands_tool_count_flag){ // tool count SETFLOAT(&handInfo[0], i); SETSYMBOL(&handInfo[1], gensym("tool_count")); SETFLOAT(&handInfo[2], num_tools); ToOutAnything(1, gensym("hand"), 3, handInfo); } for(int j = 0; j<num_fingers; j++){ Finger finger; finger = hand.fingers()[j]; t_atom fingerInfo[7]; if(fingers_direction_flag){ SETFLOAT(&fingerInfo[0], i); // index SETSYMBOL(&fingerInfo[1], gensym("fingers")); SETFLOAT(&fingerInfo[2], j); SETSYMBOL(&fingerInfo[3], gensym("direction")); SETFLOAT(&fingerInfo[4], finger.direction().x); SETFLOAT(&fingerInfo[5], finger.direction().y); SETFLOAT(&fingerInfo[6], finger.direction().z); ToOutAnything(1, gensym("hand"), 7, fingerInfo); } if(fingers_position_flag){ SETFLOAT(&fingerInfo[0], i); // index SETSYMBOL(&fingerInfo[1], gensym("fingers")); SETFLOAT(&fingerInfo[2], j); SETSYMBOL(&fingerInfo[3], gensym("position")); SETFLOAT(&fingerInfo[4], finger.tipPosition().x); SETFLOAT(&fingerInfo[5], finger.tipPosition().y); SETFLOAT(&fingerInfo[6], finger.tipPosition().z); ToOutAnything(1, gensym("hand"), 7, fingerInfo); } if(fingers_velocity_flag){ SETFLOAT(&fingerInfo[0], i); // index SETSYMBOL(&fingerInfo[1], gensym("fingers")); SETFLOAT(&fingerInfo[2], j); SETSYMBOL(&fingerInfo[3], gensym("velocity")); SETFLOAT(&fingerInfo[4], finger.tipVelocity().x); SETFLOAT(&fingerInfo[5], finger.tipVelocity().y); SETFLOAT(&fingerInfo[6], finger.tipVelocity().z); ToOutAnything(1, gensym("hand"), 7, fingerInfo); } if(fingers_size_flag){ SETFLOAT(&fingerInfo[0], i); // index SETSYMBOL(&fingerInfo[1], gensym("fingers")); SETFLOAT(&fingerInfo[2], j); SETSYMBOL(&fingerInfo[3], gensym("size")); SETFLOAT(&fingerInfo[4], finger.width()); SETFLOAT(&fingerInfo[5], finger.length()); ToOutAnything(1, gensym("hand"), 6, fingerInfo); } } } t_atom gestureCountInfo[1]; for(int i = 0;i < num_gestures; i++){ Gesture gesture; gesture = frame.gestures()[i]; //type t_atom gestureTypeInfo[3]; SETFLOAT(&gestureTypeInfo[0], i); SETSYMBOL(&gestureTypeInfo[1], gensym("type")); switch(gesture.type()) { case Gesture::TYPE_INVALID: SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_INVALID")); break; case Gesture::TYPE_SWIPE: SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_SWIPE")); break; case Gesture::TYPE_CIRCLE: SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_CIRCLE")); break; case Gesture::TYPE_SCREEN_TAP: SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_SCREEN_TAP")); break; case Gesture::TYPE_KEY_TAP: SETSYMBOL(&gestureTypeInfo[2], gensym("TYPE_KEY_TAP")); break; } ToOutList(2, 3, gestureTypeInfo); //state t_atom gestureStateInfo[3]; SETFLOAT(&gestureStateInfo[0], i); SETSYMBOL(&gestureStateInfo[1], gensym("state")); switch(gesture.state()) { case Gesture::STATE_INVALID: SETSYMBOL(&gestureStateInfo[2], gensym("STATE_INVALID")); break; case Gesture::STATE_START: SETSYMBOL(&gestureStateInfo[2], gensym("TYPE_START")); break; case Gesture::STATE_UPDATE: SETSYMBOL(&gestureStateInfo[2], gensym("STATE_UPDATE")); break; case Gesture::STATE_STOP: SETSYMBOL(&gestureStateInfo[2], gensym("TYPE_STOP")); break; } ToOutList(2, 3, gestureStateInfo); t_atom gestureDurationInfo[3]; SETFLOAT(&gestureDurationInfo[0], i); SETSYMBOL(&gestureDurationInfo[1], gensym("duration")); SETFLOAT(&gestureDurationInfo[2], gesture.duration()); ToOutList(2, 3, gestureDurationInfo); t_atom gestureIdInfo[3]; SETFLOAT(&gestureIdInfo[0], i); SETSYMBOL(&gestureIdInfo[1], gensym("id")); SETFLOAT(&gestureIdInfo[2], gesture.id()); ToOutList(2, 3, gestureIdInfo); } }
/*----------------------------------------------------------------------------------------------------*/ void Gestures::sendGesture(const Gesture& pGesture) { if ( !pGesture.isValid() ) { return; } Gesture::Type type = pGesture.type(); Gesture::State state = pGesture.state(); int64_t duration = pGesture.duration(); Leap::Vector position; Leap::Vector direction; float progress = 0; float speed = 0; float radius = 0; std::string typeKey; std::string stateName; //// if ( type == Gesture::TYPE_CIRCLE ) { CircleGesture circle = (CircleGesture)pGesture; position = circle.center(); progress = circle.progress(); radius = circle.radius(); typeKey = GestureKey::Circle; } else if ( type == Gesture::TYPE_SWIPE ) { SwipeGesture swipe = (SwipeGesture)pGesture; position = swipe.startPosition(); direction = swipe.direction(); speed = swipe.speed(); typeKey = GestureKey::Swipe; } else if ( type == Gesture::TYPE_KEY_TAP ) { KeyTapGesture keyTap = (KeyTapGesture)pGesture; position = keyTap.position(); direction = keyTap.direction(); progress = keyTap.progress(); typeKey = GestureKey::KeyTap; } else if ( type == Gesture::TYPE_SCREEN_TAP ) { ScreenTapGesture screenTap = (ScreenTapGesture)pGesture; position = screenTap.position(); direction = screenTap.direction(); progress = screenTap.progress(); typeKey = GestureKey::ScreenTap; } else { std::cout << "[LEAP] Unsupported gesture type: " << type << std::endl; return; } //// switch ( state ) { case Gesture::STATE_INVALID: stateName = "Invalid"; break; case Gesture::STATE_START: stateName = "Start"; break; case Gesture::STATE_UPDATE: stateName = "Update"; break; case Gesture::STATE_STOP: stateName = "Stop"; break; default: std::cout << "[LEAP] Unsupported state type: " << state << std::endl; return; } //// std::cout << "GESTURE MESSAGE" << "\n - type: " << type << " (" << typeKey << ")" << "\n - stat: " << state << " (" << stateName << ")" << "\n - dura: " << duration << "\n - pos: " << position << "\n - dir: " << direction << "\n - prog: " << progress << "\n - radi: " << radius << "\n - spd: " << speed << "\n" << std::endl; }
FREObject LNLeapDevice::getFrame() { Frame frame = controller->frame(); // TODO: Only continue with valid Frame? FREObject freCurrentFrame; FRENewObject( (const uint8_t*) "com.leapmotion.leap.Frame", 0, NULL, &freCurrentFrame, NULL); FREObject freFrameId; FRENewObjectFromInt32((int32_t) frame.id(), &freFrameId); FRESetObjectProperty(freCurrentFrame, (const uint8_t*) "id", freFrameId, NULL); const Vector frameTranslation = frame.translation(lastFrame); FRESetObjectProperty(freCurrentFrame, (const uint8_t*) "translationVector", createVector3(frameTranslation.x, frameTranslation.y, frameTranslation.z), NULL); const Matrix frameRotation = frame.rotationMatrix(lastFrame); FRESetObjectProperty(freCurrentFrame, (const uint8_t*) "rotation", createMatrix( createVector3(frameRotation.xBasis[0], frameRotation.xBasis[1], frameRotation.xBasis[2]), createVector3(frameRotation.yBasis[0], frameRotation.yBasis[1], frameRotation.yBasis[2]), createVector3(frameRotation.zBasis[0], frameRotation.zBasis[1], frameRotation.zBasis[2]), createVector3(frameRotation.origin[0], frameRotation.origin[1], frameRotation.origin[2]) ), NULL); FREObject freFrameScaleFactor; FRENewObjectFromDouble(frame.scaleFactor(lastFrame), &freFrameScaleFactor); FRESetObjectProperty(freCurrentFrame, (const uint8_t*) "scaleFactorNumber", freFrameScaleFactor, NULL); FREObject freTimestamp; FRENewObjectFromInt32((int32_t) frame.timestamp(), &freTimestamp); FRESetObjectProperty(freCurrentFrame, (const uint8_t*) "timestamp", freTimestamp, NULL); std::map<int, FREObject> freHandsMap; if (!frame.hands().empty()) { FREObject freHands; FREGetObjectProperty(freCurrentFrame, (const uint8_t*) "hands", &freHands, NULL); for(int i = 0; i < frame.hands().count(); i++) { const Hand hand = frame.hands()[i]; FREObject freHand; FRENewObject( (const uint8_t*) "com.leapmotion.leap.Hand", 0, NULL, &freHand, NULL); FRESetObjectProperty(freHand, (const uint8_t*) "frame", freCurrentFrame, NULL); FRESetObjectProperty(freHand, (const uint8_t*) "direction", createVector3(hand.direction()[0], hand.direction()[1], hand.direction()[2]), NULL); FREObject freHandId; FRENewObjectFromInt32(hand.id(), &freHandId); FRESetObjectProperty(freHand, (const uint8_t*) "id", freHandId, NULL); FRESetObjectProperty(freHand, (const uint8_t*) "palmNormal", createVector3(hand.palmNormal()[0], hand.palmNormal()[1], hand.palmNormal()[2]), NULL); FRESetObjectProperty(freHand, (const uint8_t*) "palmPosition", createVector3(hand.palmPosition()[0], hand.palmPosition()[1], hand.palmPosition()[2]), NULL); FRESetObjectProperty(freHand, (const uint8_t*) "palmVelocity", createVector3(hand.palmVelocity()[0], hand.palmVelocity()[1], hand.palmVelocity()[2]), NULL); const Matrix rotation = hand.rotationMatrix(lastFrame); FRESetObjectProperty(freHand, (const uint8_t*) "rotation", createMatrix( createVector3(rotation.xBasis[0], rotation.xBasis[1], rotation.xBasis[2]), createVector3(rotation.yBasis[0], rotation.yBasis[1], rotation.yBasis[2]), createVector3(rotation.zBasis[0], rotation.zBasis[1], rotation.zBasis[2]), createVector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]) ), NULL); FREObject freScaleFactor; FRENewObjectFromDouble(hand.scaleFactor(lastFrame), &freScaleFactor); FRESetObjectProperty(freHand, (const uint8_t*) "scaleFactorNumber", freScaleFactor, NULL); FRESetObjectProperty(freHand, (const uint8_t*) "sphereCenter", createVector3(hand.sphereCenter()[0], hand.sphereCenter()[1], hand.sphereCenter()[2]), NULL); FREObject freSphereRadius; FRENewObjectFromDouble(hand.sphereRadius(), &freSphereRadius); FRESetObjectProperty(freHand, (const uint8_t*) "sphereRadius", freSphereRadius, NULL); const Vector translation = hand.translation(lastFrame); FRESetObjectProperty(freHand, (const uint8_t*) "translationVector", createVector3(translation.x, translation.y, translation.z), NULL); FRESetArrayElementAt(freHands, i, freHand); freHandsMap[hand.id()] = freHand; } } std::map<int, FREObject> frePointablesMap; if(!frame.pointables().empty()) { FREObject frePointables; FREGetObjectProperty(freCurrentFrame, (const uint8_t*) "pointables", &frePointables, NULL); for(int i = 0; i < frame.pointables().count(); i++) { const Pointable pointable = frame.pointables()[i]; FREObject frePointable; if(pointable.isTool()) { FRENewObject( (const uint8_t*) "com.leapmotion.leap.Tool", 0, NULL, &frePointable, NULL); } else { FRENewObject( (const uint8_t*) "com.leapmotion.leap.Finger", 0, NULL, &frePointable, NULL); } FRESetObjectProperty(frePointable, (const uint8_t*) "frame", freCurrentFrame, NULL); FREObject frePointableId; FRENewObjectFromInt32(pointable.id(), &frePointableId); FRESetObjectProperty(frePointable, (const uint8_t*) "id", frePointableId, NULL); FREObject frePointableLength; FRENewObjectFromDouble(pointable.length(), &frePointableLength); FRESetObjectProperty(frePointable, (const uint8_t*) "length", frePointableLength, NULL); FREObject frePointableWidth; FRENewObjectFromDouble(pointable.width(), &frePointableWidth); FRESetObjectProperty(frePointable, (const uint8_t*) "width", frePointableWidth, NULL); FRESetObjectProperty(frePointable, (const uint8_t*) "direction", createVector3(pointable.direction().x, pointable.direction().y, pointable.direction().z), NULL); FRESetObjectProperty(frePointable, (const uint8_t*) "tipPosition", createVector3(pointable.tipPosition().x, pointable.tipPosition().y, pointable.tipPosition().z), NULL); FRESetObjectProperty(frePointable, (const uint8_t*) "tipVelocity", createVector3(pointable.tipVelocity().x, pointable.tipVelocity().y, pointable.tipVelocity().z), NULL); //map to hand & back if(pointable.hand().isValid()) { FREObject freHand = freHandsMap[pointable.hand().id()]; FRESetObjectProperty(frePointable, (const uint8_t*) "hand", freHand, NULL); FREObject frePointables; FREGetObjectProperty(freHand, (const uint8_t*) "pointables", &frePointables, NULL); uint32_t numPointables; FREGetArrayLength(frePointables, &numPointables); FRESetArrayElementAt(frePointables, numPointables, frePointable); FREObject freSpecificHandPointables; if(pointable.isTool()) { FREGetObjectProperty(freHand, (const uint8_t*) "tools", &freSpecificHandPointables, NULL); } else { FREGetObjectProperty(freHand, (const uint8_t*) "fingers", &freSpecificHandPointables, NULL); } uint32_t numSpecificHandTools; FREGetArrayLength(freSpecificHandPointables, &numSpecificHandTools); FRESetArrayElementAt(freSpecificHandPointables, numSpecificHandTools, frePointable); } //push it in current frame FRESetArrayElementAt(frePointables, i, frePointable); //specific FREObject freSpecificPointables; if(pointable.isTool()) { FREGetObjectProperty(freCurrentFrame, (const uint8_t*) "tools", &freSpecificPointables, NULL); } else { FREGetObjectProperty(freCurrentFrame, (const uint8_t*) "fingers", &freSpecificPointables, NULL); } uint32_t numSpecificTools; FREGetArrayLength(freSpecificPointables, &numSpecificTools); FRESetArrayElementAt(freSpecificPointables, numSpecificTools, frePointable); frePointablesMap[pointable.id()] = frePointable; } } if(!frame.gestures().empty()) { FREObject freGestures; FREGetObjectProperty(freCurrentFrame, (const uint8_t*) "gesturesVector", &freGestures, NULL); for(int i = 0; i < frame.gestures().count(); i++) { const Gesture gesture = frame.gestures()[i]; int state; switch (gesture.state()) { case Gesture::STATE_INVALID: state = 0; break; case Gesture::STATE_START: state = 1; break; case Gesture::STATE_UPDATE: state = 2; break; case Gesture::STATE_STOP: state = 3; break; default: break; } int type; FREObject freGesture; switch (gesture.type()) { case Gesture::TYPE_SWIPE: { type = 5; SwipeGesture swipe = gesture; FRENewObject( (const uint8_t*) "com.leapmotion.leap.SwipeGesture", 0, NULL, &freGesture, NULL); FRESetObjectProperty(freGesture, (const uint8_t*) "direction", createVector3(swipe.direction().x, swipe.direction().y, swipe.direction().z), NULL); FRESetObjectProperty(freGesture, (const uint8_t*) "position", createVector3(swipe.position().x, swipe.position().y, swipe.position().z), NULL); FRESetObjectProperty(freGesture, (const uint8_t*) "startPosition", createVector3(swipe.startPosition().x, swipe.startPosition().y, swipe.startPosition().z), NULL); FREObject freSwipeGestureSpeed; FRENewObjectFromDouble(swipe.speed(), &freSwipeGestureSpeed); FRESetObjectProperty(freGesture, (const uint8_t*) "speed", freSwipeGestureSpeed, NULL); break; } case Gesture::TYPE_CIRCLE: { type = 6; CircleGesture circle = gesture; FRENewObject( (const uint8_t*) "com.leapmotion.leap.CircleGesture", 0, NULL, &freGesture, NULL); FRESetObjectProperty(freGesture, (const uint8_t*) "center", createVector3(circle.center().x, circle.center().y, circle.center().z), NULL); FRESetObjectProperty(freGesture, (const uint8_t*) "normal", createVector3(circle.normal().x, circle.normal().y, circle.normal().z), NULL); FREObject freCircleGestureProgress; FRENewObjectFromDouble(circle.progress(), &freCircleGestureProgress); FRESetObjectProperty(freGesture, (const uint8_t*) "progress", freCircleGestureProgress, NULL); FREObject freCircleGestureRadius; FRENewObjectFromDouble(circle.radius(), &freCircleGestureRadius); FRESetObjectProperty(freGesture, (const uint8_t*) "radius", freCircleGestureRadius, NULL); FREObject frePointable = frePointablesMap[circle.pointable().id()]; if(frePointable != NULL) { FRESetObjectProperty(freGesture, (const uint8_t*) "pointable", frePointable, NULL); } break; } case Gesture::TYPE_SCREEN_TAP: { type = 7; ScreenTapGesture screentap = gesture; FRENewObject( (const uint8_t*) "com.leapmotion.leap.ScreenTapGesture", 0, NULL, &freGesture, NULL); FRESetObjectProperty(freGesture, (const uint8_t*) "direction", createVector3(screentap.direction().x, screentap.direction().y, screentap.direction().z), NULL); FRESetObjectProperty(freGesture, (const uint8_t*) "position", createVector3(screentap.position().x, screentap.position().y, screentap.position().z), NULL); break; } case Gesture::TYPE_KEY_TAP: { type = 8; KeyTapGesture tap = gesture; FRENewObject( (const uint8_t*) "com.leapmotion.leap.KeyTapGesture", 0, NULL, &freGesture, NULL); FRESetObjectProperty(freGesture, (const uint8_t*) "direction", createVector3(tap.direction().x, tap.direction().y, tap.direction().z), NULL); FRESetObjectProperty(freGesture, (const uint8_t*) "position", createVector3(tap.position().x, tap.position().y, tap.position().z), NULL); break; } default: { type = 4; FRENewObject( (const uint8_t*) "com.leapmotion.leap.Gesture", 0, NULL, &freGesture, NULL); break; } } FREObject freGestureState; FRENewObjectFromInt32(state, &freGestureState); FRESetObjectProperty(freGesture, (const uint8_t*) "state", freGestureState, NULL); FREObject freGestureType; FRENewObjectFromInt32(type, &freGestureType); FRESetObjectProperty(freGesture, (const uint8_t*) "type", freGestureType, NULL); FREObject freGestureDuration; FRENewObjectFromInt32((int32_t) gesture.duration(), &freGestureDuration); FRESetObjectProperty(freGesture, (const uint8_t*) "duration", freGestureDuration, NULL); FREObject freGestureDurationSeconds; FRENewObjectFromDouble(gesture.durationSeconds(), &freGestureDurationSeconds); FRESetObjectProperty(freGesture, (const uint8_t*) "durationSeconds", freGestureDurationSeconds, NULL); FRESetObjectProperty(freGesture, (const uint8_t*) "frame", freCurrentFrame, NULL); FREObject freGestureId; FRENewObjectFromInt32(gesture.id(), &freGestureId); FRESetObjectProperty(freGesture, (const uint8_t*) "id", freGestureId, NULL); if (!gesture.hands().empty()) { FREObject freGestureHands; FREGetObjectProperty(freGesture, (const uint8_t*) "hands", &freGestureHands, NULL); for(int i = 0; i < gesture.hands().count(); i++) { const Hand hand = gesture.hands()[i]; FREObject freHand = freHandsMap[hand.id()]; FRESetArrayElementAt(freGestureHands, i, freHand); } } if (!gesture.pointables().empty()) { FREObject freGesturePointables; FREGetObjectProperty(freGesture, (const uint8_t*) "pointables", &freGesturePointables, NULL); for(int i = 0; i < gesture.pointables().count(); i++) { const Pointable pointable = gesture.pointables()[i]; FREObject frePointable = frePointablesMap[pointable.id()]; FRESetArrayElementAt(freGesturePointables, i, frePointable); } } //push it in current gesture vector FRESetArrayElementAt(freGestures, i, freGesture); } } lastFrame = frame; return freCurrentFrame; }