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.

DarkBASIC Discussion / How do you create a HUD for a 3D game?

Author
Message
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Apr 2003 23:44
Should this be done as sprites? Or is this not compatible with the 3D environment? I'd appreciate everyone's opinions, I imagine thre are many different ways to acheive this.
Thanks in advance.
All the Best,
StevieVee
hexGEAR
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 15th Apr 2003 23:47
well, in my opinion, the best way to make your HUD is with plains, texture and resize to optimize then lock on screen and position them to appear right on the screen. You can then use the set object command to light-up the plain or dimmen it!

everyday of life is a new chapter that has already been fortold but is up to the soul to capture.
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Apr 2003 23:57
Ok...but how do you position the plain so that it's at 0,0, 800 pixels wide and 100 pixels deep? Surely you would need some clever 3D maths.

Please tell me I'm wrong, the idea sounds excellent.

Thanks in advance.
All the Best,
StevieVee
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Apr 2003 00:08
Found some ggod stuff in the new DB tutorials, under section "The Scores". 2D HUD created from 3D objects. The code appears to be written for a 640 x 480 display.

`-----------------------------------
`3d sprite commands - make 3d sprite
`-----------------------------------
function make_3d_sprite(objid,width,height)

make object plain objid,width,height
set object objid,1,1,1,0,0,0,0
set object collision off objid
lock object on objid

endfunction

`-----------------
`texture 3d sprite
`-----------------
function texture_3d_sprite(objid,tex,trans)

set object objid,1,trans,1,1,0,0,0
texture object objid,tex

endfunction

`------------------
`position 3d sprite
`------------------
function position_3d_sprite(objid,x,y)

position object objid,(x-320)+(object size x(objid)/2),-1*((y-240)+(object size y(objid)/2)),400

endfunction

Thanks in advance.
All the Best,
StevieVee
rapscaLLion
23
Years of Service
User Offline
Joined: 29th Aug 2002
Location: Canada
Posted: 16th Apr 2003 00:37
You just position it by eye... it's easy to write a little program for that, I did but lost it :S

You could use complex 3D maths if you want to though!

Alex Wanuch
aka rapscaLLion
Kousen Dev Progress >> Currently Working On Editors
Dr DooMer
23
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 16th Apr 2003 02:21
The last HUD I did was just positioned by eye, too - trial and error in my case. Although, it wasn't very complicated, just a few floating numbers and health bars as flat plains locked to the screen.

It's probably the easiest way because it's then independent of the user's display mode.

"I am a living, thinking entity who was created in the sea of information."
Danmatsuma
23
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 16th Apr 2003 07:20
Yeah StevieVee, get into using the CLI, you get a feel for these things

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Apr 2003 17:29 Edited at: 16th Apr 2003 17:32
The code I posted above works fantastically! You don't change any values for different resolutions, it adapts. I guess the ratios 640 x 480 x 400(z) are just perfect.

Dansatsuma:
I used the CLI to display variable values, but they disappear instantly. How do I get around this?

I'd never thought about using the CLI to actually change the screen...that would've saved me hours! 'Cos I'm a mainframe programmer amongst other things, I just assume debugging is supposed to be virtually impossible!

Thanks in advance.
All the Best,
StevieVee
Danmatsuma
23
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 16th Apr 2003 21:53
hehe, well it helps to write little bits of code into your program which have variables you can use the cli to change mid-program.

Your text dissappears because after you resume running the program loop iterates again and the sync command wipes your "softcoded" text command or print command. You have to put something like:



into your program loop, and change those values (info$ and variable#)in the cli but you can get a lot more complicated than that, it's a matter of personal preference, but sometimes I'll write a function specifically for debugging using the cli whilst running my program. It's handy

another nice thing to do is to setup the tab key or some other unused key so that if you press it you get a text display of all the significant variables and strings in your proggy superimposed over it.
You can rem out the ones you know you don't want to see before executing your code.

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.

Login to post a reply

Server time is: 2026-06-12 03:34:53
Your offset time is: 2026-06-12 03:34:53