allow going frame by frame or typing a frame

master
poikilos 2019-04-03 10:35:27 -04:00
parent d9af477575
commit 8a61dea048
9 changed files with 86 additions and 1 deletions

View File

@ -400,6 +400,7 @@ void Engine::run()
if (this->m_LoadedMesh != nullptr) {
if (isPlaying) {
this->m_LoadedMesh->setLoopMode(true);
this->m_UserInterface->playbackSetFrameEditBox->setText(Utility::toWstring(this->m_LoadedMesh->getFrameNr()).c_str());
}
else {
this->m_LoadedMesh->setLoopMode(false);

View File

@ -78,6 +78,15 @@ void UserInterface::setupUserInterface()
nullptr
);
y += size_y + spacing_y;
playbackSetFrameEditBox = m_Gui->addEditBox(
L"",
rect<s32>( vector2d<s32>( spacing_x, y ), dimension2d<s32>( size_x, size_y )),
true,
playbackWindow,
UIE_PLAYBACKSETFRAMEEDITBOX
);
// Set Font for UI Elements
m_GuiFontFace = new CGUITTFace();
// irrString defines stringc as string<c8>
@ -288,6 +297,20 @@ bool UserInterface::OnEvent( const SEvent &event )
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());
}
}
// std::wcerr << "Char: " << event.KeyInput.Char << endl;
}
m_Engine->KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
@ -372,6 +395,13 @@ bool UserInterface::OnEvent( const SEvent &event )
}
}
break;
case UIE_PLAYBACKSETFRAMEEDITBOX:
if ( ge->EventType == EGET_EDITBOX_ENTER) {
if (this->m_Engine->m_LoadedMesh != nullptr) {
this->m_Engine->m_LoadedMesh->setCurrentFrame(Utility::toF32(this->playbackSetFrameEditBox->getText()));
}
}
break;
default:
break;

View File

@ -17,7 +17,8 @@ enum UserInterfaceElements
UIE_VIEWMENU = 1005,
UIE_LOADTEXTUREDIALOG = 1006,
UIE_PLAYBACKINCREASEBUTTON = 1007,
UIE_PLAYBACKDECREASEBUTTON = 1008
UIE_PLAYBACKDECREASEBUTTON = 1008,
UIE_PLAYBACKSETFRAMEEDITBOX = 1009
};
enum UserInterfaceCommands
@ -49,6 +50,7 @@ public:
irr::gui::IGUIButton *playbackStartStopButton;
irr::gui::IGUIButton *playbackIncreaseButton;
irr::gui::IGUIButton *playbackDecreaseButton;
irr::gui::IGUIEditBox *playbackSetFrameEditBox;
UserInterface( Engine *device );
~UserInterface();

View File

@ -7,6 +7,7 @@
#include <cmath>
#include <cwctype> // #include <cwtype>
#include <algorithm>
#include <sstream>
#include "Debug.h"
@ -176,6 +177,24 @@ wstring Utility::toLower(const wstring &s)
return ret;
}
wstring Utility::toWstring(irr::f32 val)
{
return std::to_wstring(val);
}
wstring Utility::toWstring(int val)
{
return std::to_wstring(val);
}
irr::f32 Utility::toF32(wstring val)
{
std::wstringstream ss(val);
irr::f32 ret = 0;
ss >> ret;
return ret;
}
bool Utility::isFile(const std::wstring& name) {
std::string name_s = toString(name);
if (FILE *file = fopen(name_s.c_str(), "r")) {
@ -186,6 +205,11 @@ bool Utility::isFile(const std::wstring& name) {
}
}
std::string Utility::toString(irr::f32 val)
{
return std::to_string(val);
}
//don't do late instantiation (see header file)
//template<typename T>

View File

@ -17,9 +17,13 @@ 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(irr::f32 val);
static std::string toString(const std::wstring &name);
static std::string toLower(const std::string &s);
static std::wstring toLower(const std::wstring &s);
static std::wstring toWstring(irr::f32 val);
static std::wstring toWstring(int val);
static irr::f32 toF32(std::wstring val);
// compiler doesn't like template function when class is not a template--instantiate immediately
// see http://processors.wiki.ti.com/index.php/C%2B%2B_Template_Instantiation_Issues
template <typename T>

0
build/install.sh Normal file → Executable file
View File

View File

@ -0,0 +1,20 @@
[Desktop Entry]
Comment[en_US]=
Comment=
GenericName[en_US]=Irrlicht Model Viewer
GenericName=Irrlicht Model Viewer
MimeType=
Name[en_US]=b3view
Name=b3view
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=
Exec=owner/.local/bin/b3view
Icon=owner/.local/share/icons/b3view.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 B

4
install.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
echo "Use the install.sh in build instead. Switching to build/install.sh..." && cd build || echo "ERROR: No build directory" && exit 1
chmod +x install.sh
./install.sh