Hi,
I've just started using your API (C++, v 3.1.3), so maybe I'm doing something wrong, but I don't know... I've really got some weird behaviour here. I'm trying to get the tip position of thumb and index finger, so I tried this:
hand.finger( Leap::Finger::TYPE_THUMB ).tipPosition();
...and the same with TYPE_INDEX of course. I noticed this always returns a vector of [0 0 0], so I had a look at the valid flag:
hand.finger( Leap::Finger::TYPE_THUMB ).isValid()
which returned 'false'. This was weird, since I'm drawing a debug view of my hand for a while, without ever noticing any problems. There, I am iterating over the hand's fingers, using the FingerList. Now, I tried around a bit and ended up with this bit of code, returning contradicting values for both valid flag and position:
bool thumbValid = hand.finger( Leap::Finger::TYPE_THUMB ).isValid(); //<-- false
Leap::Vector tip0 = hand.finger( Leap::Finger::TYPE_THUMB ).tipPosition(); //<-- [0 0 0]
Leap::Vector tip1 = hand.finger( Leap::Finger::TYPE_THUMB ).bone( Leap::Bone::TYPE_DISTAL ).nextJoint(); //<-- [0 0 0]
Leap::FingerList &fingers = hand.fingers();
for( Leap::FingerList::const_iterator it = fingers.begin(); it != fingers.end(); ++it )
{
if( ( *it ).type() == Leap::Finger::TYPE_THUMB )
{
bool valid = ( *it ).isValid(); //<-- true
Leap::Vector tip2 = ( *it ).tipPosition(); //<-- [-40 202 48]
Leap::Vector tip3 = ( *it ).bone( Leap::Bone::TYPE_DISTAL ).nextJoint(); //<-- [-43 195 45]
Leap::Vector tip4 = ( *it ).jointPosition( Leap::Finger::JOINT_TIP ); //<-- [-43 195 45]
}
}
I realize jointPosition( JOINT_TIP ) is deprecated, note however, that it returns the same value as bone( TYPE_DISTAL ).nextJoint(), while tipPosition() does not.
What's the deal here? Thanks!