Code: Select all
void CTextSceneNode::render()
{
if (!Font || !Coll)
return;
/////////////////////////////////////////////////////////////////////
video::IVideoDriver* driver = SceneManager->getVideoDriver();
ICameraSceneNode* camera = SceneManager->getActiveCamera();
if (!camera || !driver)
return;
if (DebugDataVisible)
{
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
video::SMaterial m;
m.Lighting = false;
driver->setMaterial(m);
driver->draw3DBox(Box, video::SColor(0,208,195,152));
}
//////////////////////////////////////////////////////////////////////
core::position2d<s32> pos = Coll->getScreenCoordinatesFrom3DPosition(getAbsolutePosition(),
SceneManager->getActiveCamera());
core::rect<s32> r(pos, core::dimension2d<s32>(1,1));
Font->draw(Text.c_str(), r, Color, true, true);
}
Code: Select all
void CTextSceneNode::setText(const wchar_t* text)
{
Text = text;
//////////////////////////////////////////////////////////
//Set Bounding box
core::dimension2d<s32> dim = Font->getDimension(text);
f32 halfWidth = (f32)dim.Width/2;
f32 halfHeight = (f32)dim.Height/2;
Box.MinEdge.set(-halfWidth,-halfHeight,-1.0);
Box.MaxEdge.set(halfWidth,halfHeight,1.0);
///////////////////////////////////////////////////////////
}
Text = text;
to
setText(text);
AND
add this include
#include "IVideoDriver.h"
That should do it. Now you can pick this item with a selector.
Matt