/// Use "MeshNode" as the element name of the argument 'reader'
void MeshContainerNodeRenderMethod::LoadFromXMLNode( XMLNode& reader )
{
	vector<XMLNode> vecReader = reader.GetImmediateChildren( "MeshContainerRenderMethod" );
	m_vecpContainerRenderMethod.resize( vecReader.size() );
	for( size_t i=0; i<vecReader.size(); i++ )
	{
		m_vecpContainerRenderMethod[i].reset( new MeshContainerRenderMethod() );
		m_vecpContainerRenderMethod[i]->LoadFromXMLNode( vecReader[i] );
	}

	vector<XMLNode> vecChild = reader.GetImmediateChildren( "MeshContainerNodeRenderMethod" );
	m_vecpChild.resize( vecChild.size() );
	for( size_t i=0; i<vecChild.size(); i++ )
	{
		m_vecpChild[i].reset( new MeshContainerNodeRenderMethod() ); 
		m_vecpChild[i]->LoadFromXMLNode( vecChild[i] );
	}
}
void MeshContainerRenderMethod::LoadFromXMLNode( XMLNode& reader )
{
//	m_vecSubsetNameToRenderMethod.resize( 1 );

//	m_MeshRenderMethod.LoadFromXMLNode( reader );

	vector<XMLNode> vecMeshRenderMethod = reader.GetImmediateChildren( "MeshRenderMethod" );
	m_RenderMethodsAndSubsetIndices.resize( vecMeshRenderMethod.size() );
	for( size_t i=0; i<vecMeshRenderMethod.size(); i++ )
	{
		m_RenderMethodsAndSubsetIndices[i].first.LoadFromXMLNode( vecMeshRenderMethod[i] );
	}

	vector<XMLNode> vecSubsetRenderMethod = reader.GetImmediateChildren( "SubsetRenderMethod" );
	for( size_t i=0; i<vecSubsetRenderMethod.size(); i++ )
	{
		int lod = 0;
//		string lod_str = vecSubsetRenderMethod[i].GetAttributeText( "lod" );
//		if( lod_str == "" )
//			lod = 0;
//		else
//			lod = to_int(lod_str);
//
//		clamp( lod, 0, 7 );
//
//		while( (int)m_vecSubsetNameToRenderMethod.size() <= lod )
//			m_vecSubsetNameToRenderMethod.push_back( map< string, SubsetRenderMethod >() );

		string subset_name = "";
		vecSubsetRenderMethod[i].GetChildElementTextContent( "Name", subset_name );

//		shared_ptr<SubsetRenderMethod> pSubsetRenderMethod = ;
		SubsetRenderMethod subset_render_method;
		subset_render_method.LoadFromXMLNode( vecSubsetRenderMethod[i] );
		m_vecSubsetNameToRenderMethod[lod][subset_name] = subset_render_method;
	}
}
void CRotatableTurret::LoadFromXMLNode( XMLNode& reader )
{
	GameItem::LoadFromXMLNode( reader );

	string ammo_name, ammo_quantity;

	reader.GetChildElementTextContent( "Weapon",      m_WeaponName );

	vector<XMLNode> vecAmmo = reader.GetImmediateChildren( "Ammunition" );
//	m_vecpAmmunition.resize( vecAmmo.size() );
	m_vecAmmunition.resize( vecAmmo.size() );
	for( size_t i=0; i<vecAmmo.size(); i++ )
	{
		// name
		m_vecAmmunition[i].m_AmmunitionName = vecAmmo[i].GetTextContent();

		// quantity
		ammo_quantity = vecAmmo[i].GetAttributeText( "quantity" );
		if( ammo_quantity == "" )
			ammo_quantity = "infinite";
		if( ammo_quantity == "infinite" )
		{
			// TODO: set infinite
			ammo_quantity = "100000000";
		}
		m_vecAmmunition[i].m_InitQuantity = to_int(ammo_quantity);

//		m_vecpAmmunition[i] = GetItemDatabaseManager().GetItem<CGI_Ammunition>( ammo_name, to_int(ammo_quantity) );
	}
/*
	vector<XMLNode> vecAmmoLoading = reader.GetChildElementTextContent( "AmmunitionLoading/Name",  ammo_name );
	const size_t num_loadings = vecAmmoLoading.size();
	m_vecpAmmunitionLoading.reserve( 8 );
	for( size_t i=0; i<num_loadings; i++ )
	{
		ammo_name = vecAmmoLoading[i].GetTextContent();
		num_loads = vecAmmoLoading[i].GetAttributeText();
		shared_ptr<CGI_Ammunition> pAmmunition = get_ammo( ammo_name );
		for( int j=0; j<num_loads; j++ )
			m_vecpAmmunitionLoading.push_back( pAmmunition );
	}
*/
	amorphous::LoadFromXMLNode( reader.GetChild( "Mount/LocalPose" ), m_MountLocalPose );
	amorphous::LoadFromXMLNode( reader.GetChild( "Gun/LocalPose" ),   m_GunLocalPose );

	m_MountMeshTransform = m_MeshTransform * m_MountLocalPose.GetInverseROT();
	m_GunMeshTransform   = m_MeshTransform * m_GunLocalPose.GetInverseROT();
}
Exemple #4
0
void CGI_Aircraft::LoadFromXMLNode( XMLNode& reader )
{
	GameItem::LoadFromXMLNode( reader );

	reader.GetChildElementTextContent( "Armor",           m_fArmor );
	reader.GetChildElementTextContent( "RCS",             m_fRCS );
	reader.GetChildElementTextContent( "Ceiling",         m_fCeiling );
	reader.GetChildElementTextContent( "CockpitLocalPos", m_CockpitLocalPose.vPosition );

	reader.GetChildElementTextContent( "ThirdPersonView/CameraPosition", m_vThirdPersonViewOffset );

//	reader.GetChildElementTextContent( m_vecNozzleFlameParams,  );

	XMLNode accels_reader = reader.GetChild( "Accel" );
	accels_reader.GetChildElementTextContent( "Default",    m_fAccel );
	accels_reader.GetChildElementTextContent( "Boost",      m_fBoostAccel );
	accels_reader.GetChildElementTextContent( "Brake",      m_fBrakeAccel );

//	reader.m_PitchRange reader.m_RollRange;

	reader.GetChildElementTextContent(  "MaxPitchAccel",  m_fMaxPitchAccel );
	reader.GetChildElementTextContent(  "MaxRollAccel",   m_fMaxRollAccel );
	reader.GetChildElementTextContent(  "MaxYawAccel",    m_fMaxYawAccel );

	reader.GetChildElementTextContent( "GunMuzzleEndPos", m_vGunMuzzleEndLocalPos );

	std::vector<XMLNode> payloads = reader.GetImmediateChildren( "AmmoPayload" );

	const size_t num_payload_info = payloads.size();
	m_vecSupportedAmmo.resize( num_payload_info );
	for( size_t i = 0; i<num_payload_info; i++ )
	{
		m_vecSupportedAmmo[i].LoadFromXMLNode( payloads[i] );
	}

	XMLNode components_reader = reader.GetChild( "Components" );
	std::vector<XMLNode> components = components_reader.GetImmediateChildren();
//	std::vector<XMLNode> components = reader.GetImmediateChildren( "Components" );
	for( size_t i = 0; i<components.size(); i++ )
	{
		XMLNode& component_reader = components[i];
		shared_ptr<MeshBoneController_AircraftBase> pComponent;
		if( component_reader.GetName() == "Flap" )
		{
			pComponent = shared_ptr<MeshBoneController_AircraftBase>( new MeshBoneController_Flap() );
		}
		else if( component_reader.GetName() == "VFlap" )
		{
			pComponent = shared_ptr<MeshBoneController_AircraftBase>( new MeshBoneController_VFlap() );
		}
		else if( component_reader.GetName() == "Rotor" )
		{
			pComponent = shared_ptr<MeshBoneController_AircraftBase>( new MeshBoneController_Rotor() );
		}
		else if( component_reader.GetName() == "GearUnit" )
		{
			// store to the gear unit array to open/close the gear box(es)
			shared_ptr<MeshBoneController_GearUnit> pGearUnit;
			pGearUnit = shared_ptr<MeshBoneController_GearUnit>( new MeshBoneController_GearUnit() );
			m_vecpGear.push_back( pGearUnit );

			pComponent = pGearUnit;
		}

		if( pComponent )
		{
			pComponent->LoadFromXMLNode( component_reader );

			m_vecpMeshController.push_back( pComponent );
		}
	}

}