Jump to content
  • Advertisement
Sign in to follow this  
dbh

Health Bar: ID3DXLine?

This topic is 4847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Been toying with various ways to do health bars in my game... They need to: 1. Move around in a 3D world (floating above enemies). 2. Be normal to the camera at all times... which is what made me lean to the ID3DXLINE class. I've considered using my own quads and making my own healthbars that way... but again, then I'd have to do all this work to get the quad normal to the camera. It could be done-- but I figure if D3DX already has a class that does it... But I'm having trouble getting the DrawTransform functionality for ID3DXLine to work right. I can get 2D lines to render perfectly with the class's Draw() function-- but DrawTransform is giving me no results. Should I just give up on ID3DXLine? If so, what would you recommend I do for my health bars? Thank you, -dbh

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by dbh
I've considered using my own quads and making my own healthbars that way... but again, then I'd have to do all this work to get the quad normal to the camera.


Why not just set up an orthographic projection matrix?

Share this post


Link to post
Share on other sites
Think that'd do it? Just use a quad to represent the full health bar, and then scale it according to the current-health / max-health ratio... and then use an orthographic proj matrix to draw it with?

-dbh

Share this post


Link to post
Share on other sites
Quote:
Original post by dbh
Think that'd do it? Just use a quad to represent the full health bar, and then scale it according to the current-health / max-health ratio... and then use an orthographic proj matrix to draw it with?

-dbh


Maybe you want billboarding instead? If you use orthographic projection you'll have to scale it according to how far away the enemy is from the screen. I think the documentation has some info on it.

Share this post


Link to post
Share on other sites
Thanks for the replies guys...

I thought about it some more, and decided to skip 2-D interfaces altogether and went with a pair of 3d models I crafted. One is a healthbar "capsule" and the other is the "inside" of that capsule.

I then just scale the mesh and color its material according to the condition the enemy is in. Works like a charm!

Thanks for the inspiration and helpful suggestions-- got me on the right track!

-dbh

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!