mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 04:26:42 +00:00 
			
		
		
		
	Trying iterators
This commit is contained in:
		
							parent
							
								
									ebab98a8a0
								
							
						
					
					
						commit
						6bdfdf379b
					
				
					 2 changed files with 59 additions and 30 deletions
				
			
		| 
						 | 
					@ -11,12 +11,18 @@ 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), robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)){
 | 
				
			||||||
     ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
 | 
					     ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
 | 
				
			||||||
            ptr.get<ESM::NPC>();
 | 
					            ptr.get<ESM::NPC>();
 | 
				
			||||||
	 Ogre::Entity* blank = 0;
 | 
						 Ogre::Entity* blank = 0;
 | 
				
			||||||
	  std::vector<Nif::NiTriShapeCopy>* blankshape = 0;
 | 
						  std::vector<Nif::NiTriShapeCopy>* blankshape = 0;
 | 
				
			||||||
	 chest = std::make_pair(blank, blankshape);
 | 
						 chest = std::make_pair(blank, blankshape);
 | 
				
			||||||
 | 
						 tail = std::make_pair(blank, blankshape);
 | 
				
			||||||
 | 
						 lBeastFoot = std::make_pair(blank, blankshape);
 | 
				
			||||||
 | 
						 rBeastFoot = std::make_pair(blank, blankshape);
 | 
				
			||||||
 | 
						 rhand = std::make_pair(blank, blankshape);
 | 
				
			||||||
 | 
						 lhand = std::make_pair(blank, blankshape);
 | 
				
			||||||
 | 
						 skirt = std::make_pair(blank, blankshape);
 | 
				
			||||||
		//Part selection on last character of the file string
 | 
							//Part selection on last character of the file string
 | 
				
			||||||
		//  " Tri Chest
 | 
							//  " Tri Chest
 | 
				
			||||||
		//  * Tri Tail
 | 
							//  * Tri Tail
 | 
				
			||||||
| 
						 | 
					@ -35,18 +41,18 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
 | 
				
			||||||
		//	vector = Ogre::Vector3(1,1,-1);
 | 
							//	vector = Ogre::Vector3(1,1,-1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		std::string hairID = ref->base->hair;
 | 
							hairID = ref->base->hair;
 | 
				
			||||||
        std::string headID = ref->base->head;
 | 
					        headID = ref->base->head;
 | 
				
			||||||
		std::string 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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
 | 
					         bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
 | 
				
			||||||
		char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2);
 | 
							char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2);
 | 
				
			||||||
		bool female = tolower(secondtolast) == 'f';
 | 
							bool female = tolower(secondtolast) == 'f';
 | 
				
			||||||
		std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower);
 | 
							std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower);
 | 
				
			||||||
		bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
 | 
							isBeast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /*std::cout << "Race: " << ref->base->race ;
 | 
					        /*std::cout << "Race: " << ref->base->race ;
 | 
				
			||||||
        if(female){
 | 
					        if(female){
 | 
				
			||||||
| 
						 | 
					@ -59,7 +65,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        std::string smodel = "meshes\\base_anim.nif";
 | 
					        std::string smodel = "meshes\\base_anim.nif";
 | 
				
			||||||
		if(beast)
 | 
							if(isBeast)
 | 
				
			||||||
			smodel = "meshes\\base_animkna.nif";
 | 
								smodel = "meshes\\base_animkna.nif";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
         insert = ptr.getRefData().getBaseNode();
 | 
					         insert = ptr.getRefData().getBaseNode();
 | 
				
			||||||
| 
						 | 
					@ -92,11 +98,26 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
 | 
				
			||||||
            insert->scale(race->data.height.female, race->data.height.female, race->data.height.female);
 | 
					            insert->scale(race->data.height.female, race->data.height.female, race->data.height.female);
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            insert->scale(race->data.height.male, race->data.height.male, race->data.height.male);
 | 
					            insert->scale(race->data.height.male, race->data.height.male, race->data.height.male);
 | 
				
			||||||
 | 
					        updateParts();
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void NpcAnimation::updateParts(){
 | 
				
			||||||
	std::string headModel = "meshes\\" +
 | 
						std::string headModel = "meshes\\" +
 | 
				
			||||||
            mEnvironment.mWorld->getStore().bodyParts.find(headID)->model;
 | 
					            mEnvironment.mWorld->getStore().bodyParts.find(headID)->model;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		std::string hairModel = "meshes\\" +
 | 
							std::string hairModel = "meshes\\" +
 | 
				
			||||||
            mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model;
 | 
					            mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//inv.getSlot(MWWorld::InventoryStore::Slot_Robe);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							robe = inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass);
 | 
				
			||||||
 | 
							if(robe == inv.end())
 | 
				
			||||||
 | 
								std::cout << "No part\n";
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								std::cout << "yes part\n";
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							
 | 
				
			||||||
        const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest");
 | 
					        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 *upperleg = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg");
 | 
				
			||||||
		const ESM::BodyPart *groinpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin");
 | 
							const ESM::BodyPart *groinpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin");
 | 
				
			||||||
| 
						 | 
					@ -216,9 +237,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O
 | 
				
			||||||
                lBeastFoot = insertFreePart("meshes\\" + feetpart->model,"::");
 | 
					                lBeastFoot = insertFreePart("meshes\\" + feetpart->model,"::");
 | 
				
			||||||
                rBeastFoot = insertFreePart("meshes\\" + feetpart->model,":<");
 | 
					                rBeastFoot = insertFreePart("meshes\\" + feetpart->model,":<");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        //originalpos = insert->_getWorldAABB().getCenter();
 | 
					        //originalpos = insert->_getWorl
 | 
				
			||||||
        //originalscenenode = insert->getPosition();
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){
 | 
					Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){
 | 
				
			||||||
| 
						 | 
					@ -252,8 +271,10 @@ std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> NpcAnimation::insert
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void NpcAnimation::runAnimation(float timepassed){
 | 
					void NpcAnimation::runAnimation(float timepassed){
 | 
				
			||||||
 | 
						if(mStateID != inv.getStateId()){
 | 
				
			||||||
		mStateID = inv.getStateId();
 | 
							mStateID = inv.getStateId();
 | 
				
			||||||
 | 
							updateParts();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
   
 | 
					   
 | 
				
			||||||
    //1. Add the amount of time passed to time
 | 
					    //1. Add the amount of time passed to time
 | 
				
			||||||
| 
						 | 
					@ -278,22 +299,22 @@ void NpcAnimation::runAnimation(float timepassed){
 | 
				
			||||||
       
 | 
					       
 | 
				
			||||||
            vecRotPos.clear();
 | 
					            vecRotPos.clear();
 | 
				
			||||||
          
 | 
					          
 | 
				
			||||||
			/*
 | 
								
 | 
				
			||||||
			if(lBeastFoot)
 | 
								if(lBeastFoot.first)
 | 
				
			||||||
				handleShapes(lBeastFootShapes, lBeastFoot, base->getSkeleton());
 | 
									handleShapes(lBeastFoot.second, lBeastFoot.first, base->getSkeleton());
 | 
				
			||||||
			if(rBeastFoot)
 | 
								if(rBeastFoot.first)
 | 
				
			||||||
				handleShapes(rBeastFootShapes, rBeastFoot, base->getSkeleton());
 | 
									handleShapes(rBeastFoot.second, rBeastFoot.first, base->getSkeleton());
 | 
				
			||||||
			if(chest)
 | 
								if(chest.first)
 | 
				
			||||||
				handleShapes(chestShapes, chest, base->getSkeleton());
 | 
									handleShapes(chest.second, chest.first, base->getSkeleton());
 | 
				
			||||||
			if(tail)
 | 
								if(tail.first)
 | 
				
			||||||
				handleShapes(tailShapes, tail, base->getSkeleton());
 | 
									handleShapes(tail.second, tail.first, base->getSkeleton());
 | 
				
			||||||
			if(skirt)
 | 
								if(skirt.first)
 | 
				
			||||||
				handleShapes(skirtShapes, skirt, base->getSkeleton());
 | 
									handleShapes(skirt.second, skirt.first, base->getSkeleton());
 | 
				
			||||||
			if(lhand)
 | 
								if(lhand.first)
 | 
				
			||||||
				handleShapes(lhandShapes, lhand, base->getSkeleton());
 | 
									handleShapes(lhand.second, lhand.first, base->getSkeleton());
 | 
				
			||||||
			if(rhand)
 | 
								if(rhand.first)
 | 
				
			||||||
				handleShapes(rhandShapes, rhand, base->getSkeleton());
 | 
									handleShapes(rhand.second, rhand.first, base->getSkeleton());
 | 
				
			||||||
			*/
 | 
								
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -13,6 +13,8 @@
 | 
				
			||||||
#include "../mwworld/environment.hpp"
 | 
					#include "../mwworld/environment.hpp"
 | 
				
			||||||
#include "components/nifogre/ogre_nif_loader.hpp"
 | 
					#include "components/nifogre/ogre_nif_loader.hpp"
 | 
				
			||||||
#include "../mwworld/inventorystore.hpp"
 | 
					#include "../mwworld/inventorystore.hpp"
 | 
				
			||||||
 | 
					#include "../mwclass/npc.hpp"
 | 
				
			||||||
 | 
					#include "../mwworld/containerstore.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace MWRender{
 | 
					namespace MWRender{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,7 +59,12 @@ private:
 | 
				
			||||||
	Ogre::Entity* hair;
 | 
						Ogre::Entity* hair;
 | 
				
			||||||
	Ogre::Entity* head;
 | 
						Ogre::Entity* head;
 | 
				
			||||||
	Ogre::SceneNode* insert;
 | 
						Ogre::SceneNode* insert;
 | 
				
			||||||
    
 | 
					    bool isBeast;
 | 
				
			||||||
 | 
						std::string headID;
 | 
				
			||||||
 | 
						std::string hairID;
 | 
				
			||||||
 | 
						std::string npcName;
 | 
				
			||||||
 | 
						std::string bodyRaceID;
 | 
				
			||||||
 | 
						MWWorld::ContainerStoreIterator robe;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    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);
 | 
				
			||||||
| 
						 | 
					@ -65,6 +72,7 @@ private:
 | 
				
			||||||
    Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename);
 | 
					    Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename);
 | 
				
			||||||
     std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> insertFreePart(const std::string &mesh, const std::string suffix);
 | 
					     std::pair<Ogre::Entity*, std::vector<Nif::NiTriShapeCopy>*> insertFreePart(const std::string &mesh, const std::string suffix);
 | 
				
			||||||
	virtual void runAnimation(float timepassed);
 | 
						virtual void runAnimation(float timepassed);
 | 
				
			||||||
 | 
						void updateParts();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue