@@ -2801,36 +2801,49 @@ FHoudiniInputTranslator::HapiCreateInputNodeForActorReference(
2801
2801
// Material Reference String Array Attribute
2802
2802
if (InInputSettings.bImportAsReferenceMaterialEnabled )
2803
2803
{
2804
- /*
2805
-
2806
- // TODO
2807
-
2808
2804
// Create point attribute info.
2809
2805
HAPI_AttributeInfo AttributeInfoPoint;
2810
2806
FHoudiniApi::AttributeInfo_Init (&AttributeInfoPoint);
2811
- AttributeInfoPoint.count = 1 ;
2807
+ AttributeInfoPoint.count = NumPoints ;
2812
2808
AttributeInfoPoint.tupleSize = 1 ;
2813
2809
AttributeInfoPoint.exists = true ;
2814
2810
AttributeInfoPoint.owner = HAPI_ATTROWNER_POINT;
2815
2811
AttributeInfoPoint.storage = HAPI_STORAGETYPE_STRING;
2816
2812
AttributeInfoPoint.originalOwner = HAPI_ATTROWNER_INVALID;
2817
2813
2814
+ int32 MaxNumMaterials = 0 ;
2815
+ for (int32 CompIdx = 0 ; CompIdx < ComponentMaterials.Num (); CompIdx++)
2816
+ {
2817
+ if (ComponentMaterials[CompIdx].Num () > MaxNumMaterials)
2818
+ MaxNumMaterials = ComponentMaterials[CompIdx].Num ();
2819
+ }
2820
+
2818
2821
// We set it to be multiple string attributes rather than a single string array attribute to not conflict
2819
2822
// with any existing HDA's that use the attribute name unreal_material
2820
- for (int i = 0; i < MaterialReferences.Num(); ++i )
2823
+ for (int32 MatIdx = 0 ; MatIdx < MaxNumMaterials; MatIdx++ )
2821
2824
{
2822
2825
FString AttributeName = HAPI_UNREAL_ATTRIB_MATERIAL;
2823
- if (i > 0)
2824
- AttributeName.AppendInt(i);
2826
+ if (MatIdx > 0 )
2827
+ AttributeName.AppendInt (MatIdx);
2828
+
2829
+ // Create an array for the current Material
2830
+ TArray<FString> CurrentMaterials;
2831
+ CurrentMaterials.SetNum (ComponentMaterials.Num ());
2832
+ for (int32 CompIdx = 0 ; CompIdx < ComponentMaterials.Num (); CompIdx++)
2833
+ {
2834
+ if (ComponentMaterials[CompIdx].IsValidIndex (MatIdx))
2835
+ CurrentMaterials[CompIdx] = ComponentMaterials[CompIdx][MatIdx];
2836
+ else
2837
+ CurrentMaterials[CompIdx] = FString ();
2838
+ }
2825
2839
2826
2840
HOUDINI_CHECK_ERROR_RETURN (FHoudiniApi::AddAttribute (
2827
2841
FHoudiniEngine::Get ().GetSession (), NewNodeId, 0 ,
2828
2842
TCHAR_TO_ANSI (*AttributeName), &AttributeInfoPoint), false );
2829
2843
2830
- FHoudiniHapiAccessor Accessor(NewNodeId, 0, TCHAR_TO_ANSI(*AttributeName));
2831
- HOUDINI_CHECK_RETURN(Accessor.SetAttributeUniqueData(AttributeInfoPoint, MaterialReferences[i] ), false);
2844
+ HOUDINI_CHECK_RETURN ( FHoudiniEngineUtils::HapiSetAttributeStringData (
2845
+ CurrentMaterials, NewNodeId, 0 , AttributeName, AttributeInfoPoint ), false );
2832
2846
}
2833
- */
2834
2847
}
2835
2848
2836
2849
// Unreal Reference String Attribute
0 commit comments