bool VehicleController::LoadComponents()
{
	if (!LoadParts("Parts.txt"))
	{
		return false;
	}
	return true;
}
示例#2
0
/*
================
sdWalker::DoLoadVehicleScript
================
*/
void sdWalker::DoLoadVehicleScript( void ) {
	LoadParts( VPT_PART | VPT_SIMPLE_PART );

	lights.Clear();
	lights.Init( this );
	for( int i = 0; i < vehicleScript->lights.Num(); i++ ) {
		lights.AddLight( vehicleScript->lights[ i ]->lightInfo );
	}
}
示例#3
0
	void Puppet::LoadParts(TiXmlElement *element, Entity *intoEntity)
	{
		TiXmlElement *xmlPart = element->FirstChildElement("Part");
		while (xmlPart)
		{
			XMLFileNode xmlFileNode(xmlPart);

			Part *part = new Part();
			part->SetPuppet(this);
			part->Load(&xmlFileNode);
			
			LoadParts(xmlPart, part);

			parts.push_back(part);

			/// TODO...?
			intoEntity->Add(part);

			xmlPart = xmlPart->NextSiblingElement("Part");
		}
	}
示例#4
0
	void Puppet::LoadParts(TiXmlElement *element, Part *intoPart)
	{
		TiXmlElement *xmlPart = element->FirstChildElement("Part");
		while (xmlPart)
		{
			XMLFileNode xmlFileNode(xmlPart);

			Part *part = new Part();
			part->SetPuppet(this);
			part->Load(&xmlFileNode);
			
			LoadParts(xmlPart, part);

			printf("loaded part [%s]\n", part->GetName().c_str());

			if (intoPart)
			{
				intoPart->parts.push_back(part);
				part->SetParent(intoPart);

				printf("   into part [%s]\n", intoPart->GetName().c_str());
			}
			else
			{
				part->SetParent(entity);
			}

			parts.push_back(part);

			Game::GetScene()->Add(part);
			
			//intoEntity->Add(part);

			xmlPart = xmlPart->NextSiblingElement("Part");
		}
	}
示例#5
0
	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());
		}
	}