end_blend/ent_blendframe

Posted By: 3dworld

end_blend/ent_blendframe - 08/09/15 23:54

Hi everyone,

I've spend countless hours trying to achieve a convincing smooth blend animation between frames using vertex animation.
Searched AUM and the forum without result, everyone seems to be giving incomplete answer and so far nobody was able to replay.
AUM is pretty much incomplete and manual doesn't say much about it.

Here is my piece of code. Any help is highly appreciated:

Concept - The player move towards specific direction a vector, if the distance between the player and the vector is less than 90, transition from the run animation into walk animation smoothly:

Code:
action player()
{	
	player = me; // copy the entity pointer to the global player pointer
   ... // more code

	while (1){

		if(mouse_left){
			
			vec_to_angle(my.pan, target_distance);
			my.tilt = 0; // don't change player's tilt angle, though
			
         // move the player while the ditance is higher that 45
			while((vec_dist(my.x,hit_coords.x) > 45){
				
				if (vec_dist(my.x,hit_coords.x) < 90){ // if the distance from the player to the target is less than 90,transition animation to walk
					
					ent_animatefrom(me,me,"run",50,ANM_CYCLE);
					ent_blendframe(me,me,"walk",0,25);

					ent_animate(my, "walk", walk_percentage, NULL); // then play the "run" animation
					walk_percentage += 4 * time_step; // 7 = "run" animation speed
					walk_percentage %= 100;
					dist_ahead = 2 * time_step;
				}
				
				else{
					
					dist_ahead = 7 * time_step;
					ent_animate(my, "run", anim_percentage, ANM_CYCLE); // then play the "run" animation
					anim_percentage += 7 * time_step; // 7 = "run" animation speed
					anim_percentage %= 100;
					walk_percentage = 0;
					
				}
				
				... // more code
						
				c_move(me,vector(dist_ahead,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE | SCAN_TEXTURE); // move the player
				
				wait(1);
				
			}
		}
		
		wait(1);	
		
	}
}



I've excluded the part of the code that calculates the distances etc., since that one is working just fine,
but basically that's the section that takes care of the animation transition. It looks like the animation just snaps, instead of having an smooth transition.

I've look into the Kingdom of Hearts animation, but is just wait to much code for such a simple thing.
Also, look into the Diverse Movement Code, but nothing.

Thanks in advance. Pardon my frustration frown .
Posted By: Superku

Re: end_blend/ent_blendframe - 08/10/15 15:17

Quote:
For vertex scenes, the instruction only sets the entity's frame and next_frame parameters. For bones scenes, the instruction blends the entity's skeleton between the scenes.
As vertex animation can only blend between two frames, not between three or more, ent_blend can not interpolate between two already-interpolated frames. The source and target frames are not interpolated, but 'snapped' to the next full frame number.


Some snapping is inevitable when using vertex animations. It's better to create some transitional animations yourself, for instance from "walk" at 0% to "stand", and then do something as follows:

if(abs(movement) < 5 or your dist close)
{
if(walk_percentage < 50) walk_percentage = maxv(walk_percentage-2*time_step,0);
if(walk_percentage > 50) walk_percentage = minv(walk_percentage+2*time_step,100);
ent_animate(me,"walk",walk_percentage,ANM_CYCLE);
if(walk_percentage == 0 || walk_percentage == 100)
{
blend_percentage = minv(blend_percentage+2*time_step,100);
ent_blendframe(me,my,"stand",0,blend_percentage); //maybe mixed up the parameters
}
}


Btw. I'm not sure what's the reasoning behind your following 3 lines of code, you are just "overwriting" or undoing stuff that way:
ent_animatefrom(me,me,"run",50,ANM_CYCLE);
ent_blendframe(me,me,"walk",0,25);
ent_animate(my, "walk", walk_percentage, NULL);
Posted By: 3dworld

Re: end_blend/ent_blendframe - 08/10/15 22:13

Thanks Superku,

I'll give it a run, and I'll post back the results.
What was happening is that after the animation blend the character just stops the animation, it kept moving until the distance was reached, but without animation, so basically those 3 lines were a hack for animation to continue... not good code practice I have to admit, but it did the job.

I'll let you know what comes out after I modify my code.

Thanks again.
Posted By: 3dworld

Re: end_blend/ent_blendframe - 08/11/15 20:30

Hi Superku,
I ran the code with your mod, assuming abs(movement) equals to run_percentage. I’m still having the same issue as before with the spanning animation.

Let me explain a little bit how the model is animated, maybe this can shine some light on this.
I've created a transition animation from "run" to "stop", as you recommended. - thanks.
The model I'm using is actually animated using bones, so basically "stop" and "run" are 2 different scenes inside MDL, but both use bones to animate the model.
The animation keeps "snapping" while using ent_blendframe or ent_blend, even though I'm using bones.

Another test I ran was creating a transition animation, as I mentioned before, using bones as well for the animation inside MED(scene name "stop"), but the snapping keeps happening.

I've change the code a bit:

Code:
while(1){

	if(dist not reached)
	{
		if(your dist close)
		{
			if(abs(run_percentage) >= 100){ // wait for the run animation to complete
			
				if(stop_percentage < 50) stop_percentage = maxv(stop_percentage-2*time_step,0);
				if(stop_percentage > 50) stop_percentage = minv(stop_percentage+2*time_step,100);
				
				ent_animate(me,"stop",stop_percentage,ANM_CYCLE);
				if(stop_percentage == 0 || stop_percentage == 100)
				{
					blend_percentage = minv(blend_percentage+2*time_step,100);
					ent_blendframe(me,my,"stand",0,blend_percentage); //maybe mixed up the parameters
				}
			}
		}
		
		... // code - move the player until the distance has been reached
	}
	else{
		play idle animation 
	}
	run_percentage = 0;
	stop_percentage = 0;
	
	wait(1);
}



I don't know what I'm doing wrong. Sometimes it plays the stop animation with the ugly spanning whether the previous animation was completed or not, or it just complete stops the animation and the player just keeps running but without animation (it basically stops the run animation at the last frame when the distance is close) until the distance has been reach.

Thanks again for your help.
Posted By: 3dworld

Re: end_blend/ent_blendframe - 08/18/15 00:38

I've ended up using a mod from the old Kingdom of Hearts movement which uses a really smooth vertex animation. Still doing some refines to the code, but is pretty much ready.

Thanks.
© 2024 lite-C Forums