FxSunLight Scale
by Adam Larson · in Torque Game Engine · 01/24/2005 (3:54 pm) · 3 replies
I am using Melv's fxSunLight in the background of one of my menus and I noticed it is independent of the screen resolution. It's not very noticeable in a regular mission, but if you're looking for it, you can tell. As a quick fix, I did this:
Include platform/platformVideo.h in fxSunLight.cc.
Then add the following to the onAdd function after the call to setFlareBitmaps on line 1604 of fxSunLight.cc
This is scaling the size based on height only so the fix won't work right with aspect ratios other than 4:3 and it assumes the base size is relative to a 640x480 resolution.
Edit: The call to dglGetPixelScale on line 1828 scales the billboard so that it is independent of screen resolution. Removing this call will give you a sun that gets bigger with a higher resolution. Much nicer fix than the one I posted above.
Include platform/platformVideo.h in fxSunLight.cc.
Then add the following to the onAdd function after the call to setFlareBitmaps on line 1604 of fxSunLight.cc
Resolution currentRes = Video::getResolution(); F32 scale = (float)currentRes.h / 480.0f; mFlareSize *= scale; mMinSize *= scale; mMaxSize *= scale;
This is scaling the size based on height only so the fix won't work right with aspect ratios other than 4:3 and it assumes the base size is relative to a 640x480 resolution.
Edit: The call to dglGetPixelScale on line 1828 scales the billboard so that it is independent of screen resolution. Removing this call will give you a sun that gets bigger with a higher resolution. Much nicer fix than the one I posted above.
About the author
#2
Thanks for the help!
01/25/2005 (3:49 pm)
That actually was the problem I was having. I don't want it to be independent of screen resolution since I am using it as the actual image of the sun as opposed to a lens flare effect. Removing the call to dglGetPixelScale fixed this for me in a much nicer way than my ugly hack I posted above.Thanks for the help!
Associate Melv May
BBRadius = (Distance / dglGetPixelScale()) / 2;
I think "dglGetPixelScale()" is the scale of 640 pixels. Hey, nothing was documented in the code when I did this so it was seat-o-the-pants stuff. ;)
I haven't looked but as far as I remember, sort this line out and it will be independant of screen-res.
There are several other problems with the code that have become apparent now that things have moved along a little. The fxSunlight stuff should be converted to use a system similar to the fxLight stuff. Particularly so that it renders through portals correctly as well as not being dependant upon the control-object.
- Melv.