From 7fce57f335133735760262849e431adacfc6aba2 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 11 Apr 2012 20:16:22 -0400 Subject: [PATCH] Getting started with a new branch --- apps/openmw/mwrender/npcanimation.cpp | 167 ++++++------------------- apps/openmw/mwrender/npcanimation.hpp | 15 +-- apps/openmw/mwworld/inventorystore.cpp | 2 +- components/esm/loadarmo.cpp | 1 + components/esm/loadclot.cpp | 1 + 5 files changed, 50 insertions(+), 136 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 8097afdbf6..f04ac76092 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -12,7 +12,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){ +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)){ ESMS::LiveCellRef *ref = ptr.get(); Ogre::Entity* blank = 0; @@ -121,6 +121,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O 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); + std::cout << "Inv" << inv.getStateId() << "\n"; updateParts(); } @@ -133,134 +134,43 @@ void NpcAnimation::updateParts(){ mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; //inv.getSlot(MWWorld::InventoryStore::Slot_Robe); + if(robe != inv.getSlot(MWWorld::InventoryStore::Slot_Robe)){ + //A robe was added or removed + if(chest.first) + { + insert->detachObject(chest.first); chest.first = 0; + } + robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe); + if(robe != inv.end()) + { + MWWorld::Ptr ptr = *robe; + + 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]; + if(part.part == ESM::PRT_Cuirass) + { + const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); + chest = insertFreePart("meshes\\" + bodypart->model, ":\""); + } + } + } - MWWorld::ContainerStoreIterator robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe); - - + } + if(robe == inv.end() ){ + //if(inv.getSlot(MWWorld::InventoryStore::Cuirass) != inv.end()) + if(chest.first == 0){ + const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); + chest = insertFreePart("meshes\\" + chestPart->model, ":\""); + } + + } - // ; - const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); - const ESM::BodyPart *upperleg = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); - const ESM::BodyPart *groinpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); - const ESM::BodyPart *arml = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); //We need two - const ESM::BodyPart *neckpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck"); - const ESM::BodyPart *knee = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee"); - const ESM::BodyPart *ankle = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); - const ESM::BodyPart *foot = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); - const ESM::BodyPart *feetpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); - const ESM::BodyPart *tailpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail"); - const ESM::BodyPart *wristlpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); //We need two - const ESM::BodyPart *forearmlpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); //We need two - const ESM::BodyPart *handlpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand"); //We need two - const ESM::BodyPart *hairpart = mEnvironment.mWorld->getStore().bodyParts.search(hairID); - const ESM::BodyPart *headpart = mEnvironment.mWorld->getStore().bodyParts.search(headID); - if(bodyRaceID == "b_n_argonian_f_") - forearmlpart = mEnvironment.mWorld->getStore().bodyParts.search ("b_n_argonian_m_forearm"); //We need two - if(!handlpart) - handlpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands"); - //const ESM::BodyPart* claviclel = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "clavicle"); - //const ESM::BodyPart* clavicler = claviclel; - const ESM::BodyPart* handrpart = handlpart; - const ESM::BodyPart* forearmr = forearmlpart; - const ESM::BodyPart* wristrpart = wristlpart; - const ESM::BodyPart* armr = arml; - - - if(upperleg){ - lUpperLeg = insertBoundedPart("meshes\\" + upperleg->model + "*|", "Left Upper Leg"); - rUpperLeg = insertBoundedPart("meshes\\" + upperleg->model, "Right Upper Leg"); - - } - if(foot){ - if(bodyRaceID.compare("b_n_khajiit_m_") == 0) - { - feetpart = foot; - } - else - { - rfoot = insertBoundedPart("meshes\\" + foot->model, "Right Foot"); - lfoot = insertBoundedPart("meshes\\" + foot->model + "*|", "Left Foot"); - } - } - if(groinpart){ - groin = insertBoundedPart("meshes\\" + groinpart->model, "Groin"); - } - if(knee) - { - lKnee = insertBoundedPart("meshes\\" + knee->model + "*|", "Left Knee"); //e - rKnee = insertBoundedPart("meshes\\" + knee->model, "Right Knee"); //e - - } - if(ankle){ - - lAnkle = insertBoundedPart("meshes\\" + ankle->model + "*|", "Left Ankle"); //Ogre::Quaternion(Ogre::Radian(3.14 / 4), Ogre::Vector3(1, 0, 0)),blank); //1,0,0, blank); - rAnkle = insertBoundedPart("meshes\\" + ankle->model, "Right Ankle"); - } - if (armr){ - rupperArm = insertBoundedPart("meshes\\" + armr->model, "Right Upper Arm"); - } - if(arml){ - lupperArm = insertBoundedPart("meshes\\" + arml->model + "*|", "Left Upper Arm"); - } - - if (forearmr) - { - rForearm = insertBoundedPart("meshes\\" + forearmr->model, "Right Forearm"); - } - if(forearmlpart) - lForearm = insertBoundedPart("meshes\\" + forearmlpart->model + "*|", "Left Forearm"); - - if (wristrpart) - { - rWrist = insertBoundedPart("meshes\\" + wristrpart->model, "Right Wrist"); - } - - if(wristlpart) - lWrist = insertBoundedPart("meshes\\" + wristlpart->model + "*|", "Left Wrist"); - - - - - - /*if(claviclel) - insertBoundedPart("meshes\\" + claviclel->model + "*|", "Left Clavicle", base); - if(clavicler) - insertBoundedPart("meshes\\" + clavicler->model , "Right Clavicle", base);*/ - - if(neckpart) - { - neck = insertBoundedPart("meshes\\" + neckpart->model, "Neck"); - } - if(headpart) - head = insertBoundedPart("meshes\\" + headpart->model, "Head"); - if(hairpart) - hair = insertBoundedPart("meshes\\" + hairpart->model, "Head"); - - if (chestPart){ - chest = insertFreePart("meshes\\" + chestPart->model, ":\""); - - - } - if (handrpart){ - rhand = insertFreePart("meshes\\" + handrpart->model , ":?"); - - } - if (handlpart){ - lhand = insertFreePart("meshes\\" + handlpart->model, ":>"); - - } - if(tailpart){ - tail = insertFreePart("meshes\\" + tailpart->model, ":*"); - } - if(feetpart){ - - lBeastFoot = insertFreePart("meshes\\" + feetpart->model,"::"); - rBeastFoot = insertFreePart("meshes\\" + feetpart->model,":<"); - } - //originalpos = insert->_getWorl } Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){ @@ -295,13 +205,14 @@ std::pair*> NpcAnimation::insert void NpcAnimation::runAnimation(float timepassed){ - if(mStateID != inv.getStateId()){ - std::cout << "StateID" < .2){ + timeToChange = 0; + + updateParts(); } - + timeToChange += timepassed; //1. Add the amount of time passed to time diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index e90bea5c9f..02b161b994 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -15,6 +15,7 @@ #include "../mwworld/inventorystore.hpp" #include "../mwclass/npc.hpp" #include "../mwworld/containerstore.hpp" +#include "components/esm/loadarmo.hpp" namespace MWRender{ @@ -30,12 +31,11 @@ private: std::pair*> tail; std::pair*> lBeastFoot; std::pair*> rBeastFoot; - /*Ogre::Entity* skirt; std::vector* skirtShapes; - Ogre::Entity* rhand; std::vector* rhandShapes; - Ogre::Entity* lhand; std::vector* lhandShapes; - Ogre::Entity* tail; std::vector* tailShapes; - Ogre::Entity* lBeastFoot; std::vector* lBeastFootShapes; - Ogre::Entity* rBeastFoot; std::vector* rBeastFootShapes;*/ + + int partslots[27]; //Each part slot is taken by clothing, armor, or is empty + + + //Bounded Parts Ogre::Entity* lclavicle; @@ -64,7 +64,8 @@ private: std::string hairID; std::string npcName; std::string bodyRaceID; - + float timeToChange; + MWWorld::ContainerStoreIterator robe; public: NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 650418201b..230f7d69a0 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -72,7 +72,7 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite /// \todo restack item previously in this slot (if required) /// \todo unstack item pointed to by iterator if required) - + mSlots[slot] = iterator; flagAsModified(); diff --git a/components/esm/loadarmo.cpp b/components/esm/loadarmo.cpp index ddc25e176f..8b559b10fc 100644 --- a/components/esm/loadarmo.cpp +++ b/components/esm/loadarmo.cpp @@ -11,6 +11,7 @@ void PartReferenceList::load(ESMReader &esm) esm.getHT(pr.part); // The INDX byte pr.male = esm.getHNOString("BNAM"); pr.female = esm.getHNOString("CNAM"); + parts.push_back(pr); } } diff --git a/components/esm/loadclot.cpp b/components/esm/loadclot.cpp index 1d6c9d4a1e..16fd0598cc 100644 --- a/components/esm/loadclot.cpp +++ b/components/esm/loadclot.cpp @@ -13,6 +13,7 @@ void Clothing::load(ESMReader &esm) icon = esm.getHNOString("ITEX"); parts.load(esm); + enchant = esm.getHNOString("ENAM"); }