I'm new to Irrlicht, and I'm making a simple GUI to load some meshes. I've not had any problems except after I make a call to SetPosition() on some meshes.
Here's the gist of my main function:
Code: Select all
int main()
{
IrrlichtDevice* device;
IVideoDriver* driver;
IGUIEnvironment* guienv;
device = createDevice(driverChoiceConsole(),dimension2d<u32>(800,600), 16, false, false, false, NULL);
if (!device){
cerr << "Error: Could not create device" << endl;;
return 1;
}
device->setResizable(true);
driver = device->getVideoDriver();
guienv = device->getGUIEnvironment();
IGUISkin* skin = guienv->getSkin();
IGUIFont* font = guienv->getFont("../../media/fonthaettenschweiler.bmp");
if (font) skin->setFont(font);
skin->setFont(guienv->getBuiltInFont(),EGDF_TOOLTIP);//have the tooltip font be the built-in one
guienv->addButton(rect<s32>(10,240,110,240 + 32), 0, GUI_ID_QUIT_BUTTON,
L"Quit", L"Exits Program");
guienv->addButton(rect<s32>(10,280,110,280 + 32), 0, GUI_ID_LOAD_SCENE_BUTTON,
L"Load Scene", L"Choose .scene file to load");
guienv->addButton(rect<s32>(10,320,110,320 + 32), 0, GUI_ID_LOAD_INPUT_BUTTON,
L"Load Input", L"Choose input file to load");
guienv->addButton(rect<s32>(10,360,110,360 + 32), 0, GUI_ID_LOAD_STATES_BUTTON,
L"Load States", L"Load vector of states");
IGUIButton* renderB = guienv->addButton(rect<s32>(10,400,110,400 + 32), 0,
GUI_ID_RENDER_BUTTON,
L"RENDER", L"Begin rendering");
renderB->setEnabled(false);
AppContext context;
..some unimportant stuff
MyEventReceiver receiver(context);
device->setEventReceiver(&receiver);
while(device->run() && driver){
if (device->isWindowActive()){
driver->beginScene(true,true,SColor(0,200,200,200));
device->getSceneManager()->drawAll();
context.scene->UpdateScene(); //will eventually call setPosition on some meshes, causing my problem
guienv->drawAll();
driver->endScene();
}
else device->yield();
}
device->drop();
return 0;
}
This code works fine until I click the button I defined as "Load States". What Load States does is essentially use pre-computed position/rotation information about objects in the scene, and just calls SetPosition() and SetRotation on them. I have narrowed down the problem to be in the SetPosition call:
Here's the gist of the function:
Code: Select all
for(int i=0; i<(int)states.size(); i++) {
core::vector3df vec = positions.at(m_frameNum).at(i);
core::vector3df rot = rotations.at(m_frameNum).at(i);
states[(irr::s32)i]->setRotation( rot );
states[(irr::s32)i]->setPosition(vec);
}
I've looked at the actual values in vec, and there's no "nan" or junk values like that. In fact, I determined that the issue is that SetPosition seems to fail when I give it a value greater than 120.0 in Z (EDIT: The actual failure range is from 120.0 to 470.0. Any value inside [non-inclusive] causes the gibberish text, while other values are fine). This is a problem because I need to set Z values of at least 260.0.
I don't see this issue when I use large values in X or Y; only for Z. 119.0 works, 120.0 works, but 121.0 and up causes the gibberish text on my buttons. It doesn't show the same issue when I go negative either; -121.0 works just fine.
Note: the SetPosition() call only results in junk text on my GUI; otherwise it correctly sets positions.
Can anybody shed light on this?
Edit: Some more information: I'm running Irrlicht 1.7.2 on Ubuntu 12.04 on a 64-bit machine. My graphics card is an integrated nVidia one. I'd be happy to provide more detailed specs on my system if anyone thinks it will help.