diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index b5bb4b773..16b3cff75 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -33,19 +33,6 @@ namespace MWClass void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { renderingInterface.getActors().insertNPC(ptr); - /* - ESMS::LiveCellRef *ref = - ptr.get(); - - assert (ref->base != NULL); - const std::string &model = ref->base->model; - - if (!model.empty()) - { - MWRender::Npcs& npcs = renderingInterface.getNPCs(); - //npcs.insertBegin(ptr, ptr.getRefData().isEnabled(), false); - //npcs.insertMesh(ptr, "meshes\\" + model); - }*/ } void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const diff --git a/apps/openmw/mwrender/actors.cpp b/apps/openmw/mwrender/actors.cpp index 6fbbd755f..1876bd3cf 100644 --- a/apps/openmw/mwrender/actors.cpp +++ b/apps/openmw/mwrender/actors.cpp @@ -1,6 +1,7 @@ #include "actors.hpp" #include #include +#include "../mwworld/world.hpp" using namespace Ogre; using namespace MWRender; @@ -9,8 +10,15 @@ using namespace NifOgre; void Actors::setMwRoot(Ogre::SceneNode* root){ mMwRoot = root; } +Ogre::Entity* Actors::insertBoundedPart(const std::string &mesh, std::string bonename, Ogre::Entity* base){ + NIFLoader::load(mesh); + Entity* ent = mRend.getScene()->createEntity(mesh); + + base->attachObjectToBone(bonename, ent); + return ent; + +} void Actors::insertNPC(const MWWorld::Ptr& ptr){ -/* ESMS::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); @@ -45,6 +53,18 @@ void Actors::insertNPC(const MWWorld::Ptr& ptr){ bool female = tolower(secondtolast) == 'f'; bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_"; + + std::string smodel = "meshes\\base_anim.nif"; + if(beast) + smodel = "meshes\\base_animkna.nif"; + + Ogre::SceneNode* insert = ptr.getRefData().getBaseNode(); + assert(insert); + + NifOgre::NIFLoader::load(smodel); + Entity *base = mRend.getScene()->createEntity(smodel); + insert->attachObject(base); + std::string headModel = "meshes\\" + mEnvironment.mWorld->getStore().bodyParts.find(headID)->model; @@ -72,7 +92,23 @@ void Actors::insertNPC(const MWWorld::Ptr& ptr){ const ESM::BodyPart* handr = handl; const ESM::BodyPart* forearmr = forearml; const ESM::BodyPart* wristr = wristl; - const ESM::BodyPart* armr = arml;*/ + const ESM::BodyPart* armr = arml; + if(upperleg){ + insertBoundedPart("meshes\\" + upperleg->model + "*|", "Left Upper Leg", base); + insertBoundedPart("meshes\\" + upperleg->model, "Right Upper Leg", base); + + } + if(foot){ + if(bodyRaceID.compare("b_n_khajiit_m_") == 0) + { + feet = foot; + } + else + { + insertBoundedPart("meshes\\" + foot->model, "Right Foot", base); + insertBoundedPart("meshes\\" + foot->model + "*|", "Left Foot", base); + } + } } void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ Ogre::SceneNode* cellnode; diff --git a/apps/openmw/mwrender/actors.hpp b/apps/openmw/mwrender/actors.hpp index 5096c453d..d533e77f9 100644 --- a/apps/openmw/mwrender/actors.hpp +++ b/apps/openmw/mwrender/actors.hpp @@ -4,11 +4,17 @@ #include "components/esm_store/cell_store.hpp" #include -#include "../mwworld/refdata.hpp" -#include "../mwworld/ptr.hpp" + + #include #include "components/nifogre/ogre_nif_loader.hpp" + +#include "../mwworld/refdata.hpp" +#include "../mwworld/ptr.hpp" +#include "../mwworld/actiontalk.hpp" #include "../mwworld/environment.hpp" + + namespace MWRender{ class Actors{ OEngine::Render::OgreRenderer &mRend; @@ -21,6 +27,7 @@ namespace MWRender{ public: Actors(OEngine::Render::OgreRenderer& _rend, MWWorld::Environment& _env): mRend(_rend), mEnvironment(_env){} ~Actors(){} + Ogre::Entity* Actors::insertBoundedPart(const std::string &mesh, std::string bonename, Ogre::Entity* base); void setMwRoot(Ogre::SceneNode* root); void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_); void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh); diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 796ece5be..8be945950 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -476,6 +476,7 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std HardwareBuffer::HBU_STATIC_WRITE_ONLY, true); if(flip && mFlipVertexWinding && sub->indexData->indexCount % 3 == 0){ + std::cout << "INTHEWINDING\n"; sub->indexData->indexBuffer = ibuf; uint16 *datamod = new uint16[numFaces]; @@ -1183,7 +1184,7 @@ void NIFLoader::loadResource(Resource *resource) } if(flip) { - //std::cout << "Flipping"; + std::cout << "Flipping"; calculateTransform(); } // Set up the VFS if it hasn't been done already diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index a5b33bcbe..ec0fb412a 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -119,7 +119,8 @@ class NIFLoader : Ogre::ManualResourceLoader Ogre::Quaternion convertRotation(const Nif::Matrix& rot); private: - NIFLoader() : resourceGroup("General") {resourceName = "";} + NIFLoader() : resourceGroup("General"),mNormaliseNormals(false), + mFlipVertexWinding(false), flip(false) {resourceName = "";} NIFLoader(NIFLoader& n) {} void calculateTransform();