Example #1
0
//--------------------------------------------------------------
void testApp::update()
{
	kinect.update();

	if(kinect.isNewSkeleton()) {
		for( int i = 0; i < kinect.getSkeletons().size(); i++) 
		{

			if(kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HEAD) != kinect.getSkeletons().at(i).end())
			{

				// just get the first one
				SkeletonBone headBone = kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HEAD)->second;
				SkeletonBone lHandBone = kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HAND_LEFT)->second;
				SkeletonBone rHandBone = kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HAND_RIGHT)->second;
				ofVec3f hb( headBone.getScreenPosition().x, headBone.getScreenPosition().y, 0 );
				head = head.getInterpolated(hb, 0.5);
				head.z =  ofInterpolateCosine( head.z, headBone.getStartPosition().x, 0.5) + 0.1;
				ofVec3f lhb(lHandBone.getScreenPosition().x, lHandBone.getScreenPosition().y, 0);
				lHand = lHand.getInterpolated( lhb, 0.5);
				lHand.z = ofInterpolateCosine( lHand.z, lHandBone.getStartPosition().x, 0.5);
				ofVec3f rhb(rHandBone.getScreenPosition().x, rHandBone.getScreenPosition().y, 0);
				rHand = rHand.getInterpolated( rhb, 0.5);
				rHand.z = ofInterpolateCosine( rHand.z, rHandBone.getStartPosition().x, 0.5);

				cout << headBone.getScreenPosition()  << endl;
				cout << rHandBone.getScreenPosition() << endl;
				cout << lHandBone.getScreenPosition() << endl;

				//cout << kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HEAD)->second.getScreenPosition() << endl;
				//cout << kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HAND_LEFT)->second.getScreenPosition() << endl;
				//cout << kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HAND_RIGHT)->second.getScreenPosition() << endl;

				jointDistance = head.distance(rHand);
				jointDistance += lHand.distance(rHand);
				jointDistance += lHand.distance(head);

				hasSkeleton = true;

				return;
			}
		}
	}
}
Example #2
0
 void update(){
     if(isGrow){
         pct += pctSpeed;
     }else{
         pct -= pctSpeed;
     }
     isAnimating = true;
     
     if(pct<0){
         isFinished = true;
         isAnimating = false;
     }
     if(pct>1){
         isAnimating = false;
     }
     pct = ofClamp(pct, 0, 1);
     resultValue = ofInterpolateCosine(valueMin, valueMax, pct+pctOffset);
 }