Aaron Levy
Medicated Lately?
Join date: 3 Jun 2004
Posts: 2,147
|
11-21-2005 13:28
Ok, what I'm working on is something that has a progress bar in it. I have a texture that I can change the offset of to make the progress bar show progress, but I am not good at the math needed to make it scale automatically. Basically, when the Vertical Offset is is -0.20 it's at 0%... when it's at +2.0, it's at 100%. Can someone write me up some code to calculate what I need to set the offset at if I feed it the percentage? Like if I can calculate that the progress bar should be at 44.2% done, what offset should I set the texture to? I would be willing to pay a little bit for this, if it comes to it.  Thanks!
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
11-21-2005 13:38
I think this should do it:
offset = -0.2 + (2.2 * progress); //progress is a float between 0.0 and 1.0
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
|
11-21-2005 13:39
Hehe, Seifert beat me to it!  float percentage; float textureoffset; // At the header of the script we'll define these. Within your script you'll assign values to percentage. Then I'd make a function like... updateloadtime() { textureoffset = percentage * 2.2; textureoffset = textureoffset -0.2; } // Then have your script set percentage to say 44.2, and call the function updateloadtime()...
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
11-21-2005 13:49
Careful with percentages - you'd need to divide by 100.0 at some point ;-p.
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
Aaron Levy
Medicated Lately?
Join date: 3 Jun 2004
Posts: 2,147
|
11-21-2005 14:39
Thanks! It's working great!
|