Unreal/CarlaUE4/Plugins/RoadRunnerImporter/Source/RoadRunnerImporter/Private/RoadRunnerImportUtil.cpp
////////////////////////////////////////////////////////////////////////////////
// Helper function to parse the material info from the *.rrdata.xml file
Helper function to parse the material info from the *.rrdata.xml file
Helper function to parse the material info from the * . rrdata . xml file
TArray<FRoadRunnerImportUtil::MaterialInfo> FRoadRunnerImportUtil::ParseMaterialXml(FXmlNode * matList)
{
	TArray<MaterialInfo> retList;
	const auto& xmlMats = matList->GetChildrenNodes();
	for (const auto& mat : xmlMats)
	{
		const auto& matProperties = mat->GetChildrenNodes();
		FRoadRunnerImportUtil::MaterialInfo matInfo;
		for (const auto& matProperty : matProperties)
		{
			const FString& tag = matProperty->GetTag();
			if (tag.Equals(TEXT("Name"), ESearchCase::CaseSensitive))
			{
				matInfo.Name = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("DiffuseMap"), ESearchCase::CaseSensitive))
			{
				matInfo.DiffuseMap = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("NormalMap"), ESearchCase::CaseSensitive))
			{
				matInfo.NormalMap = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("SpecularMap"), ESearchCase::CaseSensitive))
			{
				matInfo.SpecularMap = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("DiffuseColor"), ESearchCase::CaseSensitive))
			{
				matInfo.DiffuseColor = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("TransparentColor"), ESearchCase::CaseSensitive))
			{
				matInfo.TransparencyMap = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("TransparencyFactor"), ESearchCase::CaseSensitive))
			{
				matInfo.TransparencyFactor = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("SpecularColor"), ESearchCase::CaseSensitive))
			{
				matInfo.SpecularColor = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("SpecularFactor"), ESearchCase::CaseSensitive))
			{
				matInfo.SpecularFactor = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("Roughness"), ESearchCase::CaseSensitive))
			{
				matInfo.Roughness = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("Emission"), ESearchCase::CaseSensitive))
			{
				matInfo.Emission = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("TextureScaleU"), ESearchCase::CaseSensitive))
			{
				matInfo.TextureScaleU = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("TextureScaleV"), ESearchCase::CaseSensitive))
			{
				matInfo.TextureScaleV = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("TwoSided"), ESearchCase::CaseSensitive))
			{
				matInfo.TwoSided = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("DrawQueue"), ESearchCase::CaseSensitive))
			{
				matInfo.DrawQueue = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("ShadowCaster"), ESearchCase::CaseSensitive))
			{
				matInfo.ShadowCaster = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("IsDecal"), ESearchCase::CaseSensitive))
			{
				matInfo.IsDecal = matProperty->GetContent();
			}
			else if (tag.Equals(TEXT("AmbientColor")))
			{
			}
			else if (tag.Equals(TEXT("SegmentationType")))
			{
				matInfo.SegmentationType = matProperty->GetContent();
			}
			else
			{
				UE_LOG(RoadRunnerImporter, Warning, TEXT("Unrecognized element '%s' found in material property"), *tag);
			}
		}
		if (matInfo.Name.IsEmpty())
		{
			UE_LOG(RoadRunnerImporter, Warning, TEXT("Material is missing a name"));
			continue;
		}
		matInfo.Name = FRoadRunnerImportUtil::ConvertMaterialName(matInfo.Name);
		retList.Add(matInfo);
	}
	return retList;
}
TArray < FRoadRunnerImportUtil :: MaterialInfo > FRoadRunnerImportUtil :: ParseMaterialXml ( FXmlNode * matList ) { TArray < MaterialInfo > retList ; const auto & xmlMats = matList -> GetChildrenNodes ( ) ; for ( const auto & mat : xmlMats ) { const auto & matProperties = mat -> GetChildrenNodes ( ) ; FRoadRunnerImportUtil :: MaterialInfo matInfo ; for ( const auto & matProperty : matProperties ) { const FString & tag = matProperty -> GetTag ( ) ; if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . Name = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . DiffuseMap = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . NormalMap = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . SpecularMap = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . DiffuseColor = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . TransparencyMap = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . TransparencyFactor = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . SpecularColor = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . SpecularFactor = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . Roughness = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . Emission = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . TextureScaleU = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . TextureScaleV = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . TwoSided = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . DrawQueue = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . ShadowCaster = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) , ESearchCase :: CaseSensitive ) ) { matInfo . IsDecal = matProperty -> GetContent ( ) ; } else if ( tag . Equals ( TEXT ( " " ) ) ) { } else if ( tag . Equals ( TEXT ( " " ) ) ) { matInfo . SegmentationType = matProperty -> GetContent ( ) ; } else { UE_LOG ( RoadRunnerImporter , Warning , TEXT ( " " ) , * tag ) ; } } if ( matInfo . Name . IsEmpty ( ) ) { UE_LOG ( RoadRunnerImporter , Warning , TEXT ( " " ) ) ; continue ; } matInfo . Name = FRoadRunnerImportUtil :: ConvertMaterialName ( matInfo . Name ) ; retList . Add ( matInfo ) ; } return retList ; }
Helper function to parse the material info from the *.rrdata.xml file
Helper function to parse the material info from the * . rrdata . xml file
// Fill out material info struct based off xml // Unused // Validation // Follow Unreal's naming scheme