How to draw a healthbar in 3d?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Camden

How to draw a healthbar in 3d?

Post by Camden »

Hi

When units are hit, they display their healthbar next to them for a little while. It can be draw2dRectangle or draw2dImage I guess, thats fine, but how to position it correctly? Or other symbols that shall be drawn in the game?

That functions position is relative to the screen, not the world, so if camera can zoom and move, drawing that 2drectangle at the right spot is pretty tricky...

Thank you
Xico
Posts: 30
Joined: Sun Jun 05, 2005 5:08 pm
Location: Buenos Aires, Argentina
Contact:

Billboards

Post by Xico »

Hi, you can try using billboards.

regards
Xico
Fhqwhgads
Posts: 42
Joined: Tue Jun 21, 2005 1:43 am

Post by Fhqwhgads »

Just have it draw at the X and Y value you want. Then for the Z valuse just make it smaller or bigger the ferther or closer you get.
tip
Posts: 50
Joined: Fri Feb 13, 2004 8:53 am
Location: grenoble, France
Contact:

Post by tip »

you can either use
- ISceneManager::getScreenCoordinatesFrom3DPosition(vector3df(x,y,z));
and then draw 2D image above the head
- billboards

the billboard will decrease in size when you go far from the character, and the GFX will be less readable because stretched. It's also not the best thing if you need to write text (you need to create a texture and then render it). With the first method, you can write also text easily as 2D render function in screen coordinates.
Beam

Post by Beam »

getScreenCoordinatesFrom3DPosition seems to be a good sollution, although it is SceneCollisionManager (finally figured it out and how to fetch it via sceneManager).

Im having problems getting billboards to work, how do I "start" them, shouldnt load a bitmap or texture onto them? The reference doesnt help me.

Thanks
Camden

Post by Camden »

Yeah me to, is there any sample code on how to set up a billboard? Is it a "node-card" that only uses one side, so an applied texture is all that you see? Can I make a color transparent or must the billboard "look rectangular" like a block?
Ace12GA
Posts: 7
Joined: Mon Aug 08, 2005 2:43 am

Post by Ace12GA »

Beam wrote:getScreenCoordinatesFrom3DPosition seems to be a good sollution, although it is SceneCollisionManager (finally figured it out and how to fetch it via sceneManager).

Im having problems getting billboards to work, how do I "start" them, shouldnt load a bitmap or texture onto them? The reference doesnt help me.

Thanks
Read the collision tutorial, there is a billboard used in that tutorial, and it outlines how to load and display one clearly in code.
Post Reply