How can I get a HUD?

Blitz3D Forums/Blitz3D Programming/How can I get a HUD?

ala_samodi(Posted 2004) [#1]
I just can't seem to figure it out but how can I make a Heads Up Display in my 3d world?


N(Posted 2004) [#2]
Pretty simple if you've already got functions to convert 2D coords to 3D coords.

For example,


Edit: Slightly better picture

That's just two sprites and a triangle fan (the lit up squares are just a change in vertex color). There's absolutely nothing complex about it, but it works marvelously.


ala_samodi(Posted 2004) [#3]
sry i dont get it???


N(Posted 2004) [#4]
Basically, you convert 2D coordinates to 3D coordinates, add the triangles the way you want, etc. and then just modify them to suit changes in your GUI.

The screenshot above would just be adding a quad to a mesh, texturing it with the sortof techy block one, then creating a triangle fan (more like a triangle strip that's in a sortof tubular shape), texturing it with the blueish block one, and that's that. For every change in health you'd just change the vertex colors on the triangle fan like this:

Vs = CountVertices(TFSurface)
HealthMod# = (HP#/100)*Vs
For v = 0 To Vs-1 Step 4
     If v < HealthMod Then
          For i = 0 To 3
               VertexColor TFSurface,255,255,255,1.0
          Next
     Else
          For i = 0 To 3
               VertexColor TFSurface,128,128,128,1.0
          Next
     EndIf
Next



ala_samodi(Posted 2004) [#5]
So say I wanted to put that in the castle demo? were would I put that?


Braincell(Posted 2004) [#6]
hehe, maybe you should post in the Beginners thread :P

What you need to figure out is how to put a sprite to always face the camera and turn its Z buffer off , or something, i dunno. Just learn the Command Reference by heart like i did and then you'll know :)


slenkar(Posted 2004) [#7]
hey mysticlore:
http://www.nuloen.com/nsprite.html


jhocking(Posted 2004) [#8]
You'll probably want to use some 2D-in-3D library. Slenkar posted one, but there are lots of others to consider too. For example, I use the HUD library that's part of FONText, a bitmap fonts tool.


ryan scott(Posted 2004) [#9]
i'm a wonderin:

why use 2d in 3d when you could do renderworld and then do plain ole 2d on top of it?

i mean yeah you can do some cooler 3d-y looking hud if you use 3d, but 2d-in-3d library isn't that anyway. so, why not renderworld and then 2d on top?

is it faster to do 2d in 3d library or something?


Bot Builder(Posted 2004) [#10]
Yes.

Some cards slow down majorly on 2d over 3d graphics, and alot of cards do it slower. Its partially a speed issue. Also, you can do cool effects like alpha, realtime rotation, scaling, etc.


N(Posted 2004) [#11]
ryan: 2D in Blitz is really quite slow and takes much longer because the 2D operations are being done after rendering (and 2D in general is just slow). When it's done via 2D in 3D methods, everything is handled through RenderWorld instead of via post-render drawing.

And if you've ever tried drawing a HUD with alpha and various effects applied after rendering, you'd notice that there's a signifigant slowdown. It can take about as long as four times the time RenderWorld takes.


jhocking(Posted 2004) [#12]
Besides speed (which is a big issue) consider also resolution independence. A HUD done with 2D graphics commands won't be scalable to the player changing the resolution of the game, while a 2D-in-3D system won't care what resolution the game is set to.


N(Posted 2004) [#13]
Alright, mysticlore, just stuck this in the Code Archives. It may or may not help you with making a HUD. I'll update it soon-ish with text functions. But what you see in the pictures I posted first is completely doable with what's there.

http://blitzbasic.com/codearcs/codearcs.php?code=1152


WolRon(Posted 2004) [#14]
***QUESTION***
why use 2d in 3d when you could do renderworld and then do plain ole 2d on top of it?

***ANSWER***
Some cards slow down majorly on 2d over 3d graphics, and alot of cards do it slower. Its partially a speed issue. Also, you can do cool effects like alpha, realtime rotation, scaling, etc.

Besides speed (which is a big issue) consider also resolution independence. A HUD done with 2D graphics commands won't be scalable to the player changing the resolution of the game, while a 2D-in-3D system won't care what resolution the game is set to.




I think BR needs a Blitz beginner FAQ section for just these things entitled BLITZ NEWBIE FAQ.