Example #1
0
	bool CObjectViewer::loadMesh(const std::string &meshFileName, const std::string &skelFileName)
	{
		CPath::addSearchPath(CFile::getPath(meshFileName), false, false);

		// create instance of the mesh character
		UInstance Entity = _Scene->createInstance(meshFileName);

		USkeleton Skeleton = _Scene->createSkeleton(skelFileName);

		// if we can't create entity, skip it
		if (Entity.empty()) return false;

		// create a new entity
		EIT eit = (_Entities.insert (make_pair (CFile::getFilenameWithoutExtension(meshFileName), CEntity()))).first;
		CEntity	&entity = (*eit).second;

		// set the entity up
		entity._Name = CFile::getFilenameWithoutExtension(meshFileName);
		entity._Instance = Entity;
		if (!Skeleton.empty()) 
		{
			entity._Skeleton = Skeleton;
			entity._Skeleton.bindSkin (entity._Instance);
		}
		entity._AnimationSet = _Driver->createAnimationSet(false);
		entity._PlayList = _PlayListManager->createPlayList(entity._AnimationSet);
		return true;
	}