XRay Shader

XRay Shader

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Acidd_UK
Posts: 963
Joined: 23 Apr 2006, 02:15

XRay Shader

Post by Acidd_UK »

Right then, I noticed the Xray shader is still rendering the xray outline of the units even when the normal render of the units is using the custom icons. So I thought this would be a good excuse for me to learn some Lua hacking!

I had a look at the healthbars widget to see how to make the decision to render the full bars, the cut down ones, or nothing at all and it's a reasonably simple distance calculation between the camera and the unit/feature. All good so far. However, in my spring settings, my unit icon draw distance is set to 129. However, the healthbars widget uses code like this:

Code: Select all

local infoDistance = 700000
<snip>
cx, cy, cz = GetCameraPosition()
<snip>
local ux, uy, uz = GetUnitViewPosition(unitID)
local dx, dy, dz = ux-cx, uy-cy, uz-cz
dist = dx*dx + dy*dy + dz*dz
if (dist>9000000) then
  return 
elseif (dist > infoDistance) then
  fullText = false
end
So the infoDistance variable is the one deciding how far you can be while still seeing the full bars. It's also actually the square of the distance, presumably because the sqrt on dist isn't really needed for optimisation reasons.

So the infoDistance for full text display is really representing a distance of 836 (700000 ^ 0.5). I would expect this distance to be less than the icon draw distance (129), because you need to be quite close to see the full info on the healthbars, but quite far before unit icons are drawn. So where this big difference in scales come from?

Secondly, in Lua, how do I get access to the clients graphical settings (like the unit icon draw distance)? I had a look at the wiki, but I can only see game/mod/map/server related settings, but not client settings... Am I looking in the wrong place?
User avatar
Acidd_UK
Posts: 963
Joined: 23 Apr 2006, 02:15

Re: XRay Shader

Post by Acidd_UK »

Oh come on, someone must know!
User avatar
Acidd_UK
Posts: 963
Joined: 23 Apr 2006, 02:15

Re: XRay Shader

Post by Acidd_UK »

So is it impossible? And no one knows the reason for the seeming discrepancy in the distance scales?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: XRay Shader

Post by Kloot »

Acidd_UK wrote: Secondly, in Lua, how do I get access to the clients graphical settings (like the unit icon draw distance)?
You don't, .springrc / registry values aren't exposed to Lua. ;)

e: but see trepan's post below
Last edited by Kloot on 08 May 2008, 22:27, edited 1 time in total.
User avatar
Tribulexrenamed
Posts: 775
Joined: 22 Apr 2008, 19:06

Re: XRay Shader

Post by Tribulexrenamed »

Kloot wrote:
Acidd_UK wrote: Secondly, in Lua, how do I get access to the clients graphical settings (like the unit icon draw distance)?
You don't, .springrc / registry values aren't exposed to Lua. ;)
Request.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: XRay Shader

Post by trepan »

Already done.

Code: Select all

/luaui echo Spring.GetConfigInt('UnitIconDist')
The one caveat is that the config settings are only available
to LuaUI at the moment. It might be worth moving the 'get'
versions so that all unsynced scripts can read the values
(read: mods should not be able to set the user config values).

EDIT: Now I remember why I didn't do that in the first place...
the configHandler doesn't separate read and writes very well.
User avatar
Acidd_UK
Posts: 963
Joined: 23 Apr 2006, 02:15

Re: XRay Shader

Post by Acidd_UK »

Thaks guys, that answers the first question. So now I would like to know why the distances scales seem to be out of whack... is it a mistake in my calculation?
Post Reply

Return to “Lua Scripts”