Skirt and robe part blanking

actorid
Jason Hooks 13 years ago
parent bc8bb9c57e
commit 65c9cf565c

@ -13,12 +13,12 @@ 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), 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)), robe(inv.end()), helmet(inv.end()), shirt(inv.end()),
cuirass(inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)), greaves(inv.getSlot(MWWorld::InventoryStore::Slot_Greaves)), cuirass(inv.end()), greaves(inv.end()),
leftpauldron(inv.getSlot(MWWorld::InventoryStore::Slot_LeftPauldron)), rightpauldron(inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron)), leftpauldron(inv.end()), rightpauldron(inv.end()),
boots(inv.getSlot(MWWorld::InventoryStore::Slot_Boots)), boots(inv.end()),
leftglove(inv.getSlot(MWWorld::InventoryStore::Slot_LeftGauntlet)), rightglove(inv.getSlot(MWWorld::InventoryStore::Slot_RightGauntlet)), leftglove(inv.end()), rightglove(inv.end()), skirtiter(inv.end()),
pants(inv.getSlot(MWWorld::InventoryStore::Slot_Pants)), pants(inv.end()),
lclavicle(0), lclavicle(0),
rclavicle(0), rclavicle(0),
rupperArm(0), rupperArm(0),
@ -74,8 +74,13 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
// vector = Ogre::Vector3(1,1,-1); // vector = Ogre::Vector3(1,1,-1);
hairID = ref->base->hair; std::string hairID = ref->base->hair;
headID = ref->base->head; std::string headID = ref->base->head;
headModel = "meshes\\" +
mEnvironment.mWorld->getStore().bodyParts.find(headID)->model;
hairModel = "meshes\\" +
mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model;
npcName = ref->base->name; npcName = ref->base->name;
//ESMStore::Races r = //ESMStore::Races r =
const ESM::Race* race = mEnvironment.mWorld->getStore().races.find(ref->base->race); const ESM::Race* race = mEnvironment.mWorld->getStore().races.find(ref->base->race);
@ -159,11 +164,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
} }
void NpcAnimation::updateParts(){ void NpcAnimation::updateParts(){
std::string headModel = "meshes\\" +
mEnvironment.mWorld->getStore().bodyParts.find(headID)->model;
std::string hairModel = "meshes\\" +
mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model;
bool apparelChanged = false; bool apparelChanged = false;
@ -173,8 +174,12 @@ void NpcAnimation::updateParts(){
removePartGroup(MWWorld::InventoryStore::Slot_Robe); removePartGroup(MWWorld::InventoryStore::Slot_Robe);
robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe); robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe);
apparelChanged = true; apparelChanged = true;
}
if(skirtiter != inv.getSlot(MWWorld::InventoryStore::Slot_Skirt)){
//A robe was added or removed
removePartGroup(MWWorld::InventoryStore::Slot_Skirt);
skirtiter = inv.getSlot(MWWorld::InventoryStore::Slot_Skirt);
apparelChanged = true;
} }
if(helmet != inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)){ if(helmet != inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)){
apparelChanged = true; apparelChanged = true;
@ -237,7 +242,6 @@ void NpcAnimation::updateParts(){
} }
if(apparelChanged){ if(apparelChanged){
std::cout << "Modifying stuff\n";
if(robe != inv.end()) if(robe != inv.end())
{ {
MWWorld::Ptr ptr = *robe; MWWorld::Ptr ptr = *robe;
@ -245,6 +249,29 @@ void NpcAnimation::updateParts(){
const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->base; const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->base;
std::vector<ESM::PartReference> parts = clothes->parts.parts; std::vector<ESM::PartReference> parts = clothes->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts); addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts);
reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_Skirt, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_RLeg, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_RUpperarm, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_LUpperarm, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_RKnee, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_LKnee, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_RForearm, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_LForearm, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_RPauldron, MWWorld::InventoryStore::Slot_Robe, 5);
reserveIndividualPart(ESM::PRT_LPauldron, MWWorld::InventoryStore::Slot_Robe, 5);
}
if(skirtiter != inv.end())
{
MWWorld::Ptr ptr = *skirtiter;
const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->base;
std::vector<ESM::PartReference> parts = clothes->parts.parts;
addPartGroup(MWWorld::InventoryStore::Slot_Skirt, 4, parts);
reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Skirt, 4);
reserveIndividualPart(ESM::PRT_RLeg, MWWorld::InventoryStore::Slot_Skirt, 4);
reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Skirt, 4);
} }
if(helmet != inv.end()){ if(helmet != inv.end()){
@ -489,7 +516,6 @@ std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> NpcAnimation::insert
std::vector<Nif::NiTriShapeCopy>* shape = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix)); std::vector<Nif::NiTriShapeCopy>* shape = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix));
if(shape){ if(shape){
handleShapes(shape, part, base->getSkeleton()); handleShapes(shape, part, base->getSkeleton());
} }
std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> pair = std::make_pair(part, shape); std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> pair = std::make_pair(part, shape);
@ -541,8 +567,9 @@ void NpcAnimation::runAnimation(float timepassed){
handleShapes(chest.second, chest.first, base->getSkeleton()); handleShapes(chest.second, chest.first, base->getSkeleton());
if(tail.first) if(tail.first)
handleShapes(tail.second, tail.first, base->getSkeleton()); handleShapes(tail.second, tail.first, base->getSkeleton());
if(skirt.first) if(skirt.first){
handleShapes(skirt.second, skirt.first, base->getSkeleton()); handleShapes(skirt.second, skirt.first, base->getSkeleton());
}
if(lhand.first) if(lhand.first)
handleShapes(lhand.second, lhand.first, base->getSkeleton()); handleShapes(lhand.second, lhand.first, base->getSkeleton());
if(rhand.first) if(rhand.first)
@ -677,6 +704,14 @@ void NpcAnimation::removeIndividualPart(int type){
}
void NpcAnimation::reserveIndividualPart(int type, int group, int priority){
if(priority > partpriorities[type]){
removeIndividualPart(type);
partpriorities[type] = priority;
partslots[type] = group;
}
} }
void NpcAnimation::removePartGroup(int group){ void NpcAnimation::removePartGroup(int group){
@ -705,7 +740,7 @@ void NpcAnimation::removeIndividualPart(int type){
chest = insertFreePart(mesh, ":\""); chest = insertFreePart(mesh, ":\"");
break; break;
case ESM::PRT_Groin: //4 case ESM::PRT_Groin: //4
neck = insertBoundedPart(mesh, "Groin"); groin = insertBoundedPart(mesh, "Groin");
break; break;
case ESM::PRT_Skirt: //5 case ESM::PRT_Skirt: //5
skirt = insertFreePart(mesh, ":|"); skirt = insertFreePart(mesh, ":|");
@ -791,16 +826,15 @@ void NpcAnimation::removeIndividualPart(int type){
{ {
ESM::PartReference part = parts[i]; ESM::PartReference part = parts[i];
const ESM::BodyPart *bodypart = 0; const ESM::BodyPart *bodypart = 0;
if(isFemale) if(isFemale)
bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.female); bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.female);
if(!bodypart) if(!bodypart)
bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male);
if(bodypart) if(bodypart)
addOrReplaceIndividualPart(part.part, group,priority,"meshes\\" + bodypart->model); addOrReplaceIndividualPart(part.part, group,priority,"meshes\\" + bodypart->model);
else
reserveIndividualPart(part.part, group, priority);
} }
} }

@ -63,8 +63,8 @@ private:
Ogre::SceneNode* insert; Ogre::SceneNode* insert;
bool isBeast; bool isBeast;
bool isFemale; bool isFemale;
std::string headID; std::string headModel;
std::string hairID; std::string hairModel;
std::string npcName; std::string npcName;
std::string bodyRaceID; std::string bodyRaceID;
float timeToChange; float timeToChange;
@ -79,6 +79,7 @@ private:
MWWorld::ContainerStoreIterator pants; MWWorld::ContainerStoreIterator pants;
MWWorld::ContainerStoreIterator leftglove; MWWorld::ContainerStoreIterator leftglove;
MWWorld::ContainerStoreIterator rightglove; MWWorld::ContainerStoreIterator rightglove;
MWWorld::ContainerStoreIterator skirtiter;
public: public:
NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv);
@ -88,10 +89,12 @@ private:
virtual void runAnimation(float timepassed); virtual void runAnimation(float timepassed);
void updateParts(); void updateParts();
void removeIndividualPart(int type); void removeIndividualPart(int type);
void reserveIndividualPart(int type, int group, int priority);
bool addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh); bool addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh);
void removePartGroup(int group); void removePartGroup(int group);
void addPartGroup(int group, int priority, std::vector<ESM::PartReference>& parts); void addPartGroup(int group, int priority, std::vector<ESM::PartReference>& parts);
}; };
} }

Loading…
Cancel
Save