diff --git a/Source/HoudiniEngineRuntime/Private/HoudiniAssetBlueprintComponent.cpp b/Source/HoudiniEngineRuntime/Private/HoudiniAssetBlueprintComponent.cpp index 6034c81898..dd23df4d28 100755 --- a/Source/HoudiniEngineRuntime/Private/HoudiniAssetBlueprintComponent.cpp +++ b/Source/HoudiniEngineRuntime/Private/HoudiniAssetBlueprintComponent.cpp @@ -36,8 +36,12 @@ #include "UObject/Object.h" #include "Logging/LogMacros.h" +#include "HoudiniParameterInt.h" #include "HoudiniParameterFloat.h" +#include "HoudiniParameterString.h" +#include "HoudiniParameterColor.h" #include "HoudiniParameterToggle.h" +#include "HoudiniParameterFile.h" #include "HoudiniInput.h" #if WITH_EDITOR @@ -1940,12 +1944,111 @@ UHoudiniAssetBlueprintComponent::HasParameter(FString Name) return FindParameterByName(Name) != nullptr; } +int +UHoudiniAssetBlueprintComponent::GetIntParameter(FString Name, int Index) +{ + UHoudiniParameterInt* Parameter = Cast(FindParameterByName(Name)); + if (!Parameter) + { + UE_LOG(LogTemp, Warning, TEXT("Int parameter %s doesn't exist at index %s"), *Name, *FString::FromInt(Index)); + return 0; + } + + int Value; + Parameter->GetValueAt(Index, Value); + + return Value; +} + +void +UHoudiniAssetBlueprintComponent::SetIntParameter(FString Name, int Value, int Index) +{ + SetTypedValueAt(Name, Value, Index); +} + +float +UHoudiniAssetBlueprintComponent::GetFloatParameter(FString Name, int Index) +{ + UHoudiniParameterFloat* Parameter = Cast(FindParameterByName(Name)); + if (!Parameter) + { + UE_LOG(LogTemp, Warning, TEXT("Float parameter %s doesn't exist at index %s"), *Name, *FString::FromInt(Index)); + return 0.f; + } + + float Value; + Parameter->GetValueAt(Index, Value); + + return Value; +} + void UHoudiniAssetBlueprintComponent::SetFloatParameter(FString Name, float Value, int Index) { SetTypedValueAt(Name, Value, Index); } +FString +UHoudiniAssetBlueprintComponent::GetStringParameter(FString Name, int Index) +{ + UHoudiniParameterString* Parameter = Cast(FindParameterByName(Name)); + if (!Parameter) + { + UE_LOG(LogTemp, Warning, TEXT("String parameter %s doesn't exist at index %s"), *Name, *FString::FromInt(Index)); + return TEXT(""); + } + + FString Value = Parameter->GetValueAt(Index); + + return Value; +} + +void +UHoudiniAssetBlueprintComponent::SetStringParameter(FString Name, FString Value, int Index) +{ + SetTypedValueAt(Name, Value, Index); +} +// +FLinearColor +UHoudiniAssetBlueprintComponent::GetColorParameter(FString Name) +{ + UHoudiniParameterColor* Parameter = Cast(FindParameterByName(Name)); + if (!Parameter) + { + UE_LOG(LogTemp, Warning, TEXT("Color parameter %s doesn't exist."), *Name); + return FLinearColor::Black; + } + + FLinearColor Value = Parameter->GetColorValue(); + + return Value; +} + +void +UHoudiniAssetBlueprintComponent::SetColorParameter(FString Name, FLinearColor Value) +{ + UHoudiniParameterColor* Parameter = Cast(FindParameterByName(Name)); + if (!Parameter) + return; + + Parameter->SetColorValue(Value); +} + +bool +UHoudiniAssetBlueprintComponent::GetToggleParameter(FString Name, int Index) +{ + UHoudiniParameterToggle* Parameter = Cast(FindParameterByName(Name)); + if (!Parameter) + { + UE_LOG(LogTemp, Warning, TEXT("Toggle parameter %s doesn't exist at index %s"), *Name, *FString::FromInt(Index)); + return false; + } + + bool Value = Parameter->GetValueAt(Index); + + return Value; +} + void UHoudiniAssetBlueprintComponent::SetToggleValueAt(FString Name, bool Value, int Index) { @@ -1956,6 +2059,27 @@ UHoudiniAssetBlueprintComponent::SetToggleValueAt(FString Name, bool Value, int Parameter->SetValueAt(Value, Index); } +FString +UHoudiniAssetBlueprintComponent::GetFileParameter(FString Name, int Index) +{ + UHoudiniParameterFile* Parameter = Cast(FindParameterByName(Name)); + if (!Parameter) + { + UE_LOG(LogTemp, Warning, TEXT("File parameter %s doesn't exist at index %s"), *Name, *FString::FromInt(Index)); + return ""; + } + + FString Value = Parameter->GetValueAt(Index); + + return Value; +} + +void +UHoudiniAssetBlueprintComponent::SetFileParameter(FString Name, FString Value, int Index) +{ + SetTypedValueAt(Name, Value, Index); +} + //void UHoudiniAssetBlueprintComponent::OnPostCookHandler(UHoudiniAssetComponent* InComponent) //{ // diff --git a/Source/HoudiniEngineRuntime/Private/HoudiniAssetBlueprintComponent.h b/Source/HoudiniEngineRuntime/Private/HoudiniAssetBlueprintComponent.h index 3c23886e50..56a548568e 100755 --- a/Source/HoudiniEngineRuntime/Private/HoudiniAssetBlueprintComponent.h +++ b/Source/HoudiniEngineRuntime/Private/HoudiniAssetBlueprintComponent.h @@ -160,12 +160,42 @@ class HOUDINIENGINERUNTIME_API UHoudiniAssetBlueprintComponent : public UHoudini UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") bool HasParameter(FString Name); + UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") + int GetIntParameter(FString Name, int Index=0); + + UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") + void SetIntParameter(FString Name, int Value, int Index=0); + + UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") + float GetFloatParameter(FString Name, int Index=0); + UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") void SetFloatParameter(FString Name, float Value, int Index=0); + + UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") + FString GetStringParameter(FString Name, int Index=0); + + UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") + void SetStringParameter(FString Name, FString Value, int Index=0); + + UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") + FLinearColor GetColorParameter(FString Name); + + UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") + void SetColorParameter(FString Name, FLinearColor Value); + + UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") + bool GetToggleParameter(FString Name, int Index=0); UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") void SetToggleValueAt(FString Name, bool Value, int Index=0); + UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") + FString GetFileParameter(FString Name, int Index=0); + + UFUNCTION(BlueprintCallable, Category="Houdini Asset Component") + void SetFileParameter(FString Name, FString Value, int Index=0); + void AddInputObjectMapping(const FGuid& InputGuid, const FGuid& SCSVariableGuid) { CachedInputNodes.Add(InputGuid, SCSVariableGuid); } bool GetInputObjectSCSVariableGuid(const FGuid& InputGuid, FGuid& OutSCSGuid); void RemoveInputObjectSCSVariableGuid(const FGuid& InputGuid) { CachedInputNodes.Remove(InputGuid); };