コード例 #1
0
Animation *SystemMenuResource::LoadAnimation( const U8Archive &arc, const std::string &lanName )
{
	u8 *stuff = arc.GetFile( "/arc/anim/" + lanName + ".brlan" );
	if( !stuff )
	{
		return NULL;
	}
	Animation *brlan = new Animation( lanName );
	brlan->Load( (const RLAN_Header*)stuff );
	return brlan;
}
コード例 #2
0
void ColladaDoc::LoadAnimations(
	lpxmlnode						 pNode)
{
	lpxmlnode pCurrNode = pNode;

	while(pCurrNode != NULL) {
		Animation anim;
		anim.Load(pCurrNode->first_node());
		library_animations.push_back(anim);
		pCurrNode = pCurrNode->next_sibling();
	};
}
コード例 #3
0
void World::LoadScene(const char * scene_path)
{
	// Using case-insensitive strings and streams for easier parsing
	ci_ifstream input;
	input.open(scene_path, ios::in);

	// Invalid file
	if (input.fail())
	{
		fprintf(stderr, "Error loading file: %s\n", scene_path);
		getchar();
		exit(-1);
	}

	ci_string item;
	while (std::getline(input, item, '['))
	{
		ci_istringstream iss(item);

		ci_string result;
		if (std::getline(iss, result, ']'))
		{
			if (result == "player")
			{
				// Box attributes
				PlayerModel* player = new PlayerModel();
				player->Load(iss);
				mModel.push_back(player);

				mPlayerModel = player;
			}
			else if (result == "discoball")
			{
				// Box attributes
				Discoball* discoBallz = new Discoball();
				discoBallz->Load(iss);
				mModel.push_back(discoBallz);
			}
			else if (result == "bunnny")
			{
				// Box attributes
				BunnyModel* bunny = new BunnyModel();
				bunny->Load(iss);
				mModel.push_back(bunny);
			}
			else if (result == "barrel")
			{
				// Box attributes
				BarrelModel* barrel = new BarrelModel();
				barrel->Load(iss);
				mModel.push_back(barrel);
			}
			else if (result == "cube")
			{
				// Box attributes
				CubeModel* cube = new CubeModel();
				cube->Load(iss);
				mModel.push_back(cube);
			}
			else if (result == "sphere")
			{
				SphereModel* sphere = new SphereModel();
				sphere->Load(iss);
				mModel.push_back(sphere);
			}
			else if (result == "animationkey")
			{
				AnimationKey* key = new AnimationKey();
				key->Load(iss);
				mAnimationKey.push_back(key);
			}
			else if (result == "animation")
			{
				Animation* anim = new Animation();
				anim->Load(iss);
				mAnimation.push_back(anim);
			}
			else if (result.empty() == false && result[0] == '#')
			{
				// this is a comment line
			}
			else
			{
				fprintf(stderr, "Error loading scene file... !");
				getchar();
				exit(-1);
			}
		}
	}
	input.close();

	if (DRAW_ANIM_PATH) {
		for (vector<Animation*>::iterator it = mAnimation.begin(); it < mAnimation.end(); ++it)
		{
			(*it)->CreateVertexBuffer();
		}
	}
}
コード例 #4
0
/**
 * Load sprites from the disk.
 * @param filename Name of the RCD file to load.
 * @return Error message if load failed, else \c nullptr.
 * @todo Try to re-use already loaded blocks.
 * @todo Code will use last loaded surface as grass.
 */
const char *SpriteManager::Load(const char *filename)
{
	RcdFileReader rcd_file(filename);
	if (!rcd_file.CheckFileHeader("RCDF", 2)) return "Bad header";

	ImageMap sprites; // Sprites loaded from this file.
	TextMap  texts;   // Texts loaded from this file.
	TrackPiecesMap track_pieces; // Track pieces loaded from this file.

	/* Load blocks. */
	for (uint blk_num = 1;; blk_num++) {
		if (!rcd_file.ReadBlockHeader()) return nullptr; // End reached.

		/* Skip meta blocks. */
		if (strcmp(rcd_file.name, "INFO") == 0) {
			rcd_file.SkipBytes(rcd_file.size);
			continue;
		}

		if (strcmp(rcd_file.name, "8PXL") == 0 || strcmp(rcd_file.name, "32PX") == 0) {
			ImageData *imd = LoadImage(&rcd_file);
			if (imd == nullptr) {
				return "Image data loading failed";
			}
			std::pair<uint, ImageData *> p(blk_num, imd);
			sprites.insert(p);
			continue;
		}

		if (strcmp(rcd_file.name, "SURF") == 0) {
			if (!this->LoadSURF(&rcd_file, sprites)) return "Surface block loading failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "TSEL") == 0) {
			if (!this->LoadTSEL(&rcd_file, sprites)) return "Tile-selection block loading failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "PATH") == 0) {
			if (!this->LoadPATH(&rcd_file, sprites)) return "Path-sprites block loading failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "TCOR") == 0) {
			if (!this->LoadTCOR(&rcd_file, sprites)) return "Tile-corners block loading failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "FUND") == 0) {
			if (!this->LoadFUND(&rcd_file, sprites)) return "Foundation block loading failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "PLAT") == 0) {
			if (!this->LoadPLAT(&rcd_file, sprites)) return "Platform block loading failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "SUPP") == 0) {
			if (!this->LoadSUPP(&rcd_file, sprites)) return "Support block loading failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "BDIR") == 0) {
			if (!this->LoadBDIR(&rcd_file, sprites)) return "Build arrows block loading failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "GCHK") == 0) {
			if (!_gui_sprites.LoadGCHK(&rcd_file, sprites)) return "Loading Checkable GUI sprites failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "GBOR") == 0) {
			if (!_gui_sprites.LoadGBOR(&rcd_file, sprites)) return "Loading Border GUI sprites failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "GSLI") == 0) {
			if (!_gui_sprites.LoadGSLI(&rcd_file, sprites)) return "Loading Slider bar GUI sprites failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "GSCL") == 0) {
			if (!_gui_sprites.LoadGSCL(&rcd_file, sprites)) return "Loading Scrollbar GUI sprites failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "GSLP") == 0) {
			if (!_gui_sprites.LoadGSLP(&rcd_file, sprites, texts)) return "Loading slope selection GUI sprites failed.";
			continue;
		}

		if (strcmp(rcd_file.name, "ANIM") == 0) {
			Animation *anim = new Animation;
			if (!anim->Load(&rcd_file)) {
				delete anim;
				return "Animation failed to load.";
			}
			if (anim->person_type == PERSON_INVALID || anim->anim_type == ANIM_INVALID) {
				delete anim;
				return "Unknown animation.";
			}
			this->AddBlock(anim);
			this->AddAnimation(anim);
			this->store.RemoveAnimations(anim->anim_type, (PersonType)anim->person_type);
			continue;
		}

		if (strcmp(rcd_file.name, "ANSP") == 0) {
			AnimationSprites *an_spr = new AnimationSprites;
			if (!an_spr->Load(&rcd_file, sprites)) {
				delete an_spr;
				return "Animation sprites failed to load.";
			}
			if (an_spr->person_type == PERSON_INVALID || an_spr->anim_type == ANIM_INVALID) {
				delete an_spr;
				return "Unknown animation.";
			}
			this->AddBlock(an_spr);
			this->store.AddAnimationSprites(an_spr);
			continue;
		}

		if (strcmp(rcd_file.name, "PRSG") == 0) {
			if (!LoadPRSG(&rcd_file)) return "Graphics Person type data failed to load.";
			continue;
		}

		if (strcmp(rcd_file.name, "TEXT") == 0) {
			TextData *txt = new TextData;
			if (!txt->Load(&rcd_file)) {
				delete txt;
				return "Text block failed to load.";
			}
			this->AddBlock(txt);

			std::pair<uint, TextData *> p(blk_num, txt);
			texts.insert(p);
			continue;
		}

		if (strcmp(rcd_file.name, "SHOP") == 0) {
			ShopType *shop_type = new ShopType;
			if (!shop_type->Load(&rcd_file, sprites, texts)) {
				delete shop_type;
				return "Shop type failed to load.";
			}
			_rides_manager.AddRideType(shop_type);
			continue;
		}

		if (strcmp(rcd_file.name, "TRCK") == 0) {
			auto tp = std::make_shared<TrackPiece>();
			if (!tp->Load(&rcd_file, sprites)) {
				return "Track piece failed to load.";
			}
			track_pieces.insert({blk_num, tp});
			continue;
		}

		if (strcmp(rcd_file.name, "RCST") == 0) {
			CoasterType *ct = new CoasterType;
			if (!ct->Load(&rcd_file, texts, track_pieces)) {
				delete ct;
				return "Coaster type failed to load.";
			}
			_rides_manager.AddRideType(ct);
			continue;
		}

		if (strcmp(rcd_file.name, "CSPL") == 0) {
			if (!LoadCoasterPlatform(&rcd_file, sprites)) return "Coaster platform failed to load.";
			continue;
		}

		if (strcmp(rcd_file.name, "CARS") == 0) {
			CarType *ct = GetNewCarType();
			if (ct == nullptr) return "No room to store a car type.";
			if (!ct->Load(&rcd_file, sprites)) return "Car type failed to load.";
			continue;
		}

		/* Unknown block in the RCD file. Skip the block. */
		fprintf(stderr, "Unknown RCD block '%s', version %i, ignoring it\n", rcd_file.name, rcd_file.version);
		rcd_file.SkipBytes(rcd_file.size);
	}
}
コード例 #5
0
ファイル: Puppet.cpp プロジェクト: soundofjw/Monocle-Engine
	void Puppet::Load(const std::string &filename, Entity *entity)
	{
		this->filename = filename;
		animations.clear();
		// delete parts?
		parts.clear();
		
		TiXmlDocument xmlDoc(Assets::GetContentPath() + filename);
		
		if (xmlDoc.LoadFile())
		{
			/// TextureAtlas
			TiXmlElement *xmlTextureAtlas = xmlDoc.FirstChildElement("TextureAtlas");
			if (xmlTextureAtlas)
			{
				textureAtlas = new TextureAtlas();
				textureAtlas->Load(xmlTextureAtlas);
			}
			
			/// Parts
			TiXmlElement *xmlParts = xmlDoc.FirstChildElement("Parts");
			if (xmlParts)
			{
				LoadParts(xmlParts, entity);
			}

			/// Animations
			TiXmlElement *xmlAnimations = xmlDoc.FirstChildElement("Animations");
			if (xmlAnimations)
			{
				/// Animation
				TiXmlElement *xmlAnimation = xmlAnimations->FirstChildElement("Animation");
				while (xmlAnimation)
				{
					Animation animation;
                    XMLFileNode xmlFileNodeKeyFrameAnim(xmlAnimation);
					animation.Load(&xmlFileNodeKeyFrameAnim);

					/// PartKeyFrames
					TiXmlElement *xmlPartKeyFrames = xmlAnimation->FirstChildElement("PartKeyFrames");
					while (xmlPartKeyFrames)
					{
						PartKeyFrames partKeyFrames;
						partKeyFrames.SetPuppet(this);
                        XMLFileNode xmlFileNodeKeyFramePart(xmlPartKeyFrames);
						partKeyFrames.Load(&xmlFileNodeKeyFramePart);

						/// KeyFrame
						TiXmlElement *xmlKeyFrame = xmlPartKeyFrames->FirstChildElement("KeyFrame");
						while (xmlKeyFrame)
						{
							KeyFrame keyFrame;
                            XMLFileNode xmlFileNodeKeyFrame(xmlKeyFrame);
							keyFrame.Load(&xmlFileNodeKeyFrame);
							partKeyFrames.AddKeyFrame(keyFrame);

							xmlKeyFrame = xmlKeyFrame->NextSiblingElement("KeyFrame");
						}

						animation.AddPartKeyFrames(partKeyFrames);

						xmlPartKeyFrames = xmlPartKeyFrames->NextSiblingElement("PartKeyFrames");
					}

					animation.RefreshDuration();
					animations.push_back(animation);

					xmlAnimation = xmlAnimation->NextSiblingElement("Animation");
				}
			}
		}
		else
		{
			Debug::Log("Warning: Could not open puppet file: " + Assets::GetContentPath() + filename);
			Debug::Log("         " + std::string(xmlDoc.ErrorDesc()));
			printf("         Row: %d\n", xmlDoc.ErrorRow());
		}
	}
コード例 #6
0
void World::LoadScene(const char * scene_path)
{
	// Using case-insensitive strings and streams for easier parsing
	ci_ifstream input;
	input.open(scene_path, ios::in);

	// Invalid file
	if (input.fail())
	{
		fprintf(stderr, "Error loading file: %s\n", scene_path);
		getchar();
		exit(-1);
	}

	ci_string item;
	while (std::getline(input, item, '['))
	{
		ci_istringstream iss(item);

		ci_string result;
		if (std::getline(iss, result, ']'))
		{
			if (result == "cube")
			{
				CubeModel* cube = new CubeModel();
				cube->Load(iss);
				mModel.push_back(cube);
			}
			else if (result == "sphere")
			{
#if defined(PLATFORM_OSX)
				int sphereTextureID = TextureLoader::LoadTexture("Textures/moonTexture.jpg");
#else
				int sphereTextureID = TextureLoader::LoadTexture("../Assets/Textures/moonTexture.jpg");
#endif

				SphereModel* moon = new SphereModel(sphereTextureID, vec3(10.0f, 10.0f, 10.0f));
				moon->Load(iss);
				mModel.push_back(moon);
			}
			else if (result == "animationkey")
			{
				AnimationKey* key = new AnimationKey();
				key->Load(iss);
				mAnimationKey.push_back(key);
			}
			else if (result == "animation")
			{
				Animation* anim = new Animation();
				anim->Load(iss);
				mAnimation.push_back(anim);
			}
			else if (result.empty() == false && result[0] == '#')
			{
				// this is a comment line
			}
			else
			{
				fprintf(stderr, "Error loading scene file... !");
				getchar();
				exit(-1);
			}
		}
	}
	input.close();

	// Set Animation vertex buffers
	for (vector<Animation*>::iterator it = mAnimation.begin(); it < mAnimation.end(); ++it)
	{
		// Draw model
		(*it)->CreateVertexBuffer();
	}
}
コード例 #7
0
ファイル: World.cpp プロジェクト: vivigao/shang
void World::LoadScene(const char * scene_path){
	// Using case-insensitive strings and streams for easier parsing
	ci_ifstream input;
	input.open(scene_path, ios::in);

	// Invalid file
	if(input.fail() ){	 
		fprintf(stderr, "Error loading file: %s\n", scene_path);
		getchar();
		exit(-1);
	}

	ci_string item;
	while( std::getline( input, item, '[' ) ){
        ci_istringstream iss( item );

		ci_string result;
		if( std::getline( iss, result, ']') ){
			if( result == "cube" ){
				// Box attributes
				//CubeModel* cube = new CubeModel();
				ourGuy->Load(iss);
				mModel.push_back(ourGuy);
			}
			else if( result == "ground" ){
				// Box attributes
				CubeModel* cube = new CubeModel();
				cube->Load(iss);
				mModel.push_back(cube);
			}
            else if( result == "sphere" ){
                //SphereModel* sphere = new SphereModel();
                ourSphere->Load(iss);
                mModel.push_back(ourSphere);
            }
			else if ( result == "animationkey" ){
				AnimationKey* key = new AnimationKey();
				key->Load(iss);
				mAnimationKey.push_back(key);
			}
			else if (result == "animation"){
				Animation* anim = new Animation();
				anim->Load(iss);
				mAnimation.push_back(anim);
			}//*/
			else if (result == "bspline"){
				BSpline* spline = new BSpline();
				spline->Load(iss);
				mBSpline.push_back(spline);
			}//*/
			else if ( result.empty() == false && result[0] == '#'){
				// this is a comment line
			}
			else{
				fprintf(stderr, "Error loading scene file... !");
				getchar();
				exit(-1);
			}
	    }
	}
	input.close();

	// Set Animation vertex buffers
	for (vector<Animation*>::iterator it = mAnimation.begin(); it < mAnimation.end(); ++it)
		// Draw model
		(*it)->CreateVertexBuffer();
}