From 47112ad7f985f32c04514bb752fdd0b60e0fca12 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Tue, 13 Dec 2011 23:49:03 -0500 Subject: [PATCH] Changing a lot of things --- apps/openmw/mwrender/actors.cpp | 11 ++++---- apps/openmw/mwrender/actors.hpp | 2 +- apps/openmw/mwrender/animation.hpp | 18 ++++++++++++- apps/openmw/mwrender/npcanimation.cpp | 34 +++++++++++++++++++++++-- apps/openmw/mwrender/npcanimation.hpp | 8 +++++- components/nifogre/ogre_nif_loader.cpp | 35 +++++++++++--------------- components/nifogre/ogre_nif_loader.hpp | 6 ++--- 7 files changed, 80 insertions(+), 34 deletions(-) diff --git a/apps/openmw/mwrender/actors.cpp b/apps/openmw/mwrender/actors.cpp index f2fa59786..d3493bf4a 100644 --- a/apps/openmw/mwrender/actors.cpp +++ b/apps/openmw/mwrender/actors.cpp @@ -1,7 +1,7 @@ #include "actors.hpp" #include #include -#include "../mwworld/world.hpp" + using namespace Ogre; @@ -13,8 +13,8 @@ void Actors::setMwRoot(Ogre::SceneNode* root){ } void Actors::insertNPC(const MWWorld::Ptr& ptr){ insertBegin(ptr, true, true); - MWRender::Animation anim = MWRender::NpcAnimation(ptr, mEnvironment, mRend); - mAllActors.push_back(anim); + NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mEnvironment, mRend); + mAllActors.push_back(anim); } @@ -58,8 +58,9 @@ void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ } void Actors::insertCreature (const MWWorld::Ptr& ptr){ insertBegin(ptr, true, true); - MWRender::Animation anim = MWRender::CreatureAnimation(ptr, mEnvironment, mRend); - mAllActors.push_back(anim); + CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mEnvironment, mRend); + mAllActors.push_back(anim); + //mAllActors.push_back(&anim); } bool Actors::deleteObject (const MWWorld::Ptr& ptr) diff --git a/apps/openmw/mwrender/actors.hpp b/apps/openmw/mwrender/actors.hpp index 82e4de6ad..afd6e9ae6 100644 --- a/apps/openmw/mwrender/actors.hpp +++ b/apps/openmw/mwrender/actors.hpp @@ -23,7 +23,7 @@ namespace MWRender{ std::map mCellSceneNodes; Ogre::SceneNode* mMwRoot; MWWorld::Environment& mEnvironment; - std::list mAllActors; + std::list mAllActors; diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 82dca80b2..111e2d0c7 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -13,9 +13,25 @@ class Animation{ protected: OEngine::Render::OgreRenderer &mRend; MWWorld::Environment& mEnvironment; + + float time; + float startTime; + float stopTime; + bool loop; + //Represents a rotation index for each bone + std::vectorrindexI; + //Represents a translation index for each bone + std::vectortindexI; + + //Only shapes with morphing data will need a shape number + int shapeNumber; + std::vector> shapeIndexI; + + Ogre::SkeletonInstance* skel; + - std::vector transformations; + std::vector* transformations; std::map textmappings; Ogre::Entity* base; public: diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index c33892c21..bd60a548e 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -1,6 +1,7 @@ #include "npcanimation.hpp" #include "../mwworld/world.hpp" + using namespace Ogre; using namespace NifOgre; namespace MWRender{ @@ -54,6 +55,15 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O NifOgre::NIFLoader::load(smodel); base = mRend.getScene()->createEntity(smodel); + + /* + transformations = &(NIFLoader::getSingletonPtr())->getAnim(smodel); + for(int init = 0; init < transformations->size(); init++){ + rindexI.push_back(0); + //a.rindexJ.push_back(0); + tindexI.push_back(0); + //a.tindexJ.push_back(0); + }*/ insert->attachObject(base); std::string headModel = "meshes\\" + @@ -61,7 +71,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O std::string hairModel = "meshes\\" + mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; - + const ESM::BodyPart *chest = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); const ESM::BodyPart *upperleg = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); const ESM::BodyPart *groin = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); const ESM::BodyPart *arml = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); //We need two @@ -136,7 +146,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O if(wristl) insertBoundedPart("meshes\\" + wristl->model + "*|", "Left Wrist"); - + @@ -154,6 +164,15 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O insertBoundedPart("meshes\\" + head->model, "Head"); if(hair) insertBoundedPart("meshes\\" + hair->model, "Head"); + + if (chest){ + insertFreePart("meshes\\" + chest->model + "|\"", insert); + + } + if (handr){ + insertFreePart("meshes\\" + handr->model + "|?", insert); + + } } Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){ @@ -162,5 +181,16 @@ Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::stri base->attachObjectToBone(bonename, ent); return ent; +} +void NpcAnimation::insertFreePart(const std::string &mesh, Ogre::SceneNode* insert){ + NIFLoader::load(mesh); + Entity* ent = mRend.getScene()->createEntity(mesh); + insert->attachObject(ent); + entityparts.push_back(ent); + //std::vector shapes = (NIFLoader::getSingletonPtr())->getShapes(mesh); + std::vector* shapes = ((NIFLoader::getSingletonPtr())->getShapes(mesh)); + shapeparts.push_back(shapes); + + } } \ No newline at end of file diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 90204f6d5..96a2eeb31 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -3,6 +3,9 @@ #include "animation.hpp" #include #include +#include +#include +#include #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" @@ -12,11 +15,14 @@ namespace MWRender{ class NpcAnimation: public Animation{ - std::vector> shapeparts; //All the NiTriShape data that we need for animating this particular npc + std::vector entityparts; + + std::vector*> shapeparts; //All the NiTriShape data that we need for animating this particular npc public: NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend); ~NpcAnimation(); Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename); + void insertFreePart(const std::string &mesh, Ogre::SceneNode* insert); }; } #endif \ No newline at end of file diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 8f19be44c..26b1111a1 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -1277,18 +1277,7 @@ void NIFLoader::loadResource(Resource *resource) { allshapesmap[name] = shapes; } - if(baddin){ - /*if(addAnim){ - if(isBeast) - npcknaSkel = mSkel; - else - npcSkel = mSkel; - }*/ - for(int i = 0; i < addin.size(); i++){ - insertMeshInsideBase(addin[i]); - } - addin.clear(); - } + if(flip){ mesh->_setBounds(mBoundingBox, false); } @@ -1330,20 +1319,22 @@ This function also creates new position and normal buffers for submeshes. This function points to existing texture and IndexData buffers */ -std::vector& NIFLoader::getAnim(std::string lowername){ +std::vector* NIFLoader::getAnim(std::string lowername){ std::map,ciLessBoost>::iterator iter = allanimmap.find(lowername); + std::vector* pass = 0; if(iter != allanimmap.end()) - mAnim = iter->second; - return mAnim; + pass = &(iter->second); + return pass; } -std::vector& NIFLoader::getShapes(std::string lowername){ +std::vector* NIFLoader::getShapes(std::string lowername){ std::map,ciLessBoost>::iterator iter = allshapesmap.find(lowername); + std::vector* pass = 0; if(iter != allshapesmap.end()) - mS = iter->second; - return mS; + pass = &(iter->second); + return pass; } float NIFLoader::getTime(std::string filename, std::string text){ @@ -1359,12 +1350,14 @@ float NIFLoader::getTime(std::string filename, std::string text){ return -10000000.0; } +/* void NIFLoader::insertMeshInsideBase(Ogre::Mesh* input) { /*if(addin) { std::cout << "InsideBase:" << addin->getName() << "\n"; }*/ +/* if(input) { std::vector shapes = NIFLoader::getSingletonPtr()->getShapes(input->getName()); @@ -1478,7 +1471,7 @@ void NIFLoader::insertMeshInsideBase(Ogre::Mesh* input) for (int j = 0; j < weights.size(); j++){ std::cout << "Vertex: " << weights[j].vertex << " Weight: " << weights[j].weight << "\n"; }*/ - } + /*} } if(position){ @@ -1578,7 +1571,7 @@ void NIFLoader::insertMeshInsideBase(Ogre::Mesh* input) assign.vertexIndex = 0; assign.weight = 1.0; subNew->addBoneAssignment(assign);*/ - + /* Ogre::SubMesh::BoneAssignmentIterator boneiter = sub->getBoneAssignmentIterator(); while(boneiter.hasMoreElements()) { @@ -1592,7 +1585,7 @@ void NIFLoader::insertMeshInsideBase(Ogre::Mesh* input) } } -} +}*/ /* More code currently not in use, from the old D source. This was diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index ec0fb412a..7dab61a54 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -108,9 +108,9 @@ class NIFLoader : Ogre::ManualResourceLoader static Ogre::MeshPtr load(const std::string &name, const std::string &group="General"); - void insertMeshInsideBase(Ogre::Mesh* mesh); - std::vector& getAnim(std::string name); - std::vector& getShapes(std::string name); + //void insertMeshInsideBase(Ogre::Mesh* mesh); + std::vector* getAnim(std::string name); + std::vector* getShapes(std::string name); float getTime(std::string filename, std::string text); void addInMesh(Ogre::Mesh* input);