Also I have a qustion - to show only text, for my code, I used ITextSceneNode - it is good idea ?
Code:
Code: Select all
#include <irrlicht.h>
#include <ctime>
#include <cstdlib>
using namespace irr;
#define WIDTH_DIMENSION 512
#define HEIGHT_DIMENSION 384
#define WIDTH_MARGIN 5
#define HEIGHT_MARGIN 5
int main()
{
irr::core::stringw str [] =
{
L"a", L"b", L"c", L"d", L"e", L"f", L"g", L"h", L"i",
L"j", L"k", L"l", L"1", L"2", L"3", L"4", L"5", L"6",
L"A", L"B", L"C", L"D", L"E", L"F", L"G", L"H", L"I",
L"m", L"n", L"o", L"p", L"r", L"s", L"t", L"u", L"w",
L"7", L"8", L"9", L"!", L"@", L"#", L"$", L"&", L"J",
L"K", L"L", L"M", L"N", L"O", L"P", L"R", L"S", L"T",
L"x", L"y", L"z", L"U", L"W", L"X", L"Y", L"Z"
}; //62
std::srand(std::time(NULL));
IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9,
core::dimension2d<u32>(WIDTH_DIMENSION, HEIGHT_DIMENSION), 32, false, true, true);
if (device == 0)
return 1; // could not create selected driver.
device->setWindowCaption(L"Irrlicht Engine - Matrix Banner");
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager *smgr = device->getSceneManager();
irr::scene::ICameraSceneNode *cam = smgr->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(0,0,0), 1000);
gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();
bool width_end;
bool height_end = false;
f32 width = 0;
f32 height = 0;
/*while (height_end == false)
{
width_end = false;
width = 0;
while(width_end == false)
{
smgr->addTextSceneNode(font, str[(rand()%62)].c_str() ,
video::SColor(255,255,255,255), 0, irr::core::vector3df(width, height, 0));
width += WIDTH_MARGIN;
if(width > WIDTH_DIMENSION) width_end = true;
}
height += HEIGHT_MARGIN;
if(height > HEIGHT_DIMENSION) height_end = true;
}*/
irr::scene::ITextSceneNode *sc = smgr->addTextSceneNode(font, str[(rand()%62)].c_str() ,
video::SColor(255,255,255,255), 0, irr::core::vector3df(0, 0, 0));
while(device->run() && driver)
{
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(255,0,0,0));
// try to move camera
irr::core::vector3df v = cam->getPosition();
++v.X;
++v.Y;
cam->setPosition(v);
//try to move ITextSceneNode
v = sc->getPosition();
++v.X;
++v.Y;
sc->setPosition(v);
//find and move ITextSceneNode
smgr->getSceneNodeFromId(1000)->setPosition(irr::core::vector3df(++width, ++height, 0));
smgr->drawAll();
driver->endScene();
}
}
device->drop();
return 0;
}