From eab69f18ac7ab2d0988d39d98420464b3a02d687 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Tue, 10 Jan 2012 00:34:29 -0500 Subject: [PATCH] File output switch --- apps/openmw/engine.cpp | 7 ++++++ apps/openmw/engine.hpp | 2 ++ apps/openmw/main.cpp | 4 ++++ components/nifogre/ogre_nif_loader.cpp | 31 ++++++++++++++++---------- components/nifogre/ogre_nif_loader.hpp | 9 ++++++-- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 5d235b5d1..c4623b375 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "mwinput/inputmanager.hpp" @@ -45,6 +46,7 @@ #include "mwmechanics/mechanicsmanager.hpp" + void OMW::Engine::executeLocalScripts() { MWWorld::LocalScripts& localScripts = mEnvironment.mWorld->getLocalScripts(); @@ -99,6 +101,11 @@ void OMW::Engine::updateFocusReport (float duration) } } +void OMW::Engine::setAnimationVerbose(bool animverbose){ + if(animverbose) + NifOgre::NIFLoader::getSingletonPtr()->setOutputAnimFiles(true); +} + bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) { try diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 443f790a4..741d46624 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -158,6 +158,8 @@ namespace OMW /// Font encoding void setEncoding(const std::string& encoding); + void setAnimationVerbose(bool animverbose); + private: Cfg::ConfigurationManager& mCfgMgr; }; diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 933d1c48a..6e26d6258 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -78,6 +78,9 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Cfg::Configuratio ("fps", boost::program_options::value()->implicit_value(true) ->default_value(false), "show fps counter") + ("anim-verbose", boost::program_options::value()->implicit_value(true) + ->default_value(false), "output animation indices files") + ("debug", boost::program_options::value()->implicit_value(true) ->default_value(false), "debug mode") @@ -206,6 +209,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Cfg::Configuratio engine.setScriptsVerbosity(variables["script-verbose"].as()); engine.setCompileAll(variables["script-all"].as()); engine.setReportFocus(variables["report-focus"].as()); + engine.setAnimationVerbose(variables["anim-verbose"].as()); return true; } diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 380301551..c1d05ef2f 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -201,6 +201,9 @@ static CompareFunction getTestMode(int mode) } */ +void NIFLoader::setOutputAnimFiles(bool output){ + mOutputAnimFiles = output; +} void NIFLoader::createMaterial(const String &name, const Vector &ambient, const Vector &diffuse, @@ -984,19 +987,22 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, if (e->recType == RC_NiTextKeyExtraData){ Nif::NiTextKeyExtraData* extra = dynamic_cast (e); + std::ofstream file; + + if(mOutputAnimFiles){ + std::string cut = ""; + for(unsigned int i = 0; i < name.length(); i++) + { + if(!(name.at(i) == '\\' || name.at(i) == '/' || name.at(i) == '>' || name.at(i) == '<' || name.at(i) == '?' || name.at(i) == '*' || name.at(i) == '|' || name.at(i) == ':' || name.at(i) == '"')) + { + cut += name.at(i); + } + } - std::string cut = ""; - for(unsigned int i = 0; i < name.length(); i++) - { - if(!(name.at(i) == '\\' || name.at(i) == '/' || name.at(i) == '>' || name.at(i) == '<' || name.at(i) == '?' || name.at(i) == '*' || name.at(i) == '|' || name.at(i) == ':' || name.at(i) == '"')) - { - cut += name.at(i); - } - } - - std::cout << "Outputting " << cut << "\n"; + std::cout << "Outputting " << cut << "\n"; - std::ofstream file(("Indices" + cut + ".txt").c_str()); + file.open(("Indices" + cut + ".txt").c_str()); + } for(std::vector::iterator textiter = extra->list.begin(); textiter != extra->list.end(); textiter++) { @@ -1021,7 +1027,8 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, //length = text.length() - first; std::string sub = text.substr(first, length); - file << "Time: " << textiter->time << "|" << sub << "\n"; + if(mOutputAnimFiles) + file << "Time: " << textiter->time << "|" << sub << "\n"; textmappings[sub] = textiter->time; } diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index ef6374b23..2cacb6728 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -117,12 +117,15 @@ class NIFLoader : Ogre::ManualResourceLoader Ogre::Vector3 convertVector3(const Nif::Vector& vec); Ogre::Quaternion convertRotation(const Nif::Matrix& rot); + void setOutputAnimFiles(bool output); + private: - NIFLoader() : resourceGroup("General"),mNormaliseNormals(false), - mFlipVertexWinding(false), flip(false) {resourceName = "";} + NIFLoader() : mNormaliseNormals(false), resourceGroup("General"), resourceName(""), flip(false), + mFlipVertexWinding(false), mOutputAnimFiles(false) {} NIFLoader(NIFLoader& n) {} void calculateTransform(); + void warn(std::string msg); void fail(std::string msg); @@ -168,6 +171,7 @@ class NIFLoader : Ogre::ManualResourceLoader bool mNormaliseNormals; bool mFlipVertexWinding; bool bNiTri; + bool mOutputAnimFiles; std::multimap MaterialMap; // pointer to the ogre mesh which is currently build @@ -185,6 +189,7 @@ class NIFLoader : Ogre::ManualResourceLoader std::vector addin; std::vector mAnim; std::vector mS; + }; }