[fixed]Is there a bug in the scene saving commands?
Posted: Sat Aug 13, 2016 7:32 pm
I don't know what could be causing it, but i've tumbled upon a bug which can't be but from the engine because it only uses irr commands to work, concretely the save scene and load scene commands from the scene manager.
code:
I am trying to work on a custom irrlicht scene editor (pretty much like the irrEdit, but simpler, and tweakable for my own needs) and to my surprise, i've found that the animated meshes get squashed and flat when they're loaded from a scene file. I can't point to a posible cause, i can give away the whole project code if you want to take a look because i use a custom node (an upgraded editor grid)
http://omegasection.g0dsoft.com/wp-content/uploads/2016/08/simpleEd.zip
This is the result of it. It is the dwarf, but it looks like its height is reduced to 0

A posible way to repeat the process is to load normally some animated meshes, save the resulting scene via saveScene
code:
Code: Select all
bool onLoadScene::OnEvent(const irr::SEvent& event)
{
bool result = false;
if (event.EventType == EET_GUI_EVENT)
if (event.GUIEvent.EventType == gui::EGET_MENU_ITEM_SELECTED)
{
gui::IGUIContextMenu* menu = (gui::IGUIContextMenu*)event.GUIEvent.Caller;
if (menu->getItemCommandId(menu->getSelectedItem()) == EGUIMENUFILELOADSCENE)
{
gui->addFileOpenDialog(langPack::fileloadscene.c_str(),true,0,EGUIMENUFILELOADSCENEDIALOG,true);
result = true;
}
}
else
{
if (event.GUIEvent.EventType == gui::EGET_FILE_SELECTED)
{
gui::IGUIFileOpenDialog* dlg = (gui::IGUIFileOpenDialog*)event.GUIEvent.Caller;
if (dlg->getID() == EGUIMENUFILELOADSCENEDIALOG)
{
scene::ICameraSceneNode* cam = manager->getActiveCamera();
core::vector3df camPos, camTarget;
camPos = cam->getPosition();
camTarget = cam->getTarget();
manager->clear();
manager->loadScene(dlg->getFileNameP());
cam = manager->addCameraSceneNodeMaya(0, -700.0f, 400, 90, EGUIMENUVIEWCAMERA, 40);
cam->setPosition(camPos);
cam->setTarget(camTarget);
}
}
}
return result;
}
bool onSaveSceneAs::OnEvent(const irr::SEvent& event)
{
bool result = false;
gui::IGUIButton* btn;
gui::IGUIListBox* lbx;
core::stringw textConvert;
gui::IGUISkin* skn;
if (event.EventType == EET_GUI_EVENT)
{
if (event.GUIEvent.EventType == gui::EGET_MENU_ITEM_SELECTED)
{
gui::IGUIContextMenu* menu = (gui::IGUIContextMenu*)event.GUIEvent.Caller;
if (menu->getItemCommandId(menu->getSelectedItem()) == EGUIMENUFILESAVEAS)
{
s32 width = 400;
s32 height = 310;
core::recti rec = gui->getRootGUIElement()->getAbsoluteClippingRect();
core::dimension2di resolution;
resolution.Width = rec.LowerRightCorner.X - rec.UpperLeftCorner.X;
resolution.Height = rec.LowerRightCorner.Y - rec.UpperLeftCorner.Y;
win = gui->addWindow(
core::recti(
(resolution.Width - width) / 2,
(resolution.Height - height) / 2,
(resolution.Width + width) / 2,
(resolution.Height + height) / 2),
true, langPack::filesaveas.c_str(), NULL, EGUIMENUFILESAVEAS);
filename = gui->addEditBox(0, core::recti(10, 30, width - 90, 50), true, win, EGUIFILESAVEASEDITFILENAME);
filelist = gui->addListBox(core::recti(10, 55, width - 90, 280), win, -1, true);
Accept = gui->addButton(core::recti(width - 80, 30, width - 10, 50), win, EGUIFILESAVEASACCEPTBUTTON, L"Accept");
Cancel = gui->addButton(core::recti(width - 80, 55, width - 10, 75), win, EGUIFILESAVEASCANCELBUTTON, L"Cancel");
gui->addStaticText(langPack::filesaveaswarning.c_str(), core::recti(10, height - 25, width - 10, height - 5), false, true, win);
io::IFileSystem* fs = gui->getFileSystem();
skn = gui->getSkin();
currentDirectory = fs->getWorkingDirectory();
fl = fs->createFileList();
for (u32 i = 0; i < fl->getFileCount(); ++i)
{
textConvert = core::stringw(fl->getFileName(i));
filelist->addItem(textConvert.c_str(), skn->getIcon(fl->isDirectory(i) ? gui::EGDI_DIRECTORY : gui::EGDI_FILE));
}
fl->drop();
result = true;
}
}
switch (event.GUIEvent.EventType)
{
case gui::EGET_BUTTON_CLICKED:
btn = (gui::IGUIButton*)event.GUIEvent.Caller;
if (btn==Accept)
{
io::path savefilename;
savefilename = gui->getFileSystem()->getWorkingDirectory();
savefilename.append('/');
savefilename += filename->getText();
manager->saveScene(savefilename);
win->remove();
result = true;
}
if (btn == Cancel)
{
win->remove();
gui->getFileSystem()->changeWorkingDirectoryTo(currentDirectory);
result = true;
}
break;
case gui::EGET_LISTBOX_SELECTED_AGAIN:
lbx = (gui::IGUIListBox*)event.GUIEvent.Caller;
if (lbx == filelist)
{
io::IFileSystem* fs = gui->getFileSystem();
if (fs->changeWorkingDirectoryTo(lbx->getListItem(lbx->getSelected())))
{
filelist->clear();
io::IFileList* fl = fs->createFileList();
skn = gui->getSkin();
for (u32 i = 0; i < fl->getFileCount(); ++i)
{
textConvert = core::stringw(fl->getFileName(i));
filelist->addItem(textConvert.c_str(), skn->getIcon(fl->isDirectory(i) ? gui::EGDI_DIRECTORY : gui::EGDI_FILE));
}
fl->drop();
}
else
{
filename->setText(lbx->getListItem(lbx->getSelected()));
}
result = true;
}
break;
}
}
return result;
}
http://omegasection.g0dsoft.com/wp-content/uploads/2016/08/simpleEd.zip
This is the result of it. It is the dwarf, but it looks like its height is reduced to 0

A posible way to repeat the process is to load normally some animated meshes, save the resulting scene via saveScene