Author Topic: The HUD (Discussion)  (Read 9652 times)

0 Members and 1 Guest are viewing this topic.

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: The HUD (Discussion)
I assume you mean this page in the wiki? Done, and I tried to update the rest of the examples to reflect the new scripting system capabilities as well.
-C

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: The HUD (Discussion)
thanks :D
but wheres the render trargets example?
all i really got to go on is this old example which didnt work last i checked. i never really understood the whole thing in the first place and the fact that i was never able to generate any working code doesnt help much either. i need to see a current working example that i can mess with and understand how its working. not neccisarily a panel, but at least painting foul words on the side of an orion will do :D
« Last Edit: May 27, 2007, 05:08:12 am by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: The HUD (Discussion)
Well, I haven't been able to get a working RTT example going; apparently there's a bug with the RTT code which taylor is looking into. (I don't know when the fix will be committed)
-C

 

Offline Cobra

  • 212
  • Snake on a Cain
    • Minecraft
    • Skype
    • Steam
    • Twitter
Re: The HUD (Discussion)
What is RTT?
To consider the Earth as the only populated world in infinite space is as absurd as to assert that in an entire field of millet, only one grain will grow. - Metrodorus of Chios
I wept. Mysterious forces beyond my ken had reached into my beautiful mission and energized its pilots with inhuman bomb-firing abilities. I could only imagine the GTVA warriors giving a mighty KIAAIIIIIII shout as they worked their triggers, their biceps bulging with sinew after years of Ivan Drago-esque steroid therapy and weight training. - General Battuta

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: The HUD (Discussion)
Render-To-Texture
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: The HUD (Discussion)
will taylors fix include rtt under open gl?
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: The HUD (Discussion)
It sounds like the fix will only affect OpenGL.
-C

 

Offline Admiral Nelson

  • Resurrecter of Campaigns
  • 211
  • The GTA expects that every man will do his duty.
Re: The HUD (Discussion)
How practical would it be to use scripting with the HUD available now to produce a disturbed reticle gunsight?  This is a form of early gunsight in which the reticle itself moves to account for the bullet path under G at a given range.  In effect, unlike the targeting reticle in FS2, which is a director sight (it knows the target course, velocity and range) it is a targeting reticle set to a fixed range.  The reticle 'floats' across the screen as the craft maneuvers to display where the projectiles will actually be traveling.
If a man consults whether he is to fight, when he has the power in his own hands, it is certain that his opinion is against fighting.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: The HUD (Discussion)
how good are you at math? :D

that means it can be done, ive done my own lead indicators (based off some of wanderer's script). be nice if you could make a lead that indicates hit probibility and takes the target's evade potential into consideration.
« Last Edit: July 08, 2007, 11:16:24 pm by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: The HUD (Discussion)
That actually would be pretty cool. :nervous:

That thrill of almost-satisfaction you'd get as the reticule pulsed red when you catch a Dragon flat-footed...
-C

 

Offline blackhole

  • Still not over the rainbow
  • 29
  • Destiny can suck it
    • Black Sphere Studios
Re: The HUD (Discussion)
Quote
flat-footed
That term is reserved for D&D, not FS2 :P

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: The HUD (Discussion)
ideally id use a reticle like the one i already completed, a simple circle with a radius and color indicating hit potential. evade potential can be figured out by determining the travel time for your shots to get to the target, how fast the ship can go/manuver, and in some cases max deflection angles (for weapons that use them). using that data you could determine  it would require doing complicated math every frame though.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Admiral Nelson

  • Resurrecter of Campaigns
  • 211
  • The GTA expects that every man will do his duty.
Re: The HUD (Discussion)
Heh, that stuff sounds cool, director sights do have a "SHOOT" indicator that would be interesting.

I am interested actually in a primitive F-86 style gyro sight.  Basically a reticle that precesses opposite to whatever turn you are making. 

Quote
The disturbed reticle sight takes the ballistic data, combines it with aircraft pitch and roll inputs, and then computes a picture of what the bullet path looks like.  Essentially, the disturbed reticle sight says to the pilot, "Here’s what the bullets are doing…now it is up to you to get the target to fly into this area."



Of course it wouldn't precess down as there is no gravity in space.  I presume I would need to get the vector describing the flight path of the player craft and then in effect reverse it to get the projectiles' vector.  That in turn would need to be converted into an on screen coordinate.  Does that make sense?

If a man consults whether he is to fight, when he has the power in his own hands, it is certain that his opinion is against fighting.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: The HUD (Discussion)
try this

Code: [Select]
#Global Hooks
$GameInit:
[

--all this stuff is for multires support, for getting true width and height, and for generating factors to scale coords by

w = gr.getScreenWidth()
h = gr.getScreenHeight()
cx = w/2
cy = h/2

if w >= 1024 then
wf = w / 1024
hf = h / 768
awh = (wf + hf) / 2
hires = true
else
wf = w / 640
hf = h / 480
awh = ((wf + hf) / 2) * 0.625
hires = false
end

--now that were done with that ****, we can define some more important vars

xtarg = cx --this is where our crosshair will want to be
ytarg = cy --same thing but a bit more vertical
wepvel = 450 --set for thrasher for testing, wel do what wanderer did later
chr = 50
chg = 50
chb = 50
cha = 50

--now a crosshair, il make this much more detailed later, with target direction and orientation, target iff and maybe ammo gauge and locked/locking indicators

drawgunsight = function(x,y,r,g,b,a)
gr.setColor(r,g,b,a)
gr.drawCircle(25,x,y)
gr.setColor(r,g,b,255)
gr.drawGradientLine(x+18,y+18,x+5,y+5)
gr.drawGradientLine(x-18,y+18,x-5,y+5)
gr.drawGradientLine(x+18,y-18,x+5,y-5)
gr.drawGradientLine(x-18,y-18,x-5,y-5)
end

--and finally lets jack wanderers code, because i really dont feel like plotting vectors in 3d space

leadreticle = function(weaponvel)
local targetpos = target.Position --tweak theese
local targetvel = target.Physics.Velocity --looks like nothing else needs to be tweaked here
local lenghttargetvel = targetvel:getMagnitude()
local playerpos = player.Position
local plrtotrg = playerpos - targetpos
local lenghtplrtotrg = plrtotrg:getMagnitude()
local trgangle = plrtotrg:getDotProduct(targetvel)
local a = (( weaponvel * weaponvel ) - ( lenghttargetvel * lenghttargetvel ))
local b = ( 2 * trgangle )
local c = -( lenghtplrtotrg * lenghtplrtotrg )
local discrim = ((b * b) - 4 * a * c)
local leadx = 0
local leady = 0

if discrim >= 0 and a ~= 0 then
multipl1 = (( -b + math.sqrt(discrim)) / ( 2 * a))
multipl2 = (( -b - math.sqrt(discrim)) / ( 2 * a))

if multipl1 >=0 and multipl1 <= multipl2 and multipl2 >= 0 then
targetmult = multipl1
elseif multipl1 >=0 and multipl2 < 0 then
targetmult = multipl1
elseif multipl2 >=0 then
targetmult = multipl2
else
targetmult = nil
end

if targetmult ~= nil then
local leadvel = targetvel/(1/targetmult)
local leadpos = targetpos + leadvel

      if leadpos:getScreenCoords() ~= false then
leadx, leady = leadpos:getScreenCoords() --rather than just simply draw the coords, il scale and return them so my code can **** with them
leadx = leadx * wf --drawleadreticle(leadx,leady) pft, my way is better :D
leady = leady * hf --theese factors make things so much easyer
return leadx, leady --yep, thats what i need there
else
return -1, -1 --return -1-1 if this all fails, so it doesnt tweak my math
end
end
      end
end

]
$HUD:
[

player = mn.Ships["Alpha 1"]

if player:isValid() then
target = player.Target

banks = player.PrimaryBanks --work on this
wep1 = banks['1']
wepvel = wep1.WeaponClass.Speed
end

if target:isValid() and player:isValid() then
if target.Position:getScreenCoords() ~= false then
xship, yship = target.Position:getScreenCoords()
xship = xship * wf
yship = yship * hf
xtarg, ytarg = leadreticle(wepvel)
if xtarg >= 0 or ytarg >= 0 then
xtarg = cx + (xship - xtarg)
ytarg = cy + (yship - ytarg)
else
xtarg = cx
ytarg = cy
end
else
xtarg = cx
ytarg = cy
end
else
xtarg = cx
ytarg = cy
end

if target:isValid() == false then
if chr > 50 then
chr = chr - 1
elseif chr < 50 then
chr = chr + 1
end

if chg > 50 then
chg = chg - 1
elseif chg < 50 then
chg = chg + 1
end

if chb > 50 then
chb = chb - 1
elseif chb < 50 then
chb = chb + 1
end
elseif target.Team.Name == "Hostile" or target.Team.Name == "Traitor" then
if chr < 255 then
chr = chr + 1
end

if chg > 0 then
chg = chg - 1
end

if chb > 0 then
chb = chb - 1
end
elseif target.Team.Name == "Friendly" then
if chr > 0 then
chr = chr - 1
end

if chg < 255 then
chg = chg + 1
end

if chb > 0 then
chb = chb - 1
end
elseif target.Team.Name == "Unknown" then
if chr < 255 then
chr = chr + 1
end

if chg > 0 then
chg = chg - 1
end

if chb < 255 then
chb = chb + 1
end
elseif target.Team.Name == "Neutral" then
if chr > 0 then
chr = chr - 1
end

if chg > 0 then
chg = chg - 1
end

if chb < 255 then
chb = chb + 1
end
else
if chr > 128 then
chr = chr - 1
elseif chr < 128 then
chr = chr + 1
end

if chg > 128 then
chg = chg - 1
elseif chg < 128 then
chg = chg + 1
end

if chb > 128 then
chb = chb - 1
elseif chb < 128 then
chb = chb + 1
end
end

drawgunsight(xtarg, ytarg, chr, chg, chb, cha)

]
#End

this should work in recent head builds
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Unknown Target

  • Get off my lawn!
  • 212
  • Push.Pull?
Re: The HUD (Discussion)
Could something a little more modern be made? As in, a gunsight pipper with a line trailing to a circle - you place the circle on the target and squeeze? Basically like the one in an F-15? (Kinda like a different looking F-86 sight :) ).

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: The HUD (Discussion)
well you could swap the procedurally rendered pipper i mad ewith a graphic pipper instead, then just get the screen coords of the ship and draw a line from those coords to the sight's. ive done this before its rather easy.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Admiral Nelson

  • Resurrecter of Campaigns
  • 211
  • The GTA expects that every man will do his duty.
Re: The HUD (Discussion)
Is the magnitude of a vector in FS2 a value expressed in meters (yes, I was an English major)?  For instance, the F-86 gunsight doesn't know anything about the location of the target.  It is calibrated to assume that the target is at a certain distance -- say 500m.  Thus instead of this code snippet:

Code: [Select]
local targetpos = target.Position --tweak theese
local targetvel = target.Physics.Velocity --looks like nothing else needs to be tweaked here
local lenghttargetvel = targetvel:getMagnitude()
local playerpos = player.Position
local plrtotrg = playerpos - targetpos
local lenghtplrtotrg = plrtotrg:getMagnitude()
local trgangle = plrtotrg:getDotProduct(targetvel)
[\code]


Could I not simply use

[code]

local targetvel = player.Physics.Velocity --use the player's own craft's velocity
local lenghtplrtotrg = 500 --fixed distance
local trgangle = plrtotrg:getDotProduct(targetvel)


and continue with the rest of the code?  I will need to flip the x/y coordinates of the gunsight, as this is a trailing and not leading indicator.[/code]
If a man consults whether he is to fight, when he has the power in his own hands, it is certain that his opinion is against fighting.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: The HUD (Discussion)
before the radar gunsight was used they used a gyro gunsight, which compensated for g-forces, gravity and attitude (as this data was already available to the instruments). that would require entire code entirely.

the whole function for generating the lead was designed by wanderer (though i added some tweeks too it) and i barely understand how it works. what i did know was that if i knew where the leadpoint was (generated by function), i knew where the reticle was (w&h / 2), and i knew where the ship was, then i could draw a pipper on the screen by subtracting the lead's screen coords from the ship's screen coords, then add the result to the screen center. all i did really was change how the data was represented.

btw, what sim is that?
« Last Edit: July 11, 2007, 07:46:34 am by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: The HUD (Discussion)
My lead function is basically just 101 trigonometry.. namely usage of the extended Pythagoran law.. the cosine rule. It constantly calculates interception point for the given primary weapon and the target in 3d space. Most of function is just a verification process that it uses the correct root (from 2nd degree function) and that the root may not be imaginary. Most of the stuff i added just in case Lua would be unable to automagically handle 'double' results and imaginary values and also to make sure that i get the result i wanted from the function.

But to get a low tech 'lead reticle' for fixed distance firing you need to use something totally different as Nuke said.
Do not meddle in the affairs of coders for they are soggy and hard to light