00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include "HealthBar.h"
00009 
00010 HealthBar::HealthBar(Ogre::ManualObject* mObj, float percent = 100.0f, bool startOnLeft = true):
00011 percent(percent), startOnLeft(startOnLeft), fullBar(new Rect(0, 20, Ogre::ColourValue(0,1,0),mObj)),
00012         emptyBar(new Rect(0, 20, Ogre::ColourValue(1,0,0),mObj))
00013 {
00014 }
00015 
00016 HealthBar::HealthBar(const HealthBar& orig)
00017 {
00018 }
00019 
00020 HealthBar::~HealthBar()
00021 {
00022 }
00023 
00024 void HealthBar::Draw(Ogre::Vector3 pos)
00025 {
00026     const float length = 200;
00027     const float edge = pos.x - (length / 2.0);
00028     
00029     fullBar->length = length * (percent / 100.0f);
00030     emptyBar->length = length - fullBar->length;
00031     
00032     
00033     float fullStart = edge + (fullBar->length / 2.0);
00034     float emptyStart = fullStart + (fullBar->length / 2.0) + (emptyBar->length / 2.0);
00035     fullBar->Draw(Ogre::Vector3(fullStart, pos.y, pos.z));
00036     emptyBar->Draw(Ogre::Vector3(emptyStart, pos.y, pos.z));    
00037     
00038 }
00039 
00040 void HealthBar::ClearVertices()
00041 {
00042     fullBar->ClearVertices();
00043     emptyBar->ClearVertices();
00044 }