Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Hud posititioning

Author
Message
Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 11th Nov 2004 06:59
I was playing about with using plains for a hud, and came up with this.



The important bit is dist#=(screen height()/2)/tan(cameraFOV/2), as this is the distance away from the camera to position the plain.

For example if you have a resolution of 1024x768, a plain of 1024x768 will fit exactly to screen without and blurring of the texture (providing you do not use mipmapping on the texture or object).

If this has already been done I apologise, but it was something I wanted to find out for myself and I thought I would pass it on.

Cheers,

Cloggy
JerBil
19
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 11th Nov 2004 12:52
This is nice, Cloggy, but your example is set for 1024x768. You'll have to get the actual display size and calculate some variables for your function call.

-JerBil
Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 11th Nov 2004 16:23
Jerbil,

If you change the resolution it still works. The positioning of the bottom right pane isn't correct.

using the following call will always position at the bottom right.



The code is not designed to resize to the screen resolution. I'm sure I can do that but the graphics/text will become blurry.

Cheers,

Cloggy
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Nov 2004 18:27
looks like good work, I'll try it later on.

BatVink
http://biglaugh.co.uk/catalog AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
JerBil
19
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 11th Nov 2004 21:45
Cloggy, sorry to overdo it with my comment. I realize you probably know what you're doing...


-JerBil
Vues3d on Kalimee
19
Years of Service
User Offline
Joined: 12th May 2004
Location: NYON (SWITZERLAND)
Posted: 11th Nov 2004 23:22
Sorry if my question seems a bit silly, but could you explain me what's a "hud"????

Guido
http://www.vues3d.com
Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 12th Nov 2004 00:02
A hud is a heads up display, like on a fighter plane. You would use then to display target recticule's, radars., scores etc.

People noramlly use sprites, but 3d plains are faster.

Cheers,

Cloggy
Los
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Location:
Posted: 29th Jan 2005 23:32
I've used your code to get a background showing perfectly on screen. I like the plains idea. Now I need to figure out how to the move the camera in DBC.

I'm in the middle of urinating, but I'll try and understand your 'most important' line.. If I look at it side on. Why you chose 61 degrees as the FOV I would like to ask.

no no no no no no no no
Sol462
19
Years of Service
User Offline
Joined: 12th Sep 2004
Location: playing with the spazookeedoo
Posted: 30th Jan 2005 14:04
Quote: "I'm in the middle of urinating"

my aren't you talented!

coffee + monkeys + creativity = games
Operation Pineapple - Multiplayer FPS WIP
Los
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Location:
Posted: 2nd Feb 2005 03:49
Cloggy, or anyone if Cloggy never comes back...

Why is it you use these lines of code?

xpos=(xpos-screen width()/2)+xsize/2
ypos=((ypos*-1)+screen height()/2)-ysize/2

I could imagine it might block any unusual entries or possibly correct certain numbers. Out of interest after taking time to draw it down I saw you divided by two removing it off the screen, then moving it forward again by half of something else. This was the Xpos..

when you comment these out it works just as normal, except you need to send over -240 if you want it halfway down the screen on the Y axis.

I still havn't figured out the tan bit yet. I may do that now as I have paper, an idea of what you are doing and a calculator all at hand. Why make it so complex?

no no no no no no no no
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 2nd Feb 2005 06:10 Edited at: 2nd Feb 2005 06:18
Edit: Deleted: Not relevant.

"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 3rd Feb 2005 06:23
Quote: "I still havn't figured out the tan bit yet."


Its a right angle triangle. The field of view is the angle, the screen size is the opposite side of the triangle, and the distance from the camera is the adjacent. So, by rearranging the trigonometric rule tan(angle)=opposite/adjacent he has arrived with his equation. At least, that's how I would have done it.


Los
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Location:
Posted: 6th Feb 2005 19:17
OK Ric you seemed to of made that clear to me. The HYP doesn't always need to be the '?'

Well after I've thanked you, I need to get something working with this. You see I have a problem that some of my models I'm loading into the 3D world now go through this plain. It was originally made for a close HUD.. but I'm using it for a background image with my man infront. If I have a long path to walk down, he could disappear behined this plain. Oh dear

Thank you Ric.

" Ahh to finish something! My boy, have you ever accomplished anything? "
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 6th Feb 2005 21:42
Well, if it's a HUD, you would want it to appear infront of your objects at all times, with objects behind it only showing through the transparent parts of the HUD - so you need to 'disable zdepth' and 'set object transparency' to on (or, you could use ghosting or alpha mapping to make it translucent).


Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 9th Apr 2005 01:20
Here is an update. I've made some changes so that the plains aren't 'locked' to the screen but are moved relative to the camera. Also the code is a little cleaner.



Please let me know if you have any questions/problems with this code.

Cloggy
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 10th Apr 2005 00:02
Allright i need some help here.
I got stuck with the fov. the help file in DBC says the standard fov angle is 3.14/2.905 wich is 1.080895009. Why do u use 61.96... ?

I posted it once in the beginners forum...
Dmitry K
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Russia
Posted: 10th Apr 2005 00:42 Edited at: 10th Apr 2005 00:42
FOV_In_Radians = Pi/2.905 =
= 3,1415926535897932384626433832795/2.905 =
= 1,0814432542477773626377429890807

FOV_In_Degrees = FOV_In_Radians/(Pi/180.0) =
= 1,0814432542477773626377429890807/0,039269908169872415480783042290994
= 61,962134251290877796901893287435

Specs: P4 2.4GHz, DIMM 256 266Mhz, 60GB HD 7200rpm ATA-133, GeForce 4 MX440, CD-RW+DVD, WinXP
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 10th Apr 2005 00:44
AAAAH ty Dmitry. I see it clear now. Now i can continue my rts!

Login to post a reply

Server time is: 2024-03-28 10:51:18
Your offset time is: 2024-03-28 10:51:18