export (current frame)

master
poikilos 2019-05-02 21:17:24 -04:00
parent cc257b386b
commit c9860273e0
4 changed files with 44 additions and 0 deletions

View File

@ -389,6 +389,25 @@ void Engine::reloadMesh()
}
}
void Engine::saveMesh(const io::path path)
{
// see also https://bitbucket.org/mzeilfelder/irr-playground-micha/src/default/obj_readwrite.cpp (saves scene::EMWT_OBJ)
scene::ISceneManager* smgr = m_Device->getSceneManager();
scene::IMeshWriter* meshWriter = smgr->createMeshWriter(scene::EMWT_COLLADA);
//this->m_FileName = "";
io::path fileName = "export.dae";
//io::path filePath = path + fileName;
io::path filePath = fileName;
io::IWriteFile* meshFile = m_Device->getFileSystem()->createAndWriteFile(filePath);
if (!meshWriter->writeMesh(meshFile, m_LoadedMesh->getMesh())) {
debug() << "saving failed" << endl;
}
else
debug() << "saving ok" << endl;
meshFile->drop();
meshWriter->drop();
}
void Engine::reloadTexture()
{
if (this->m_PrevTexturePath.length() > 0) {

View File

@ -78,6 +78,7 @@ public:
void run();
void loadMesh(const std::wstring& fileName);
void reloadMesh();
void saveMesh(const irr::io::path path);
void reloadTexture();
bool loadTexture(const std::wstring& fileName);
void setMeshDisplayMode(bool wireframe = false, bool lighting = true, bool textureInterpolation = true);

View File

@ -39,6 +39,7 @@ void UserInterface::setupUserInterface()
fileMenu->addItem(L"Change Texture", UIC_FILE_OPEN_TEXTURE);
fileMenu->addItem(L"Previous Texture Shift F3", UIC_FILE_PREVIOUS_TEXTURE);
fileMenu->addItem(L"Next Texture F3", UIC_FILE_NEXT_TEXTURE);
fileMenu->addItem(L"Export", UIC_FILE_EXPORT);
fileMenu->addItem(L"Quit", UIC_FILE_QUIT);
// View Menu
@ -225,6 +226,13 @@ void UserInterface::displayLoadFileDialog()
true, nullptr, UIE_LOADFILEDIALOG);
}
void UserInterface::displaySaveFileDialog()
{
m_Gui->addFileOpenDialog(L"Select where to save export.dae",
true, nullptr, UIE_SAVEFILEDIALOG);
// NOTE: if restoreCWD is false (default), cwd changes.
}
void UserInterface::displayLoadTextureDialog()
{
m_Gui->addFileOpenDialog(L"Select file to load",
@ -242,6 +250,13 @@ void UserInterface::handleMenuItemPressed(IGUIContextMenu* menu)
displayLoadFileDialog();
break;
case UIC_FILE_EXPORT:
if (this->m_Engine->m_LoadedMesh != nullptr) {
// this->m_Engine->m_LoadedMesh->getName();
displaySaveFileDialog();
}
break;
case UIC_FILE_OPEN_TEXTURE:
displayLoadTextureDialog();
break;
@ -506,6 +521,12 @@ bool UserInterface::OnEvent(const SEvent& event)
m_Engine->loadMesh(fileOpenDialog->getFileName());
}
break;
case UIE_SAVEFILEDIALOG:
if (ge->EventType == EGET_FILE_SELECTED) {
IGUIFileOpenDialog* fileOpenDialog = static_cast<IGUIFileOpenDialog*>(ge->Caller);
m_Engine->saveMesh(fileOpenDialog->getDirectoryName());
}
break;
case UIE_LOADTEXTUREDIALOG:
if (ge->EventType == EGET_FILE_SELECTED) {

View File

@ -12,6 +12,7 @@ enum UserInterfaceElements {
UIE_LOADFILEDIALOG = 1100,
// UIE_LOADBUTTON = 1101,
UIE_LOADTEXTUREDIALOG = 1200,
UIE_SAVEFILEDIALOG = 1300,
UIE_VIEWMENU = 2000,
@ -33,6 +34,7 @@ enum UserInterfaceCommands {
UIC_FILE_OPEN_TEXTURE = 1002,
UIC_FILE_NEXT_TEXTURE = 1003,
UIC_FILE_PREVIOUS_TEXTURE = 1004,
UIC_FILE_EXPORT = 1005,
UIC_VIEW_WIREFRAME = 2001,
UIC_VIEW_LIGHTING = 2002,
UIC_VIEW_AXIS_WIDGET = 2003,
@ -54,6 +56,7 @@ private:
void setupUserInterface();
void displayLoadFileDialog();
void displaySaveFileDialog();
void displayLoadTextureDialog();
void handleMenuItemPressed(irr::gui::IGUIContextMenu* menu);