Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 801 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Blend 2 animations #403786
06/26/12 03:43
06/26/12 03:43
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I've found out that in first half-life there are only two animations for making player aim up and down, so at the end, they just blend between them and that makes character aim at the center. I tried to do something like that myself as well, but I failed by getting some weird results grin Here are the screens of the positions:
Quote:
aim up:

aim down:
So what I want now, is to blend between those animations, and make character aim straight forward.
I used to blend between three animations, when my model had additional "aim_center" animations..
But I need to do this without a third animation, I wonder maybe someone has an idea.
Here is the code I try to use currently:
Code:
function blend_test(){
	// aim at the center:
	my.skill5 = 50;
	// main loop:
	while(1){
		// rest animations:
		ent_animate(my, NULL, 0, 0); 
		// go throw the animations:
		my.skill2 += time_step * 2;
		// blend between animations via Q and E keys:
		my.skill5 += key_q - key_e;   
		my.skill5 = clamp(my.skill5, 0, 100); 
		// if skill5 is less than 50 % then we aim up:
		if(((50 - my.skill5) * 2) > 0){
			my.skill3 = (50 - my.skill5) * 2;  
		}   
		// if skill5 is more than 50 % then we aim down:
		if(((50 - my.skill5) * 2) < 0){
			my.skill4 = abs((50 - my.skill5) * 2); 
		} 
		// blend animations:
		ent_blendframe(my, my, "aim_up", my.skill2, my.skill3);
		ent_blendframe(my, my, "aim_down", my.skill2, my.skill4);
		wait(1);
	}
}




Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Blend 2 animations [Re: 3run] #403790
06/26/12 07:58
06/26/12 07:58
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
been a while, but if I recall correctly, you need to reset the bones before you can blend them, so blending between 3 animations is gonna be difficult tongue

However, I'm wondering why you dont just use 1 animation (aim forward) and rotate the spine by code to make him aim anywhere?


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Blend 2 animations [Re: Helghast] #403791
06/26/12 08:32
06/26/12 08:32
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
For that you better use ent_blendpose. It allows to blend between any number of animation poses. So what you do is simply setting the entities pose parameter to 2, animate the "aim up" part of it, then set the pose parameter to 3, animate the "aim down", then do a ent_blendpose of pose 2 and 3 by 50 percent and finally copy the pose into pose 1 to make it visible.
Something like this:

Code:
function entityAim(ENTITY* ent, var percent)
{
        my = ent;
	
	my.pose = 2;
	ent_animate(my,"aimUp",100,ANM_CYCLE);
	
	my.pose = 3;
	ent_animate(my,"aimDown",100,ANM_CYCLE);
	
	ent_blendpose(my,2,3,percent);
	ent_blendpose(my,1,2,100);
	

}



Now, if you call this function with a percent value of 50, you should have the straight aiming, if you call it with a percent value of zero you should have aiming up, and with a percent value of 100 aiming down. Any values between these will result in interpolations.
However, this is just typed out of nothing, not sure if it works flawlessly. And of course you still have to calculate the percent from somewhere else, and if you wanna have additive animations (to do this while the entity is standing, running, walking, whatever) you'd have to add that. However, this is the rough idea how it could work.

EDIT: oh, and this only works with bones as far as I recall, however I guess you're using bones anyways.

Last edited by the_clown; 06/26/12 08:33.
Re: Blend 2 animations [Re: the_clown] #403797
06/26/12 10:46
06/26/12 10:46
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Helghast@ I don't use it, simply cause I don't have such model grin And I'm not able to animate it myself as well. BTW, it's not that really hard to blend between three animations, from 1 to 2 and from 2 into 3 (up, center, down) laugh

the_clown@ I got the same result already, with the script above (only one "ent_animate" line is missing).
Result isn't really good.. It doesn't look as it should grin And yes, I'm using bone animations.

Here is the screen for you guys to see:

Still, I have no idea why thins happens, cause in half-life game, this works perfect.. Any other ideas?
And thank you for your time guys.

Edit: here is, how should it looks like:



Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Blend 2 animations [Re: 3run] #403812
06/26/12 19:53
06/26/12 19:53
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
Don't think what you are doing on will work. It will blend down to Aim Down or up to Aim Up, but will never end up at Aim Center like you are trying to achieve. You can blend from Aim Up or Aim Down to Aim Center animation though.

Loco


Professional A8.30
Spoils of War - East Coast Games
Re: Blend 2 animations [Re: Locoweed] #403814
06/26/12 19:54
06/26/12 19:54
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Hey Locoweed, I see your point. But how to blend into Aim Center? Poke me in the right direction pls :>


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Blend 2 animations [Re: 3run] #403816
06/26/12 20:11
06/26/12 20:11
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
As the manual says about end_blendpose:

Quote:
Blending by linear interpolation computes intermediate vertex positions rather than intermediate bones angles. Thus it produces the best results when the bones angles of source and target pose are not too different, like less than 90 degrees


So, blending by frames is done in the end by interpolation the positions of the vertices rather than rotating actually the bones. That is the reason why your image looks weird. --- Maybe Valve implemented a complex blending by interpolation the bone positions/angles via quaternions and recalculation of the vertices.

Nevertheless, you should add more frames inbetween - Gamestudio can't provide IK so it would always look strange, imho.

Last edited by HeelX; 06/26/12 20:12.
Re: Blend 2 animations [Re: HeelX] #403818
06/26/12 20:15
06/26/12 20:15
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: HeelX
Maybe Valve implemented a complex blending by interpolation the bone positions/angles via quaternions and recalculation of the vertices.
I hope you are wrong and GS could handle such stuff frown
Do you mean "aim_center" by "more frames inbetween"??

Thank you all for your time guys, I really appreciate it!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Blend 2 animations [Re: 3run] #403821
06/26/12 21:09
06/26/12 21:09
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Bones animation just stores the skeleton and the associated vertices and the frames. This way, you save lots of memory and you can do independent stuff with bones. Vertex recalculation on intermediate, blended bone poses was never not supported.

Re: Blend 2 animations [Re: HeelX] #403842
06/27/12 09:31
06/27/12 09:31
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
So this isn't possible with gs?


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Page 1 of 2 1 2

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