コード例 #1
0
ファイル: Puppet.cpp プロジェクト: soundofjw/Monocle-Engine
	void Puppet::Save(Entity *entity)
	{
		// save to filename
		TiXmlDocument xmlDoc;

		/// TextureAtlas
		if (textureAtlas)
		{
			textureAtlas->Save(&xmlDoc);
		}

		/// Parts
		//TiXmlElement *xmlParts = xmlDoc.FirstChildElement("Parts");
		TiXmlElement xmlParts("Parts");
		SaveParts(&xmlParts, entity);
		xmlDoc.InsertEndChild(xmlParts);


		/// Animations
		TiXmlElement xmlAnimations("Animations");
		{
			/// Animation
			for (std::list<Animation>::iterator i = animations.begin(); i != animations.end(); ++i)
			{
				TiXmlElement xmlAnimation("Animation");

				Animation *animation = &(*i);
                
                XMLFileNode xmlFileNodeKeyFrameAnim(&xmlAnimation);
				animation->Save(&xmlFileNodeKeyFrameAnim);

				/// PartKeyFrames
				for (std::list<Part*>::iterator j = parts.begin(); j != parts.end(); ++j)
				{
					PartKeyFrames *partKeyFrames = animation->GetPartKeyFrames(*j);
					if (partKeyFrames)
					{
						TiXmlElement xmlPartKeyFrames("PartKeyFrames");
						XMLFileNode xmlFileNodePartKeyFrames(&xmlPartKeyFrames);

						partKeyFrames->Save(&xmlFileNodePartKeyFrames);

						/// KeyFrame
					
						std::list<KeyFrame> *keyFrames = partKeyFrames->GetKeyFrames();
						for (std::list<KeyFrame>::iterator i = keyFrames->begin(); i != keyFrames->end(); ++i)
						{
							KeyFrame *keyFrame = &(*i);

							TiXmlElement xmlKeyFrame("KeyFrame");
							XMLFileNode xmlFileNodeKeyFrame(&xmlKeyFrame);

							keyFrame->Save(&xmlFileNodeKeyFrame);

							xmlPartKeyFrames.InsertEndChild(xmlKeyFrame);
						}

						xmlAnimation.InsertEndChild(xmlPartKeyFrames);
					}
				}

				xmlAnimations.InsertEndChild(xmlAnimation);
			}
		}
		xmlDoc.InsertEndChild(xmlAnimations);

		xmlDoc.SaveFile(Assets::GetContentPath() + filename);
	}