/**
* Process and fill in the mesh Materials using the raw binary import data
* 
* @param Materials - [out] array of materials to update
* @param ImportData - raw binary import data to process
*/
void ProcessImportMeshMaterials(TArray<FSkeletalMaterial>& Materials, FSkeletalMeshImportData& ImportData )
{
	TArray <VMaterial>&	MaterialsBinary = ImportData.Materials;

	// If direct linkup of materials is requested, try to find them here - to get a texture name from a 
	// material name, cut off anything in front of the dot (beyond are special flags).
	Materials.Empty();
	for( int32 m=0; m < MaterialsBinary.Num(); m++)
	{			
		const FString& MaterialName = MaterialsBinary[m].MaterialName;

		UMaterialInterface* Material = FindObject<UMaterialInterface>( ANY_PACKAGE, *MaterialName );
		Materials.Add( FSkeletalMaterial( Material, true ) );	// I guess true is a sensible default for shadow casting

		if( !Material )
		{
			UE_LOG(LogSkeletalMeshImport, Log, TEXT(" Mesh material not found among currently loaded ones: %s"), *MaterialName );
		}
	}

	// Pad the material pointers.
	while( MaterialsBinary.Num() > Materials.Num() )
	{
		Materials.Add( FSkeletalMaterial( NULL, true ) );
	}
}
Beispiel #2
0
/**
* Process and fill in the mesh Materials using the raw binary import data
* 
* @param Materials - [out] array of materials to update
* @param ImportData - raw binary import data to process
*/
void ProcessImportMeshMaterials(TArray<FSkeletalMaterial>& Materials, FSkeletalMeshImportData& ImportData )
{
	TArray <VMaterial>&	ImportedMaterials = ImportData.Materials;

	// If direct linkup of materials is requested, try to find them here - to get a texture name from a 
	// material name, cut off anything in front of the dot (beyond are special flags).
	Materials.Empty();
	for( int32 MatIndex=0; MatIndex < ImportedMaterials.Num(); ++MatIndex)
	{			
		const VMaterial& ImportedMaterial = ImportedMaterials[MatIndex];

		UMaterialInterface* Material = NULL;
		if( ImportedMaterial.Material.IsValid() )
		{
			Material = ImportedMaterial.Material.Get();
		}
		else
		{
			const FString& MaterialName = ImportedMaterial.MaterialImportName;
			Material = FindObject<UMaterialInterface>(ANY_PACKAGE, *MaterialName);
		}

		const bool bEnableShadowCasting = true;
		Materials.Add( FSkeletalMaterial( Material, bEnableShadowCasting ) );
	}

	int32 NumMaterialsToAdd = FMath::Max<int32>( ImportedMaterials.Num(), ImportData.MaxMaterialIndex + 1 );

	// Pad the material pointers
	while( NumMaterialsToAdd > Materials.Num() )
	{
		Materials.Add( FSkeletalMaterial( NULL, true ) );
	}
}