CtrlAltDestroy
June 20th, 2010, 05:20 PM
As some of you may be aware, the animation graph field in the projectile tag doesn't do anything:
http://img97.imageshack.us/img97/8038/75562281.jpg
So, I developed a little work around.
Pros:
Animations are cool.
Cons:
Can't animate markers, meaning things like smoke trails and whatnot won't sync with the model's animation.
Polycount increases with each frame of the animation. LODs fix this though.
Take your model--I'll be using Infinity Ward's throwing knife from Modern Warfare 2:
http://img688.imageshack.us/img688/3074/98320569.jpg
Duplicate your model for each frame of your animation, and position/rotate/scale/fuck around with each 'frame' accordingly:
http://img202.imageshack.us/img202/2338/14841491.gif
**Note: Your frame count should be a power of two ideally (for example, I have a total of 8 frames above), unless you want to get creative with your texture's dimensions--which I won't get into... just stick to a power of two.
Take your model's texture:
http://img149.imageshack.us/img149/2075/59913501.jpg
... and tile it horizontally by the number of frames you have:
http://img149.imageshack.us/img149/6564/23927513.jpg
Remember how I said your frame count should be a power of two? Yeah, this is why.
Re-UV each 'frame' of your animation to the new texture accordingly:
http://img149.imageshack.us/img149/7518/49215228.jpg
Then, black out all but the first frame in your texture (make sure you do so with your alpha channel as well):
RGB:
http://img823.imageshack.us/img823/3544/44354056.jpg
Alpha:
http://img819.imageshack.us/img819/2135/78775148.jpg
Your model should look something like this now:
http://img517.imageshack.us/img517/4117/52611468.jpg
**Note: The black areas will appear completely transparent ingame.
OK, export your model/compile your bitmaps and all that noise. Open up your model's shader_model tag:
http://img249.imageshack.us/img249/8208/93376168.jpg
The u-animation source should be 'A out', and the function should be 'one' (default). Your scale should be set to -1 repeats, otherwise your projectile will animate backwards.
Now, onto the projectile tag...
Here's what your A out function should look like:
http://img189.imageshack.us/img189/7363/67584109.jpg
The function should be set to slide. Your period dictates how long the entire animation takes to make one loop. I have it set to 0.2, therefore each frame lasts 0.2/8 = 0.025 seconds (40 fps). Your step count should be your frame count plus one. What this does is quantize your texture scrolling animation such that each 'shift' moves the texture over by one tile, as opposed to smoothly scrolling it (bad).
** OPTIONAL
If your projectile becomes embedded into a surface after it impacts something, as opposed to detonating/disappearing (i.e.: the throwing knife), then you probably don't want the projectile to continue animating after it becomes embedded:
In your A out function:
http://img208.imageshack.us/img208/4088/69158957.jpg
... set the scale result by to 'B out'.
This is what your B out function should look like:
http://img63.imageshack.us/img63/5884/79686557.jpg
... and the rest of the projectile tag:
http://img337.imageshack.us/img337/5416/49238924.jpg
I hope the functionality of this... function should be intuitive to figure out. Basically, what this means is, if the projectile is not airborne, don't animate.
And voila:
http://img256.imageshack.us/img256/3842/knife.gif
http://img97.imageshack.us/img97/8038/75562281.jpg
So, I developed a little work around.
Pros:
Animations are cool.
Cons:
Can't animate markers, meaning things like smoke trails and whatnot won't sync with the model's animation.
Polycount increases with each frame of the animation. LODs fix this though.
Take your model--I'll be using Infinity Ward's throwing knife from Modern Warfare 2:
http://img688.imageshack.us/img688/3074/98320569.jpg
Duplicate your model for each frame of your animation, and position/rotate/scale/fuck around with each 'frame' accordingly:
http://img202.imageshack.us/img202/2338/14841491.gif
**Note: Your frame count should be a power of two ideally (for example, I have a total of 8 frames above), unless you want to get creative with your texture's dimensions--which I won't get into... just stick to a power of two.
Take your model's texture:
http://img149.imageshack.us/img149/2075/59913501.jpg
... and tile it horizontally by the number of frames you have:
http://img149.imageshack.us/img149/6564/23927513.jpg
Remember how I said your frame count should be a power of two? Yeah, this is why.
Re-UV each 'frame' of your animation to the new texture accordingly:
http://img149.imageshack.us/img149/7518/49215228.jpg
Then, black out all but the first frame in your texture (make sure you do so with your alpha channel as well):
RGB:
http://img823.imageshack.us/img823/3544/44354056.jpg
Alpha:
http://img819.imageshack.us/img819/2135/78775148.jpg
Your model should look something like this now:
http://img517.imageshack.us/img517/4117/52611468.jpg
**Note: The black areas will appear completely transparent ingame.
OK, export your model/compile your bitmaps and all that noise. Open up your model's shader_model tag:
http://img249.imageshack.us/img249/8208/93376168.jpg
The u-animation source should be 'A out', and the function should be 'one' (default). Your scale should be set to -1 repeats, otherwise your projectile will animate backwards.
Now, onto the projectile tag...
Here's what your A out function should look like:
http://img189.imageshack.us/img189/7363/67584109.jpg
The function should be set to slide. Your period dictates how long the entire animation takes to make one loop. I have it set to 0.2, therefore each frame lasts 0.2/8 = 0.025 seconds (40 fps). Your step count should be your frame count plus one. What this does is quantize your texture scrolling animation such that each 'shift' moves the texture over by one tile, as opposed to smoothly scrolling it (bad).
** OPTIONAL
If your projectile becomes embedded into a surface after it impacts something, as opposed to detonating/disappearing (i.e.: the throwing knife), then you probably don't want the projectile to continue animating after it becomes embedded:
In your A out function:
http://img208.imageshack.us/img208/4088/69158957.jpg
... set the scale result by to 'B out'.
This is what your B out function should look like:
http://img63.imageshack.us/img63/5884/79686557.jpg
... and the rest of the projectile tag:
http://img337.imageshack.us/img337/5416/49238924.jpg
I hope the functionality of this... function should be intuitive to figure out. Basically, what this means is, if the projectile is not airborne, don't animate.
And voila:
http://img256.imageshack.us/img256/3842/knife.gif