mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 23:26:41 +00:00 
			
		
		
		
	Partially handle NiGeomMorpherController
The morphs aren't actually applied yet, but the Ogre controller is set up so all that has to be done is to implement the setValue method.
This commit is contained in:
		
							parent
							
								
									d936291dbf
								
							
						
					
					
						commit
						59137d93c9
					
				
					 3 changed files with 60 additions and 2 deletions
				
			
		|  | @ -116,6 +116,20 @@ void NIFMeshLoader::createSubMesh(Ogre::Mesh *mesh, const Nif::NiTriShape *shape | |||
|     std::vector<Ogre::Vector3> srcNorms = data->normals; | ||||
|     Ogre::HardwareBuffer::Usage vertUsage = Ogre::HardwareBuffer::HBU_STATIC; | ||||
|     bool vertShadowBuffer = false; | ||||
| 
 | ||||
|     if(!shape->controller.empty()) | ||||
|     { | ||||
|         Nif::ControllerPtr ctrl = shape->controller; | ||||
|         do { | ||||
|             if(ctrl->recType == Nif::RC_NiGeomMorpherController) | ||||
|             { | ||||
|                 vertUsage = Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY; | ||||
|                 vertShadowBuffer = true; | ||||
|                 break; | ||||
|             } | ||||
|         } while(!(ctrl=ctrl->next).empty()); | ||||
|     } | ||||
| 
 | ||||
|     if(skin != NULL) | ||||
|     { | ||||
|         vertUsage = Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY; | ||||
|  |  | |||
|  | @ -293,7 +293,7 @@ public: | |||
|         } | ||||
| 
 | ||||
|     public: | ||||
|         Value(const Ogre::MaterialPtr &material, Nif::NiUVData *data) | ||||
|         Value(const Ogre::MaterialPtr &material, const Nif::NiUVData *data) | ||||
|           : mMaterial(material) | ||||
|           , mUTrans(data->mKeyList[0]) | ||||
|           , mVTrans(data->mKeyList[1]) | ||||
|  | @ -363,6 +363,36 @@ public: | |||
|     typedef DefaultFunction Function; | ||||
| }; | ||||
| 
 | ||||
| class GeomMorpherController | ||||
| { | ||||
| public: | ||||
|     class Value : public Ogre::ControllerValue<Ogre::Real> | ||||
|     { | ||||
|     private: | ||||
|         Ogre::SubEntity *mSubEntity; | ||||
|         std::vector<Nif::NiMorphData::MorphData> mMorphs; | ||||
| 
 | ||||
|     public: | ||||
|         Value(Ogre::SubEntity *subent, const Nif::NiMorphData *data) | ||||
|           : mSubEntity(subent) | ||||
|           , mMorphs(data->mMorphs) | ||||
|         { } | ||||
| 
 | ||||
|         virtual Ogre::Real getValue() const | ||||
|         { | ||||
|             // Should not be called
 | ||||
|             return 0.0f; | ||||
|         } | ||||
| 
 | ||||
|         virtual void setValue(Ogre::Real value) | ||||
|         { | ||||
|             // TODO: Implement
 | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     typedef DefaultFunction Function; | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| /** Object creator for NIFs. This is the main class responsible for creating
 | ||||
|  * "live" Ogre objects (entities, particle systems, controllers, etc) from | ||||
|  | @ -429,6 +459,19 @@ class NIFObjectLoader | |||
| 
 | ||||
|                 objectlist.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func)); | ||||
|             } | ||||
|             else if(ctrl->recType == Nif::RC_NiGeomMorpherController) | ||||
|             { | ||||
|                 const Nif::NiGeomMorpherController *geom = static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr()); | ||||
| 
 | ||||
|                 Ogre::SubEntity *subent = entity->getSubEntity(0); | ||||
|                 Ogre::ControllerValueRealPtr srcval((animflags&Nif::NiNode::AnimFlag_AutoPlay) ? | ||||
|                                                     Ogre::ControllerManager::getSingleton().getFrameTimeSource() : | ||||
|                                                     Ogre::ControllerValueRealPtr()); | ||||
|                 Ogre::ControllerValueRealPtr dstval(OGRE_NEW GeomMorpherController::Value(subent, geom->data.getPtr())); | ||||
|                 Ogre::ControllerFunctionRealPtr func(OGRE_NEW GeomMorpherController::Function(geom, (animflags&Nif::NiNode::AnimFlag_AutoPlay))); | ||||
| 
 | ||||
|                 objectlist.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func)); | ||||
|             } | ||||
|             ctrl = ctrl->next; | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -179,7 +179,8 @@ void NIFSkeletonLoader::buildBones(Ogre::Skeleton *skel, const Nif::Node *node, | |||
|             ctrls.push_back(static_cast<const Nif::NiKeyframeController*>(ctrl.getPtr())); | ||||
|         else if(!(ctrl->recType == Nif::RC_NiParticleSystemController || | ||||
|                   ctrl->recType == Nif::RC_NiVisController || | ||||
|                   ctrl->recType == Nif::RC_NiUVController | ||||
|                   ctrl->recType == Nif::RC_NiUVController || | ||||
|                   ctrl->recType == Nif::RC_NiGeomMorpherController | ||||
|                   )) | ||||
|             warn("Unhandled "+ctrl->recName+" from node "+node->name+" in "+skel->getName()); | ||||
|         ctrl = ctrl->next; | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue