Gamestudio Links
Zorro Links
Newest Posts
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 502 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
end_blend/ent_blendframe #453721
08/09/15 23:54
08/09/15 23:54
Joined: Sep 2007
Posts: 173
USA, Florida
3dworld Offline OP
Member
3dworld  Offline OP
Member

Joined: Sep 2007
Posts: 173
USA, Florida
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 .


No matter what people tell you,  words and ideas can change the world.
Re: end_blend/ent_blendframe [Re: 3dworld] #453740
08/10/15 15:17
08/10/15 15:17
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
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);


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: end_blend/ent_blendframe [Re: Superku] #453748
08/10/15 22:13
08/10/15 22:13
Joined: Sep 2007
Posts: 173
USA, Florida
3dworld Offline OP
Member
3dworld  Offline OP
Member

Joined: Sep 2007
Posts: 173
USA, Florida
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.


No matter what people tell you,  words and ideas can change the world.
Re: end_blend/ent_blendframe [Re: 3dworld] #453768
08/11/15 20:30
08/11/15 20:30
Joined: Sep 2007
Posts: 173
USA, Florida
3dworld Offline OP
Member
3dworld  Offline OP
Member

Joined: Sep 2007
Posts: 173
USA, Florida
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.


No matter what people tell you,  words and ideas can change the world.
Re: end_blend/ent_blendframe [Re: 3dworld] #453882
08/18/15 00:38
08/18/15 00:38
Joined: Sep 2007
Posts: 173
USA, Florida
3dworld Offline OP
Member
3dworld  Offline OP
Member

Joined: Sep 2007
Posts: 173
USA, Florida
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.


No matter what people tell you,  words and ideas can change the world.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1