Code: Select all
#include "CHealthBar.h"
#include <iostream>
using namespace std;
CHealthBar::CHealthBar(scene::ISceneNode* parent, scene::ISceneManager* smgr, s32 id)
: scene::ISceneNode(parent, smgr, id)
{
this->smgr = smgr;
Material.Wireframe = false;
Material.Lighting = false;
Vertices[0] = video::S3DVertex(0,0,10, 1,1,0,
video::SColor(255,0,255,255), 0, 1);
Vertices[1] = video::S3DVertex(10,0,-10, 1,0,0,
video::SColor(255,255,0,255), 1, 1);
Vertices[2] = video::S3DVertex(0,20,0, 0,1,1,
video::SColor(255,255,255,0), 1, 0);
Vertices[3] = video::S3DVertex(-10,0,-10, 0,0,1,
video::SColor(255,0,255,0), 0, 0);
Box.reset(Vertices[0].Pos);
for (s32 i=1; i<4; ++i)
Box.addInternalPoint(Vertices[i].Pos);
}
CHealthBar::~CHealthBar()
{
}
void CHealthBar::OnRegisterSceneNode()
{
if (IsVisible)
SceneManager->registerNodeForRendering(this);
ISceneNode::OnRegisterSceneNode();
cout << "Test" << endl;
}
void CHealthBar::render()
{
cout << "Testing" << endl;
u16 indices[] = { 0,2,3, 2,1,3, 1,0,3, 2,0,1 };
video::IVideoDriver* driver = smgr->getVideoDriver();
driver->setMaterial(Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawVertexPrimitiveList(&Vertices[0], 4, &indices[0], 4, video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);
}
const core::aabbox3d<f32>& CHealthBar::getBoundingBox() const
{
return Box;
}
u32 CHealthBar::getMaterialCount() const
{
return 1;
}
video::SMaterial& CHealthBar::getMaterial(u32 i)
{
return Material;
}
Code: Select all
CHealthBar* healthBar = new CHealthBar(this->getObjSceneNode(), this->smgr, 0);
healthBar->setParent(this->getObjSceneNode());
healthBar->setPosition(core::vector3df(0, 1, 0));
healthBar->addAnimator(anim);
anim->drop();
Thanks