mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 19:56:38 +00:00 
			
		
		
		
	Attempt to load the skeleton source if it doesn't yet exist
This commit is contained in:
		
							parent
							
								
									c839502743
								
							
						
					
					
						commit
						8b1e7b95ba
					
				
					 3 changed files with 36 additions and 2 deletions
				
			
		|  | @ -52,8 +52,13 @@ Ogre::Bone *Animation::insertSkeletonSource(const std::string &name) | |||
|     Ogre::SkeletonPtr skel = skelMgr.getByName(name); | ||||
|     if(skel.isNull()) | ||||
|     { | ||||
|         std::cerr<< "Failed to get skeleton source "<<name <<std::endl; | ||||
|         return NULL; | ||||
|         NifOgre::Loader::createSkeleton(name); | ||||
|         skel = skelMgr.getByName(name); | ||||
|         if(skel.isNull()) | ||||
|         { | ||||
|             std::cerr<< "Failed to get skeleton source "<<name <<std::endl; | ||||
|             return NULL; | ||||
|         } | ||||
|     } | ||||
|     skel->touch(); | ||||
|     mSkeletonSources.push_back(skel); | ||||
|  |  | |||
|  | @ -1250,6 +1250,33 @@ EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonen | |||
| } | ||||
| 
 | ||||
| 
 | ||||
| bool Loader::createSkeleton(const std::string &name, const std::string &group) | ||||
| { | ||||
|     Nif::NIFFile::ptr pnif = Nif::NIFFile::create(name); | ||||
|     Nif::NIFFile &nif = *pnif.get(); | ||||
|     if(nif.numRecords() < 1) | ||||
|     { | ||||
|         nif.warn("Found no NIF records in "+name+"."); | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     // The first record is assumed to be the root node
 | ||||
|     Nif::Record const *r = nif.getRecord(0); | ||||
|     assert(r != NULL); | ||||
| 
 | ||||
|     Nif::Node const *node = dynamic_cast<Nif::Node const *>(r); | ||||
|     if(node == NULL) | ||||
|     { | ||||
|         nif.warn("First record in "+name+" was not a node, but a "+ | ||||
|                  r->recName+"."); | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     NIFSkeletonLoader skelldr; | ||||
|     return skelldr.createSkeleton(name, group, node); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /* More code currently not in use, from the old D source. This was
 | ||||
|    used in the first attempt at loading NIF meshes, where each submesh | ||||
|    in the file was given a separate bone in a skeleton. Unfortunately | ||||
|  |  | |||
|  | @ -77,6 +77,8 @@ public: | |||
|     static EntityList createEntities(Ogre::SceneNode *parentNode, | ||||
|                                      std::string name, | ||||
|                                      const std::string &group="General"); | ||||
| 
 | ||||
|     static bool createSkeleton(const std::string &name, const std::string &group="General"); | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue