mirror of https://github.com/Poikilos/b3view
fix frame-by-frame hotkeys, add menu items
parent
764933097f
commit
16230a0777
|
@ -404,7 +404,7 @@ std::wstring Engine::saveMesh(const io::path path, const std::string& nameOrBlan
|
|||
io::path fileName = io::path();
|
||||
std::string beginning = "export-";
|
||||
if (nameOrBlank.length() > 0) {
|
||||
beginning = nameOrBlank + "-";
|
||||
beginning = nameOrBlank + "#" + Utility::toString(static_cast<int>(round(m_LoadedMesh->getFrameNr()))) + "-";
|
||||
}
|
||||
std::string partial = beginning + Utility::dateTimeNowPathString();
|
||||
if (extension == "dae") {
|
||||
|
|
|
@ -31,6 +31,7 @@ void UserInterface::setupUserInterface()
|
|||
// Menu
|
||||
menu = m_Gui->addMenu();
|
||||
menu->addItem(L"File", UIE_FILEMENU, true, true);
|
||||
menu->addItem(L"Playback", UIE_PLAYBACKMENU, true, true);
|
||||
menu->addItem(L"View", UIE_VIEWMENU, true, true);
|
||||
|
||||
// File Menu
|
||||
|
@ -46,8 +47,23 @@ void UserInterface::setupUserInterface()
|
|||
fileMenu->addItem(L"Export STL (stereolithography)", UIC_FILE_EXPORT_STL);
|
||||
fileMenu->addItem(L"Quit", UIC_FILE_QUIT);
|
||||
|
||||
// Playback Menu
|
||||
playbackMenu = menu->getSubMenu(1);
|
||||
playbackMenu->addItem(L"Previous Frame Left",
|
||||
UIC_PLAYBACK_PREVIOUS, true, false,
|
||||
false, false);
|
||||
playbackMenu->addItem(L"Next Frame Right",
|
||||
UIC_PLAYBACK_NEXT, true, false,
|
||||
false, false);
|
||||
playbackMenu->addItem(L"Slower Ctrl Left",
|
||||
UIC_PLAYBACK_SLOWER, true, false,
|
||||
false, false);
|
||||
playbackMenu->addItem(L"Faster Ctrl Right",
|
||||
UIC_PLAYBACK_FASTER, true, false,
|
||||
false, false);
|
||||
|
||||
// View Menu
|
||||
viewMenu = menu->getSubMenu(1);
|
||||
viewMenu = menu->getSubMenu(2);
|
||||
viewWireframeIdx = viewMenu->addItem(L"Wireframe",
|
||||
UIC_VIEW_WIREFRAME, true,
|
||||
false, this->m_WireframeDisplay, true);
|
||||
|
@ -71,12 +87,6 @@ void UserInterface::setupUserInterface()
|
|||
viewZUpIdx = viewMenu->addItem(L"Z Up",
|
||||
UIC_VIEW_Z_UP, true, false,
|
||||
false, true);
|
||||
viewMenu->addItem(L"Slower Ctrl Left",
|
||||
UIC_VIEW_SLOWER, true, false,
|
||||
false, false);
|
||||
viewMenu->addItem(L"Faster Ctrl Right",
|
||||
UIC_VIEW_FASTER, true, false,
|
||||
false, false);
|
||||
|
||||
// Playback Control Window
|
||||
dimension2d<u32> windowSize = m_Engine->m_Driver->getScreenSize();
|
||||
|
@ -243,6 +253,24 @@ void UserInterface::displayLoadTextureDialog()
|
|||
true, nullptr, UIE_LOADTEXTUREDIALOG);
|
||||
}
|
||||
|
||||
void UserInterface::incrementFrame(f32 frameCount, bool enableRound)
|
||||
{
|
||||
if (this->m_Engine->m_LoadedMesh != nullptr) {
|
||||
if (this->m_Engine->isPlaying)
|
||||
this->m_Engine->toggleAnimation();
|
||||
this->m_Engine->m_LoadedMesh->setCurrentFrame(
|
||||
enableRound
|
||||
? (round(this->m_Engine->m_LoadedMesh->getFrameNr()) + frameCount)
|
||||
: (round(this->m_Engine->m_LoadedMesh->getFrameNr()) + frameCount)
|
||||
);
|
||||
this->playbackSetFrameEditBox->setText(
|
||||
Utility::toWstring(
|
||||
this->m_Engine->m_LoadedMesh->getFrameNr()
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void UserInterface::handleMenuItemPressed(IGUIContextMenu* menu)
|
||||
{
|
||||
s32 selected = menu->getSelectedItem();
|
||||
|
@ -308,6 +336,26 @@ void UserInterface::handleMenuItemPressed(IGUIContextMenu* menu)
|
|||
m_Engine->m_RunEngine = false;
|
||||
break;
|
||||
|
||||
case UIC_PLAYBACK_PREVIOUS:
|
||||
this->incrementFrame(-1.0f, true);
|
||||
break;
|
||||
|
||||
case UIC_PLAYBACK_NEXT:
|
||||
this->incrementFrame(1.0f, true);
|
||||
break;
|
||||
|
||||
case UIC_PLAYBACK_SLOWER:
|
||||
//if (ge->EventType == EGET_BUTTON_CLICKED) {
|
||||
this->m_Engine->incrementAnimationFPS(-5);
|
||||
//}
|
||||
break;
|
||||
|
||||
case UIC_PLAYBACK_FASTER:
|
||||
//if (ge->EventType == EGET_BUTTON_CLICKED) {
|
||||
this->m_Engine->incrementAnimationFPS(5);
|
||||
//}
|
||||
break;
|
||||
|
||||
case UIC_VIEW_WIREFRAME:
|
||||
m_WireframeDisplay = viewMenu->isItemChecked(viewWireframeIdx);
|
||||
m_Engine->setMeshDisplayMode(m_WireframeDisplay, m_Lighting,
|
||||
|
@ -611,6 +659,7 @@ bool UserInterface::OnEvent(const SEvent& event)
|
|||
const SEvent::SGUIEvent* ge = &(event.GUIEvent);
|
||||
switch (ge->Caller->getID()) {
|
||||
case UIE_FILEMENU:
|
||||
case UIE_PLAYBACKMENU:
|
||||
case UIE_VIEWMENU:
|
||||
// call handler for all menu related actions
|
||||
handleMenuItemPressed(static_cast<IGUIContextMenu*>(ge->Caller));
|
||||
|
@ -673,6 +722,7 @@ bool UserInterface::OnEvent(const SEvent& event)
|
|||
this->m_Engine->incrementAnimationFPS(-5);
|
||||
}
|
||||
break;
|
||||
|
||||
case UIE_PLAYBACKSETFRAMEEDITBOX:
|
||||
if (ge->EventType == EGET_EDITBOX_ENTER) {
|
||||
if (this->m_Engine->m_LoadedMesh != nullptr) {
|
||||
|
@ -763,43 +813,19 @@ bool UserInterface::OnEvent(const SEvent& event)
|
|||
|| m_Engine->KeyIsDown[irr::KEY_RCONTROL]) {
|
||||
m_Engine->incrementAnimationFPS(5);
|
||||
}
|
||||
else
|
||||
handled = false;
|
||||
else {
|
||||
incrementFrame(1.0f, true);
|
||||
}
|
||||
} else if (event.KeyInput.Key == irr::KEY_LEFT) {
|
||||
if (m_Engine->KeyIsDown[irr::KEY_LCONTROL]
|
||||
|| m_Engine->KeyIsDown[irr::KEY_RCONTROL]) {
|
||||
m_Engine->incrementAnimationFPS(-5);
|
||||
}
|
||||
else
|
||||
handled = false;
|
||||
else {
|
||||
incrementFrame(-1.0f, true);
|
||||
}
|
||||
} else if (event.KeyInput.Char == L' ') {
|
||||
m_Engine->toggleAnimation();
|
||||
} else if (event.KeyInput.Key == irr::KEY_LEFT) {
|
||||
if (this->m_Engine->m_LoadedMesh != nullptr) {
|
||||
if (m_Engine->isPlaying)
|
||||
m_Engine->toggleAnimation();
|
||||
this->m_Engine->m_LoadedMesh->setCurrentFrame(
|
||||
round(this->m_Engine->m_LoadedMesh->getFrameNr()) - 1
|
||||
);
|
||||
this->playbackSetFrameEditBox->setText(
|
||||
Utility::toWstring(
|
||||
this->m_Engine->m_LoadedMesh->getFrameNr()
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
} else if (event.KeyInput.Key == irr::KEY_RIGHT) {
|
||||
if (this->m_Engine->m_LoadedMesh != nullptr) {
|
||||
if (m_Engine->isPlaying)
|
||||
m_Engine->toggleAnimation();
|
||||
this->m_Engine->m_LoadedMesh->setCurrentFrame(
|
||||
round(this->m_Engine->m_LoadedMesh->getFrameNr()) + 1
|
||||
);
|
||||
this->playbackSetFrameEditBox->setText(
|
||||
Utility::toWstring(
|
||||
this->m_Engine->m_LoadedMesh->getFrameNr()
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
handled = false;
|
||||
|
|
|
@ -16,18 +16,20 @@ enum UserInterfaceElements {
|
|||
UIE_LOADTEXTUREDIALOG = 1200,
|
||||
UIE_SAVEFILEDIALOG = 1300,
|
||||
|
||||
UIE_VIEWMENU = 2000,
|
||||
UIE_PLAYBACKMENU = 2000,
|
||||
|
||||
UIE_PLAYBACKWINDOW = 3000,
|
||||
UIE_PLAYBACKSTARTSTOPBUTTON = 3001,
|
||||
UIE_PLAYBACKSETFRAMEEDITBOX = 3002,
|
||||
UIE_PLAYBACKINCREASEBUTTON = 3003,
|
||||
UIE_PLAYBACKDECREASEBUTTON = 3004,
|
||||
UIE_FPSEDITBOX = 3005,
|
||||
UIE_TEXTUREPATHSTATICTEXT = 3006,
|
||||
UIE_TEXTUREPATHEDITBOX = 3007,
|
||||
UIE_AXISSIZESTATICTEXT = 3008,
|
||||
UIE_AXISSIZEEDITBOX = 3009
|
||||
UIE_VIEWMENU = 3000,
|
||||
|
||||
UIE_PLAYBACKWINDOW = 10000,
|
||||
UIE_PLAYBACKSTARTSTOPBUTTON = 10001,
|
||||
UIE_PLAYBACKSETFRAMEEDITBOX = 10002,
|
||||
UIE_PLAYBACKINCREASEBUTTON = 10003,
|
||||
UIE_PLAYBACKDECREASEBUTTON = 10004,
|
||||
UIE_FPSEDITBOX = 10005,
|
||||
UIE_TEXTUREPATHSTATICTEXT = 10006,
|
||||
UIE_TEXTUREPATHEDITBOX = 10007,
|
||||
UIE_AXISSIZESTATICTEXT = 10008,
|
||||
UIE_AXISSIZEEDITBOX = 10009
|
||||
};
|
||||
|
||||
enum UserInterfaceCommands {
|
||||
|
@ -41,15 +43,17 @@ enum UserInterfaceCommands {
|
|||
UIC_FILE_EXPORT_IRRMESH = 1007,
|
||||
UIC_FILE_EXPORT_OBJ = 1008,
|
||||
UIC_FILE_EXPORT_STL = 1009,
|
||||
UIC_VIEW_WIREFRAME = 2001,
|
||||
UIC_VIEW_LIGHTING = 2002,
|
||||
UIC_VIEW_AXIS_WIDGET = 2003,
|
||||
UIC_VIEW_TARGET = 2004,
|
||||
UIC_VIEW_TEXTURE_INTERPOLATION = 2005,
|
||||
UIC_VIEW_Y_UP = 2006,
|
||||
UIC_VIEW_Z_UP = 2007,
|
||||
UIC_VIEW_SLOWER = 2008,
|
||||
UIC_VIEW_FASTER = 2009
|
||||
UIC_PLAYBACK_PREVIOUS = 2001,
|
||||
UIC_PLAYBACK_NEXT = 2002,
|
||||
UIC_PLAYBACK_SLOWER = 2003,
|
||||
UIC_PLAYBACK_FASTER = 2004,
|
||||
UIC_VIEW_WIREFRAME = 3001,
|
||||
UIC_VIEW_LIGHTING = 3002,
|
||||
UIC_VIEW_AXIS_WIDGET = 3003,
|
||||
UIC_VIEW_TARGET = 3004,
|
||||
UIC_VIEW_TEXTURE_INTERPOLATION = 3005,
|
||||
UIC_VIEW_Y_UP = 3006,
|
||||
UIC_VIEW_Z_UP = 3007
|
||||
};
|
||||
|
||||
class UserInterface : public irr::IEventReceiver {
|
||||
|
@ -64,6 +68,7 @@ private:
|
|||
void displayLoadFileDialog();
|
||||
void displaySaveFileDialog();
|
||||
void displayLoadTextureDialog();
|
||||
void incrementFrame(irr::f32 frameCount, bool enableRound);
|
||||
void handleMenuItemPressed(irr::gui::IGUIContextMenu* menu);
|
||||
|
||||
bool m_WireframeDisplay;
|
||||
|
@ -74,6 +79,7 @@ private:
|
|||
public:
|
||||
irr::gui::IGUIContextMenu* menu;
|
||||
irr::gui::IGUIContextMenu* fileMenu;
|
||||
irr::gui::IGUIContextMenu* playbackMenu;
|
||||
irr::gui::IGUIContextMenu* viewMenu;
|
||||
irr::gui::IGUIButton* playbackStartStopButton;
|
||||
irr::gui::IGUIEditBox* playbackSetFrameEditBox;
|
||||
|
|
|
@ -276,6 +276,11 @@ bool Utility::isFile(const std::wstring& name)
|
|||
}
|
||||
}
|
||||
|
||||
std::string Utility::toString(int val)
|
||||
{
|
||||
return std::to_string(val);
|
||||
}
|
||||
|
||||
std::string Utility::toString(irr::f32 val)
|
||||
{
|
||||
return std::to_string(val);
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
static std::wstring delimiter(const std::wstring& path);
|
||||
static bool isFile(const std::string& name);
|
||||
static bool isFile(const std::wstring& name);
|
||||
static std::string toString(int val);
|
||||
static std::string toString(irr::f32 val);
|
||||
static std::string toString(const std::wstring& name);
|
||||
static std::string toLower(const std::string& s);
|
||||
|
|
Loading…
Reference in New Issue