From e5becb1f50dc79b14a5f587629516ee216ab6f95 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 14 Apr 2012 18:58:52 -0400 Subject: [PATCH] Group add function;Greaves --- apps/openmw/mwrender/npcanimation.cpp | 81 ++++++++++++++------------- apps/openmw/mwrender/npcanimation.hpp | 6 +- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 08c53f39d..bacee7f2d 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -14,7 +14,7 @@ NpcAnimation::~NpcAnimation(){ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0), robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)), helmet(inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)), shirt(inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)), - cuirass(inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)), + cuirass(inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)), greaves(inv.getSlot(MWWorld::InventoryStore::Slot_Greaves)), lclavicle(0), rclavicle(0), rupperArm(0), @@ -79,7 +79,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2); - bool female = tolower(secondtolast) == 'f'; + isFemale = tolower(secondtolast) == 'f'; std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower); isBeast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_"; @@ -145,7 +145,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O insert->attachObject(base); - if(female) + if(isFemale) insert->scale(race->data.height.female, race->data.height.female, race->data.height.female); else insert->scale(race->data.height.male, race->data.height.male, race->data.height.male); @@ -183,6 +183,12 @@ void NpcAnimation::updateParts(){ removePartGroup(MWWorld::InventoryStore::Slot_Cuirass); apparelChanged = true; + } + if(greaves != inv.getSlot(MWWorld::InventoryStore::Slot_Greaves)){ + cuirass = inv.getSlot(MWWorld::InventoryStore::Slot_Greaves); + removePartGroup(MWWorld::InventoryStore::Slot_Greaves); + apparelChanged = true; + } if(shirt != inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)){ shirt = inv.getSlot(MWWorld::InventoryStore::Slot_Shirt); @@ -198,56 +204,32 @@ void NpcAnimation::updateParts(){ const ESM::Clothing *clothes = (ptr.get())->base; std::vector parts = clothes->parts.parts; - for(int i = 0; i < parts.size(); i++) - { - ESM::PartReference part = parts[i]; - - const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); - if(bodypart) - addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Robe,5,"meshes\\" + bodypart->model); - - } + addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts); } if(helmet != inv.end()){ removeIndividualPart(ESM::PRT_Hair); const ESM::Armor *armor = (helmet->get())->base; std::vector parts = armor->parts.parts; - for(int i = 0; i < parts.size(); i++) - { - ESM::PartReference part = parts[i]; - - const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); - if(bodypart) - addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Helmet,3,"meshes\\" + bodypart->model); - - } + addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts); + } if(cuirass != inv.end()){ const ESM::Armor *armor = (cuirass->get())->base; std::vector parts = armor->parts.parts; - for(int i = 0; i < parts.size(); i++) - { - ESM::PartReference part = parts[i]; - - const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); - if(bodypart) - addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Cuirass,3,"meshes\\" + bodypart->model); - - } + addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts); + + } + if(greaves != inv.end()){ + const ESM::Armor *armor = (greaves->get())->base; + std::vector parts = armor->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); + } if(shirt != inv.end()){ const ESM::Clothing *clothes = (shirt->get())->base; std::vector parts = clothes->parts.parts; - for(int i = 0; i < parts.size(); i++) - { - ESM::PartReference part = parts[i]; - - const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); - if(bodypart) - addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Shirt,2,"meshes\\" + bodypart->model); - - } + addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts); } } @@ -299,6 +281,8 @@ std::pair*> NpcAnimation::insert } + + void NpcAnimation::runAnimation(float timepassed){ if(timeToChange > .2){ @@ -585,6 +569,25 @@ void NpcAnimation::removeIndividualPart(int type){ } return false; } + + void NpcAnimation::addPartGroup(int group, int priority, std::vector& parts){ + for(int i = 0; i < parts.size(); i++) + { + ESM::PartReference part = parts[i]; + + + const ESM::BodyPart *bodypart = 0; + + if(isFemale) + bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.female); + if(!bodypart) + bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); + + if(bodypart) + addOrReplaceIndividualPart(part.part, group,priority,"meshes\\" + bodypart->model); + + } + } } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 377560222..545634e1f 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -62,6 +62,7 @@ private: Ogre::SceneNode* insert; bool isBeast; + bool isFemale; std::string headID; std::string hairID; std::string npcName; @@ -71,6 +72,7 @@ private: MWWorld::ContainerStoreIterator helmet; MWWorld::ContainerStoreIterator shirt; MWWorld::ContainerStoreIterator cuirass; + MWWorld::ContainerStoreIterator greaves; public: NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); @@ -80,8 +82,10 @@ private: virtual void runAnimation(float timepassed); void updateParts(); void removeIndividualPart(int type); - void removePartGroup(int group); + bool addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh); + void removePartGroup(int group); + void addPartGroup(int group, int priority, std::vector& parts); }; }