2D Graphics Over 3D meshes

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.
Post Reply
fronald
Posts: 7
Joined: Sun Nov 15, 2015 4:10 am

2D Graphics Over 3D meshes

Post by fronald »

Hi guys,

In my game i need draw an 2D hp bar over all 3D meshes in scene. But when i call videoDriver->draw2DImage, the image appear on background. Is any way to draw over meshes? Like layers?

Thank you,
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: 2D Graphics Over 3D meshes

Post by Mel »

You can create your own node, say for instance, a node that drew a couple rectangles over each node it is attached to. Being careful, you can draw this node the same size on all the distances, or even better, create a node with a list of special nodes that builds a mesh like the one i've described over each node, and draws all at once. it is not very hard, and it can be API independent. Take a look at the custom node example, and don't be afraid to experiment.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: 2D Graphics Over 3D meshes

Post by hendu »

draw2dImage goes where you use it - draw it before, it goes under, draw it after, it goes on top.
fronald
Posts: 7
Joined: Sun Nov 15, 2015 4:10 am

Re: 2D Graphics Over 3D meshes

Post by fronald »

Mel wrote:You can create your own node, say for instance, a node that drew a couple rectangles over each node it is attached to. Being careful, you can draw this node the same size on all the distances, or even better, create a node with a list of special nodes that builds a mesh like the one i've described over each node, and draws all at once. it is not very hard, and it can be API independent. Take a look at the custom node example, and don't be afraid to experiment.
Thank you very much! Maybe this is the better way to solve my problem and give more flexibility to my "custom game widgets". The Irrlicht code organization and formatting is very familiar for me.

I will make a test and reply you later.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: 2D Graphics Over 3D meshes

Post by Mel »

hendu wrote:draw2dImage goes where you use it - draw it before, it goes under, draw it after, it goes on top.
Yeah, but in his case, I also keep in mind the amount of draw calls that would require to draw many of those rectangles as well, or perhaps the interleaving between nodes. Think that it is possible to draw a 2D image just after a node is rendered, enabling the drawing of multiple images on diferent distances, with a lighting manager (<- tbh the MOST UNDERRATED part of Irrlicht ever... )

There should be a way to batch 2D drawings on 3D environments, like a draw3DImageBatch, in which you passed 3D positions all along, and a rectangular sizes, or that perhaps, it drew the image independent of the size, or the like. We have the billboards and particle systems, but the particle systems will draw currently thousand copies of a single image, and the billboards will draw just one image for each billboard, slowing things down if there are many of them to draw. There could be a posibility that enabled the drawing of many diferent images (perhaps stored on the same texture) on diferent 3d positions.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: 2D Graphics Over 3D meshes

Post by hendu »

HP bar class ;)

That sounds similar to my instancing class, except without instancing.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: 2D Graphics Over 3D meshes

Post by Mel »

Instancing is overrated XD

No, really, if the triangle account is minimal (~3000 tris) you can live without instancing.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: 2D Graphics Over 3D meshes

Post by Cube_ »

instancing can actually lower performance if we're talking small triangle counts...
"this is not the bottleneck you are looking for"
Post Reply