diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 9e14c119b..d0f09c214 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -42,6 +42,8 @@ #include "mwgui/class.hpp" + + //using namespace ESM; void OMW::Engine::executeLocalScripts() @@ -75,8 +77,8 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) std::string effect; - - + + MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell(); //If the region has changed if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){ @@ -86,7 +88,7 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) total = 0; test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region)); } - + if(test.soundList.size() > 0) { std::vector::iterator soundIter = test.soundList.begin(); @@ -118,14 +120,14 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) //play sound std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; mEnvironment.mSoundManager->playSound(effect, 20.0, 1.0); - + break; } pos += chance; } } - + //mEnvironment.mSoundManager->playSound(effect, 1.0, 1.0); //printf("REGION: %s\n", test.name); @@ -194,7 +196,6 @@ OMW::Engine::Engine() , mVerboseScripts (false) , mNewGame (false) , mUseSound (true) - , mCompileAll (false) , mScriptManager (0) , mScriptContext (0) , mGuiManager (0) @@ -297,7 +298,7 @@ void OMW::Engine::go() test.name = ""; total = 0; - + std::cout << "Data directory: " << mDataDir << "\n"; @@ -307,6 +308,16 @@ void OMW::Engine::go() addResourcesDirectory (mDataDir / "Meshes"); addResourcesDirectory (mDataDir / "Textures"); + //boost::filesystem::copy_file("meshes\\b\\B_N_Argonian_F_Skins.nif",mDataDir / "b2\\B_N_Argonian_F_Skins.nif",boost::filesystem::copy_option::overwrite_if_exists); + /*CFileOperation fo; // create object + + fo.SetOverwriteMode(false); // reset OverwriteMode flag (optional) + + if (!fo.Copy("c:\\source", "c:\\dest")) // do Copy + { + fo.ShowError(); // if copy fails show error message + }*/ + // This has to be added BEFORE MyGUI is initialized, as it needs // to find core.xml here. @@ -327,7 +338,6 @@ void OMW::Engine::go() MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); // Create window manager - this manages all the MW-specific GUI windows MWScript::registerExtensions (mExtensions); @@ -361,20 +371,9 @@ void OMW::Engine::go() // load cell ESM::Position pos; + pos.pos[0] = pos.pos[1] = pos.pos[2] = 0; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; - pos.pos[2] = 0; - - if (const ESM::Cell *exterior = mEnvironment.mWorld->getExterior (mCellName)) - { - mEnvironment.mWorld->indexToPosition (exterior->data.gridX, exterior->data.gridY, - pos.pos[0], pos.pos[1], true); - mEnvironment.mWorld->changeToExteriorCell (pos); - } - else - { - pos.pos[0] = pos.pos[1] = 0; - mEnvironment.mWorld->changeCell (mCellName, pos); - } + mEnvironment.mWorld->changeCell (mCellName, pos); // Sets up the input system MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(), @@ -390,29 +389,6 @@ void OMW::Engine::go() // Play some good 'ol tunes mEnvironment.mSoundManager->startRandomTitle(); - // scripts - if (mCompileAll) - { - typedef ESMS::ScriptListT::MapType Container; - - Container scripts = mEnvironment.mWorld->getStore().scripts.list; - - int count = 0; - int success = 0; - - for (Container::const_iterator iter (scripts.begin()); iter!=scripts.end(); ++iter, ++count) - if (mScriptManager->compile (iter->first)) - ++success; - - if (count) - std::cout - << "compiled " << success << " of " << count << " scripts (" - << 100*static_cast (success)/count - << "%)" - << std::endl; - - } - // Start the main rendering loop mOgre.start(); @@ -421,49 +397,35 @@ void OMW::Engine::go() void OMW::Engine::activate() { - // TODO: This is only a workaround. The input dispatcher should catch any exceptions thrown inside - // the input handling functions. Looks like this will require an OpenEngine modification. - try + std::string handle = mEnvironment.mWorld->getFacedHandle(); + + if (handle.empty()) + return; + + MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle); + + if (ptr.isEmpty()) + return; + + MWScript::InterpreterContext interpreterContext (mEnvironment, + &ptr.getRefData().getLocals(), ptr); + + boost::shared_ptr action = + MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayerPos().getPlayer(), + mEnvironment); + + interpreterContext.activate (ptr, action); + + std::string script = MWWorld::Class::get (ptr).getScript (ptr); + + if (!script.empty()) { - std::string handle = mEnvironment.mWorld->getFacedHandle(); - - if (handle.empty()) - return; - - MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle); - - if (ptr.isEmpty()) - return; - - MWScript::InterpreterContext interpreterContext (mEnvironment, - &ptr.getRefData().getLocals(), ptr); - - boost::shared_ptr action = - MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayerPos().getPlayer(), - mEnvironment); - - interpreterContext.activate (ptr, action); - - std::string script = MWWorld::Class::get (ptr).getScript (ptr); - - if (!script.empty()) - { - mIgnoreLocalPtr = ptr; - mScriptManager->run (script, interpreterContext); - } - - if (!interpreterContext.hasActivationBeenHandled()) - { - interpreterContext.executeActivation(); - } + mIgnoreLocalPtr = ptr; + mScriptManager->run (script, interpreterContext); } - catch (const std::exception& e) + + if (!interpreterContext.hasActivationBeenHandled()) { - std::cerr << "Activation failed: " << e.what() << std::endl; + interpreterContext.executeActivation(); } } - -void OMW::Engine::setCompileAll (bool all) -{ - mCompileAll = all; -} diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index 501b234d1..e03805e65 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -55,7 +55,7 @@ StatsWindow::StatsWindow (MWWorld::Environment& environment) for (int i = 0; i < ESM::Skill::Length; ++i) { skillValues.insert(std::pair >(i, MWMechanics::Stat())); - skillWidgetMap.insert(std::pair(i, nullptr)); + skillWidgetMap.insert(std::pair(i, (MyGUI::StaticTextPtr) nullptr)); } MyGUI::WindowPtr t = static_cast(mMainWidget); diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 9eb6092ce..6caba6238 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -80,7 +80,7 @@ ReviewDialog::ReviewDialog(MWWorld::Environment& environment) for (int i = 0; i < ESM::Skill::Length; ++i) { skillValues.insert(std::pair >(i, MWMechanics::Stat())); - skillWidgetMap.insert(std::pair(i, nullptr)); + skillWidgetMap.insert(std::pair(i, (MyGUI::StaticTextPtr)nullptr)); } static_cast(mMainWidget)->eventWindowChangeCoord = MyGUI::newDelegate(this, &ReviewDialog::onWindowResize); diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index fc205d387..7d4731b82 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -728,8 +728,6 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, const Transformation *trafo, BoundsFinder &bounds, Bone *parentBone) { stack++; - //if( MWClass::isChest) - // cout << "u:" << node << "\n"; // Accumulate the flags from all the child nodes. This works for all // the flags we currently use, at least. flags |= node->flags; @@ -740,6 +738,10 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, { // Get the next extra data in the list e = e->extra.getPtr(); + if(anim){ + cout << "RECNAME:" << e->recName.toString() << "RECTYPE:" << e->recType << "\n"; + cout << "THE:" << e; + } assert(e != NULL); if (e->recType == RC_NiStringExtraData) @@ -761,9 +763,21 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, Bone *bone = 0; + //Contains the actual rotation, scale, and translation coordinate data + if(node->recType == RC_NiKeyframeData && anim) + { + + } + //Indicates the node that the data applies to + if(node->recType == RC_NiKeyframeController && anim) + { + + } + // create skeleton or add bones if (node->recType == RC_NiNode) { + //TODO: Store this variable, then read the KeyFrames //FIXME: "Bip01" isn't every time the root bone if (node->name == "Bip01" || node->name == "Root Bone") //root node, create a skeleton { @@ -779,6 +793,8 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, if (!skel.isNull()) //if there is a skeleton { std::string name = node->name.toString(); + if (anim) + std::cout << "BONE:" << name << "\n"; //if (isBeast && isChest) // std::cout << "NAME: " << name << "\n"; // Quick-n-dirty workaround for the fact that several @@ -928,6 +944,13 @@ void NIFLoader::loadResource(Resource *resource) const std::string test22 ="meshes\\b\\B_N_Breton_M_Skins.nif"; const std::string test23 ="meshes\\b\\B_N_High Elf_F_Skins.nif"; const std::string test24 ="meshes\\b\\B_N_High Elf_M_Skins.nif"; + const std::string animfile = "meshes\\base_anim.nif"; + if (name == animfile){ + std::cout << "We have animation\n"; + anim = true; + } + else + anim = false; //std::cout <<"LEN1:" << test.length() << "TEST: " << test << "\n"; @@ -1087,47 +1110,16 @@ MeshPtr NIFLoader::load(const std::string &name, // Check if the resource already exists ResourcePtr ptr = m->getByName(name, group); MeshPtr resize; - - const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif"; - const std::string beast2 ="meshes\\b\\B_N_Khajiit_M_Skins.nif"; - const std::string beast3 ="meshes\\b\\B_N_Argonian_F_Skins.nif"; - const std::string beast4 ="meshes\\b\\B_N_Argonian_M_Skins.nif"; - - const std::string beasttail1 ="tail\\b\\B_N_Khajiit_F_Skins.nif"; - const std::string beasttail2 ="tail\\b\\B_N_Khajiit_M_Skins.nif"; - const std::string beasttail3 ="tail\\b\\B_N_Argonian_F_Skins.nif"; - const std::string beasttail4 ="tail\\b\\B_N_Argonian_M_Skins.nif"; if (!ptr.isNull()){ - //if(pieces > 1) - //cout << "It exists\n"; resize = MeshPtr(ptr); - //resize->load(); - //resize->reload(); } else // Nope, create a new one. { resize = MeshManager::getSingleton().createManual(name, group, NIFLoader::getSingletonPtr()); - //cout <<"EXISTING" << name << "\n"; - - //if(pieces > 1) - //cout << "Creating it\n"; - - - //resize->load(); - //resize->reload(); - //return 0; ResourcePtr ptr = m->getByName(name, group); resize = MeshPtr(ptr); - - //NIFLoader::getSingletonPtr()-> - /*ResourcePtr ptr = m->getByName(name, group); - if (!ptr.isNull()){ - if(pieces > 1) - cout << "It exists\n"; - resize = MeshPtr(ptr);*/ - //return resize; } return resize; } diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index b2a6b50fd..8f88c0fdb 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -82,7 +82,7 @@ class NIFLoader : Ogre::ManualResourceLoader Ogre::Quaternion convertRotation(const Nif::Matrix& rot); private: - NIFLoader() : resourceGroup("General") { skincounter = 0; resourceName = "";} + NIFLoader() : resourceGroup("General") { skincounter = 0; resourceName = ""; anim = false;} NIFLoader(NIFLoader& n) {} void warn(std::string msg); @@ -128,6 +128,7 @@ class NIFLoader : Ogre::ManualResourceLoader bool isBeast; bool isHands; bool isFeet; + bool anim; int counter; int numbers; int stack;