PDA

View Full Version : Rotating HUDS



Ni3ls
30th October 2014, 16:54
y'all talking about rotating huds etc. I wonder how to achieve this and somebody post an example of it?

maxdamage99
30th October 2014, 18:21
Maybe I will not understand because of the language barrier), but could you tell more precisely in what sense "rotating"?
To top of your feet?))

IzNoGoD
30th October 2014, 18:26
No need to manually create a lot of rotated images anymore :)


How-to (quick n dirty):
- You need to have an image that already is in .iwi, preferably square (non-square images get stretched)
- Name it something with exactly 15 letters.
- Create a background for this image, same size as the image used above (also square). Give it a 9 char name.
- Now for the tricky part. Find the material files called "hudstopwatch" and "hudstopwatchneedle" and rename the first one to whatever you like (12 chars though), and rename the second one to exactly the same name, but add "needle" to the end. (so a total of 18 chars)
- Open up both files in some program like notepad++. Scroll to the end of the file, notice the hudstopwatchneedle and stopwatchneedle for the "hudstopwatchneedle" file.
Replace the first of those references with the name of the material file (18 char, ending in needle) and the second with the name of the actual image file that has to be rotated (15 char).
Do the same for the other material file, but remember to use the 12 and 9 char filenames here
- Now put the images and the material files in the appropriate folders
- Take a look at sd.gsc: see that both hudstopwatch and hudstopwatchneedle shaders are being precached.
This means you have to precache both YOUR images too
- Scroll to the following part in sd.gsc:


showPlayerBombTimer()
{
timeleft = (level.bombtimer - (getTime() - level.bombtimerstart) / 1000);

if(timeleft > 0)
{
self.bombtimer = newClientHudElem(self);
self.bombtimer.x = 6;
self.bombtimer.y = 76;
self.bombtimer.horzAlign = "left";
self.bombtimer.vertAlign = "top";
self.bombtimer setClock(timeleft, level.bombtimer, "hudStopwatch", 48, 48);
}
}

The most important line here is:


self.bombtimer setClock(timeleft, level.bombtimer, "hudStopwatch", 48, 48);

Take a look at the appropriate reference for this function:
http://www.zeroy.com/script/hud/setclock.htm
If you set the full time really high and reset the clock every 0.05 seconds, you can control the angle your image is held under, or just give it a spin with a low total time and let it just go round.

This opens up a LOT of possibilities for modders.

PS: this write-up was done really quick, and should not be made a reference for future generations. If someone has some time to spare and feels like doing a rewrite: please feel free to do so.

For all hungarian readers: if you do not understand a word i said above, please, feel free to NOT contact me about this. You wont understand me then either.

For all dogs reading this: bark bark bark. Good dog

quoting myself from modsonline.com

Tally
31st October 2014, 13:47
In COD4, they do a rotating hud element like this:



{
precacheShader( "icon_0" );
precacheShader( "icon_1" );
precacheShader( "icon_2" );
precacheShader( "icon_3" );
precacheShader( "icon_4" );
precacheShader( "icon_5" );

}

{
self.nuke_icon = newClientHudElem(self);
self.nuke_icon.x = 143;
self.nuke_icon.y = 98;
self.nuke_icon.alignx = "center";
self.nuke_icon.aligny = "middle";
self.nuke_icon.horzAlign = "fullscreen";
self.nuke_icon.vertAlign = "fullscreen";
self.nuke_icon.glowColor = (0.2, 0.3, 0.7);
self.nuke_icon.glowAlpha = 1;
self.nuke_icon.alpha = .9;
self.nuke_icon.sort = 100;
self.nuke_icon.foreground = true;
self.nuke_icon thread rotatingNukeIcon();
}

rotatingNukeIcon()
{
self endon("death");

iconNumber = 0;

for( ;; )
{
if( isDefined( self ) )
self setShader( "icon_" + iconNumber, 32, 32 );

iconNumber++;

if( iconNumber > 5 ) iconNumber = 0;

wait( 0.08 );
}
}


So, your shader files are stages of an animation. A quick and easy way to create these is to do the first one in the animation, the very last one in the animation, then find a site that creates GIF files from your before and after images (these sites use a tween engine to interpolate all the between images from the first stage and the last stage). Then, open the gif in ImageReady and save each individual frame as a .DDS file. Create your materials and IWI files from these.

FYI - doing animated images in the Q3 engine was easy. This is an animated flag waving:


americanflag
{
nopicmip
nomipmaps
{
AnimMap 10
map gfx/flags/usa_1.tga
map gfx/flags/usa_2.tga
map gfx/flags/usa_3.tga
map gfx/flags/usa_4.tga
map gfx/flags/usa_5.tga
map gfx/flags/usa_6.tga
map gfx/flags/usa_7.tga
map gfx/flags/usa_8.tga
map gfx/flags/usa_9.tga
map gfx/flags/usa_10.tga

blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen vertex
}
}

php
31st October 2014, 14:39
Or for Q3/CoD1 just use the SetClock or use a tcMod shader rotate.

Tally
31st October 2014, 15:29
Or for Q3/CoD1 just use the SetClock or use a tcMod shader rotate.

I think you've missed the wood for the trees.

php
31st October 2014, 16:39
I think you've missed the wood for the trees.

I think you've missed the tree for the forest.

IzNoGoD
31st October 2014, 17:41
I think i have no clue what you guys are trying to say...

Tally
31st October 2014, 17:49
I think you've missed the tree for the forest.

Not at all Pal. I was saying I wished it were easier to make animated shaders - whether rotating or waving or scrolling - in COD2 like it was in Q3. You came along and added details of how to do yet more rotating icons in Q3. Which was completely beside my point and not really relevant to the discussion.

serthy
31st October 2014, 19:58
in CoD1 you can just use hud.angle...
look at the stock files in the bombermission (https://www.youtube.com/watch?v=7R9JzT-66Yg) (I dont remember the actual script name), the plane damage-icon in the compass is done this way, unfortunately they removed this feature
in CoD2: you can also combine WINDOW_STYLE_DVAR_SHADER and changing cvars with image names, this way I did the mw2 icons in the hud