Dynamic visibleDistance based upon model's scale
by Dave Shay · in Torque Game Engine · 05/18/2007 (9:03 am) · 2 replies
Hello,
I'm starting to crawl through the 1.5.x TGE engine source trying to learn how to affect the maximum drawing distance of objects. So far I've learned (mainly by searching through this forum) how to take a "one size fits all" approach and change the visibleDistance.
I've also been able to recompile the engine so that I can have a max visibleDistance greater than the hardcoded max of 2000.
My issue, though, is I would like this setting to be a little more dynamic. Rather than having ALL objects start to "fog out" at 2500, for example, I'd like to do something like this:
If a model has an x/y/z scale <= 0.5/0.5/0.5, then fog it out at 700.
Else if x/y/z/ scale is <= 2.0/2.0/2.0, then fog out at 2000.
Else fog out at 2500.
Doing a global search on visibleDistance yielded quite a few files and methods. I'm not sure if I'm barking up the right tree, though. (There's also farPlane to consider and perhaps other stuff I've missed).
Which is the "correct" source file I can alter to control when an object fogs out or is not rendered?
To make this exercise simpler, I don't care about how the terrain/mission editor works... I'd be fine with the default of 2000 for all models there. This is because I'm accessing a database and dynamically adding objects to the game during runtime, rather than hardcoding everything in the mission file or using the editor.
Thanks for reading!
I'm starting to crawl through the 1.5.x TGE engine source trying to learn how to affect the maximum drawing distance of objects. So far I've learned (mainly by searching through this forum) how to take a "one size fits all" approach and change the visibleDistance.
I've also been able to recompile the engine so that I can have a max visibleDistance greater than the hardcoded max of 2000.
My issue, though, is I would like this setting to be a little more dynamic. Rather than having ALL objects start to "fog out" at 2500, for example, I'd like to do something like this:
If a model has an x/y/z scale <= 0.5/0.5/0.5, then fog it out at 700.
Else if x/y/z/ scale is <= 2.0/2.0/2.0, then fog out at 2000.
Else fog out at 2500.
Doing a global search on visibleDistance yielded quite a few files and methods. I'm not sure if I'm barking up the right tree, though. (There's also farPlane to consider and perhaps other stuff I've missed).
Which is the "correct" source file I can alter to control when an object fogs out or is not rendered?
To make this exercise simpler, I don't care about how the terrain/mission editor works... I'd be fine with the default of 2000 for all models there. This is because I'm accessing a database and dynamically adding objects to the game during runtime, rather than hardcoding everything in the mission file or using the editor.
Thanks for reading!
About the author
#2
For example, the global visibleDistance may be 5000, but I don't want players to be visible beyond 1000, or Item() models with a scale smaller than 1 to be visible beyond 2000.
So thanks for the warning, but my underlying question is still unanswered. :)
05/19/2007 (9:09 am)
I don't want to change the global visibleDistance on the fly. What I'm trying to accomplish is to filter out objects, that would be otherwise visible, due to criteria such as scale or object type (players, static, vehicles, or whatever).For example, the global visibleDistance may be 5000, but I don't want players to be visible beyond 1000, or Item() models with a scale smaller than 1 to be visible beyond 2000.
So thanks for the warning, but my underlying question is still unanswered. :)
Torque Owner Stefan Lundmark