File output switch

actorid
Jason Hooks 13 years ago
parent 7fde576dd9
commit eab69f18ac

@ -19,6 +19,7 @@
#include <components/esm/esm_reader.hpp>
#include <components/files/path.hpp>
#include <components/nifbullet/bullet_nif_loader.hpp>
#include <components/nifogre/ogre_nif_loader.hpp>
#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

@ -158,6 +158,8 @@ namespace OMW
/// Font encoding
void setEncoding(const std::string& encoding);
void setAnimationVerbose(bool animverbose);
private:
Cfg::ConfigurationManager& mCfgMgr;
};

@ -78,6 +78,9 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Cfg::Configuratio
("fps", boost::program_options::value<bool>()->implicit_value(true)
->default_value(false), "show fps counter")
("anim-verbose", boost::program_options::value<bool>()->implicit_value(true)
->default_value(false), "output animation indices files")
("debug", boost::program_options::value<bool>()->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<bool>());
engine.setCompileAll(variables["script-all"].as<bool>());
engine.setReportFocus(variables["report-focus"].as<bool>());
engine.setAnimationVerbose(variables["anim-verbose"].as<bool>());
return true;
}

@ -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<Nif::NiTextKeyExtraData*> (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<Nif::NiTextKeyExtraData::TextKey>::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;
}

@ -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<std::string,std::string> MaterialMap;
// pointer to the ogre mesh which is currently build
@ -185,6 +189,7 @@ class NIFLoader : Ogre::ManualResourceLoader
std::vector<Ogre::Mesh*> addin;
std::vector<Nif::NiKeyframeData> mAnim;
std::vector<Nif::NiTriShapeCopy> mS;
};
}

Loading…
Cancel
Save