示例#1
0
void ofCharacter::animateWalkBackward(){
    if( timeToTransition() ){
        currentPos++;
        if( currentPos >= 16 ) { currentPos = 12; }
    }
}
示例#2
0
void ofCharacter::animateWalkRight(){
    if( timeToTransition() ){
        currentPos++;
        if( currentPos >= 12 ) { currentPos = 8; }    }
}
示例#3
0
void ofCharacter::animateWalkLeft(){
    if( timeToTransition() ){
        currentPos++;
        if( currentPos >= 4 ) { currentPos = 0; }
    }
}
示例#4
0
void ofCharacter::animateWalkForward(){
    if( timeToTransition() ){
        currentPos++;
        if( currentPos >= 8 ) { currentPos = 4; }
    }
}
示例#5
0
float MotionGraphController::getValue(CHANNEL_ID _channel, float _time){
	//if it is not transitioning and its time to loop
	if (!status.isTransitioning &&  timeToTransition(_time))
	{
		//iterateStatus();
		int frame3 = computeCurrentFrame(_time);
		MotionSequence *motion_sequence = returnMotionSequenceContainerFromID(status.SeqID).MS;
		if (motion_sequence == NULL)
			throw AnimationException("MotionSequenceController has no attached MotionSequence");

		if (!isValidChannel(_channel, _time))
		{
			string s = string("MotionSequenceController received request for invalid channel ")
				+ " bone: " + toString(_channel.bone_id) + " dof: " + toString(_channel.channel_type);
			throw AnimationException(s.c_str());
		}

//		int frame3 = computeCurrentFrame(_time);
		//set this for currentFrameCalculations
		last_transition_time = _time;
		last_transition_frame = status.FrameNumberTransitionTo;
		// set the frame number to the frame we transition to.
		status.FrameNumber = status.FrameNumberTransitionTo;

	//	int frame3 = computeCurrentFrame(_time);
		float value = motion_sequence->getValue(_channel, computeCurrentFrame(_time));

		//transition the graph using status information
		// only use when we have matching names of Motion sequences are the same as the filenames of the frames on the graph
		// in this case we need to put the vertex descriptor back to its original spot
		//transitionGraph();
		printStatus();
		//update the status
		iterateStatus();
		printStatus();
		return(value);

	}
	else if (status.isTransitioning &&  timeToTransition(_time))
	{
		MotionSequence *motion_sequence = returnMotionSequenceContainerFromID(status.TransitionToSeqId).MS;
		if (motion_sequence == NULL)
			throw AnimationException("MotionSequenceController has no attached MotionSequence");

		if (!isValidChannel(_channel, _time))
		{
			string s = string("MotionSequenceController received request for invalid channel ")
				+ " bone: " + toString(_channel.bone_id) + " dof: " + toString(_channel.channel_type);
			throw AnimationException(s.c_str());
		}
		//set this for currentFrameCalculations
		last_transition_time = _time;
		last_transition_frame = status.FrameNumberTransitionTo;
		// set the frame number to the frame we transition to.
		status.FrameNumber = status.FrameNumberTransitionTo;

		int frame3 = computeCurrentFrame(_time);
		float value = motion_sequence->getValue(_channel, computeCurrentFrame(_time));

		//transition the graph using status information
		// only use when we have matching names of Motion sequences are the same as the filenames of the frames on the graph
		//transitionGraph();
		printStatus();
		//update the status
		iterateStatus();
		printStatus();
		return(value);
	}
	//not at right time to transition
	else{
		MotionSequence *motion_sequence = returnMotionSequenceContainerFromID(status.SeqID).MS;

		if (motion_sequence == NULL)
			throw AnimationException("MotionSequenceController has no attached MotionSequence");

		if (!isValidChannel(_channel, _time))
		{
			string s = string("MotionSequenceController received request for invalid channel ")
				+ " bone: " + toString(_channel.bone_id) + " dof: " + toString(_channel.channel_type);
			throw AnimationException(s.c_str());
		}
		int frame3 = computeCurrentFrame(_time);
		float value = motion_sequence->getValue(_channel, computeCurrentFrame(_time));
		if (frame3 > status.FrameNumber)
		{

			//printStatus();
		}

		//update status
		status.FrameNumber = frame3;

		// only use when we have matching names of Motion sequences are the same as the filenames of the frames on the graph
		//iterate graph
		//iterateMotionGraph();
	
		return(value);
	}
}