2d overlay on 3d?

Blitz3D Forums/Blitz3D Beginners Area/2d overlay on 3d?

Rambus(Posted 2003) [#1]
Trying to add a 2d overlay, for my 3d game. Whats the best way of doing this and does any one have an example?
thx


WolRon(Posted 2003) [#2]
Best way is to make the overlay a sprite draw the sprite last using entityorder.


Rambus(Posted 2003) [#3]
Yeah Thats what i was doing, but some one mentioned you can use all the 2d commands and such... how exactly do you lets say, add a list box (for chat) into your 3d game?


ford escort(Posted 2003) [#4]
you can use 2D commands in 3D but only blitz3D 2D-commands.
so you'll have to code yourself the chat interface.


FlameDuck(Posted 2003) [#5]
but some one mentioned you can use all the 2d commands and such.
You can, but you shouldn't. Modern (for lack of a better family friendly word) PC hardware doesn't handle 3D/2D mix and match combinations all that gracefullly.

Personally I use FonText for my 3D overlay needs. Works like a charm IMHO.


Neo Genesis10(Posted 2003) [#6]
GOD: Just ensure that you call all 2D commands (such as DrawImage) AFTER your call to Renderworld but BEFORE Flip. If you have the default CameraClsMode it will clear the color buffer leaving you with a blank canvas (save for your 3D rendered stuff anyways ^_^).

I have no idea why everyone keeps saying 2D + 3D is slow - I've been using just this kind of technique for ages now and havent run into problems. Oh well. Here's a code example for your perusal.
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

Global cube = CreateCube()
Global cone = CreateCone(32)
Global cam = CreateCamera()
PositionEntity cube, -1, 0, 0
PositionEntity cone, 1, 0, 0
PositionEntity cam, 0, 0, -3

EntityColor cube, 255, 0, 0
EntityColor cone, 0, 255, 0

Repeat
	TurnEntity cube, 1, 1, 1
	TurnEntity cone, -1, -1, -1
	RenderWorld

	; 2D Drawing commands
	Color 255, 255
	Rect 0, 0, 800, 200, 1
	Color 0, 0, 255
	Rect 2, 2, 796, 196, 0
	Text 4, 4, "This is 2D on top of 3D!"
	Text 4, 16, "Press ESC to exit!"
	Flip
Until KeyHit(1)



Rottbott(Posted 2003) [#7]
I've never had a problem with 2D commands over 3D, with one exception: Text. The Text command works fine on my machine, but on others it can a) slow things down a HUGE amount, or b) just look dodgy, or even totally unreadable.


FlameDuck(Posted 2003) [#8]
I have no idea why everyone keeps saying 2D + 3D is slow
Because a) Nvidia's software engineers couldn't write decent drivers to save their lives and b) because modern hardware is designed around 3D. The 2D portion of your graphics card is (more or less) the excact same hardware that it was 10 years ago.


Rambus(Posted 2003) [#9]
Hmmm Interesting, Yeah Ill experiment with both and see what works best for me.
thx


WolRon(Posted 2003) [#10]
Not what works best for you, what works best for your users...


Harder(Posted 2005) [#11]
Hey guys,
I'll apologize in advance if this is a stupid question, as it's my first questions with Blitz on these forums, but..
I'm using sprite control for my overlay buttons; I also want to use 2d rect commands, as they are working well for my layout. However, I can't seem to get the SpriteControl DrawImage3D to draw over the 2d rects, no matter how I re-arrange it. I'm guessing the solution is something dreadfully obvious, or maybe with the entity order or z buffer? Can anyone help out with this? It would be highly appreciated!

Tyler


WolRon(Posted 2005) [#12]
Well, first of all, you should have created a NEW thread, instead of digging up this old one.

Second, Keep in mind (as stated above) that 2D commands over 3D can (in some setups) cause terrible slow-down.

Third, what the heck is 'SpriteControl DrawImage3D'?

Fourth, you do realize that all 2D drawing operations need to be performed AFTER RenderWorld in order to be seen, and thus would always appear 'on top' of everything else...
(Technically, there are exceptions to this, which involve multiple cameras or pivots being shown/hidden, and CameraCLSMode being used with the cls_color parameter being set, and multiple RenderWorld's being used.)

Fifth, no question is ever stupid.


_PJ_(Posted 2005) [#13]

pivots being shown/hidden


How do you 'show' or 'hide' a pivot ?

Why would you?


WolRon(Posted 2005) [#14]
HideEntity pivot
ShowEntity pivot


to show/hide all of it's children, which could be hundreds or thousands, if you want, all in one command.


Sir Gak(Posted 2005) [#15]
The pivot is a really useful place to "hang your hat". All sorts of entities can be positionally tied to a pivot, and since said entities get their placement on-screen relative to the pivot, then changing the pivot's position changes all of the entities in one blast. As WolRon said, there could be hundreds or thousands of children. Instead of looping through all those entities, changing each one, you just change the pivot, voila! they all change with it.