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.

2D Graphics Over 3D meshes

Postby fronald » Fri Nov 20, 2015 2:11 pm

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,
fronald
 
Posts: 7
Joined: Sun Nov 15, 2015 4:10 am

Re: 2D Graphics Over 3D meshes

Postby Mel » Fri Nov 20, 2015 5:30 pm

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
User avatar
Mel
Competition winner
 
Posts: 2273
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: 2D Graphics Over 3D meshes

Postby hendu » Fri Nov 20, 2015 7:07 pm

draw2dImage goes where you use it - draw it before, it goes under, draw it after, it goes on top.
hendu
 
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: 2D Graphics Over 3D meshes

Postby fronald » Fri Nov 20, 2015 10:12 pm

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.
fronald
 
Posts: 7
Joined: Sun Nov 15, 2015 4:10 am

Re: 2D Graphics Over 3D meshes

Postby Mel » Sun Nov 22, 2015 7:24 pm

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
User avatar
Mel
Competition winner
 
Posts: 2273
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: 2D Graphics Over 3D meshes

Postby hendu » Sun Nov 22, 2015 8:27 pm

HP bar class ;)

That sounds similar to my instancing class, except without instancing.
hendu
 
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: 2D Graphics Over 3D meshes

Postby Mel » Mon Nov 23, 2015 11:10 am

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
User avatar
Mel
Competition winner
 
Posts: 2273
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: 2D Graphics Over 3D meshes

Postby Cube_ » Mon Nov 23, 2015 1:49 pm

instancing can actually lower performance if we're talking small triangle counts...
"this is not the bottleneck you are looking for"
User avatar
Cube_
 
Posts: 1011
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


Return to Everything 2d/3d Graphics

Who is online

Users browsing this forum: No registered users and 1 guest