mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-28 17:56:37 +00:00 
			
		
		
		
	Update animation source controller targets
This commit is contained in:
		
							parent
							
								
									44a59e1b87
								
							
						
					
					
						commit
						f69a8259e1
					
				
					 3 changed files with 36 additions and 5 deletions
				
			
		|  | @ -78,6 +78,7 @@ void Animation::setAnimationSources(const std::vector<std::string> &names) | |||
|         destroyObjectList(sceneMgr, mAnimationSources[i]); | ||||
|     mAnimationSources.clear(); | ||||
| 
 | ||||
|     Ogre::SkeletonInstance *skelinst = mObjectList.mSkelBase->getSkeleton(); | ||||
|     std::vector<std::string>::const_iterator nameiter; | ||||
|     for(nameiter = names.begin();nameiter != names.end();nameiter++) | ||||
|     { | ||||
|  | @ -89,6 +90,19 @@ void Animation::setAnimationSources(const std::vector<std::string> &names) | |||
|             mAnimationSources.pop_back(); | ||||
|             continue; | ||||
|         } | ||||
|         const NifOgre::ObjectList &objects = mAnimationSources.back(); | ||||
| 
 | ||||
|         for(size_t i = 0;i < objects.mControllers.size();i++) | ||||
|         { | ||||
|             NifOgre::NodeTargetValue<Ogre::Real> *dstval = dynamic_cast<NifOgre::NodeTargetValue<Ogre::Real>*>(objects.mControllers[i].getDestination().getPointer()); | ||||
|             if(!dstval) continue; | ||||
| 
 | ||||
|             const Ogre::String &trgtname = dstval->getNode()->getName(); | ||||
|             if(!skelinst->hasBone(trgtname)) continue; | ||||
| 
 | ||||
|             Ogre::Bone *bone = skelinst->getBone(trgtname); | ||||
|             dstval->setNode(bone); | ||||
|         } | ||||
| 
 | ||||
|         Ogre::Entity *ent = mAnimationSources.back().mSkelBase; | ||||
|         Ogre::SkeletonPtr skel = Ogre::SkeletonManager::getSingleton().getByName(ent->getSkeleton()->getName()); | ||||
|  |  | |||
|  | @ -108,10 +108,9 @@ public: | |||
| class VisController | ||||
| { | ||||
| public: | ||||
|     class Value : public Ogre::ControllerValue<Ogre::Real> | ||||
|     class Value : public NodeTargetValue<Ogre::Real> | ||||
|     { | ||||
|     private: | ||||
|         Ogre::Bone *mTarget; | ||||
|         std::vector<Nif::NiVisData::VisData> mData; | ||||
| 
 | ||||
|         virtual bool calculate(Ogre::Real time) | ||||
|  | @ -149,8 +148,8 @@ public: | |||
|         } | ||||
| 
 | ||||
|     public: | ||||
|         Value(Ogre::Bone *target, const Nif::NiVisData *data) | ||||
|           : mTarget(target) | ||||
|         Value(Ogre::Node *target, const Nif::NiVisData *data) | ||||
|           : NodeTargetValue<Ogre::Real>(target) | ||||
|           , mData(data->mVis) | ||||
|         { } | ||||
| 
 | ||||
|  | @ -163,7 +162,7 @@ public: | |||
|         virtual void setValue(Ogre::Real time) | ||||
|         { | ||||
|             bool vis = calculate(time); | ||||
|             setVisible(mTarget, vis); | ||||
|             setVisible(mNode, vis); | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -74,6 +74,24 @@ public: | |||
|                                        const std::string &group="General"); | ||||
| }; | ||||
| 
 | ||||
| // FIXME: Should be with other general Ogre extensions.
 | ||||
| template<typename T> | ||||
| class NodeTargetValue : public Ogre::ControllerValue<T> | ||||
| { | ||||
| protected: | ||||
|     Ogre::Node *mNode; | ||||
| 
 | ||||
| public: | ||||
|     NodeTargetValue(Ogre::Node *target) : mNode(target) | ||||
|     { } | ||||
| 
 | ||||
|     void setNode(Ogre::Node *target) | ||||
|     { mNode = target; } | ||||
|     Ogre::Node *getNode() const | ||||
|     { return mNode; } | ||||
| }; | ||||
| typedef Ogre::SharedPtr<NodeTargetValue<Ogre::Real> > NodeTargetValueRealPtr; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| namespace std | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue