67 lines
2.3 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AI/PickAndPlaceManager.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "LuckyWorldFunctions.generated.h"
/**
*
*/
UCLASS()
class LUCKYMUJOCO_API ULuckyWorldFunctions : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
/**
* Get the pick and place manager.
* @param WorldContextObject - The world context owner.
* @return - The first pick and place manager.
*/
UFUNCTION(BlueprintCallable,Category = "LuckyWorld|PickAndPlace", meta = (WorldContext = "WorldContextObject"))
static APickAndPlaceManager* GetPickAndPlaceManager(UObject* WorldContextObject);
/**
* Save a render target (texture target from scene capture component 2D) to disk.
* @param RenderTarget - The render target to save to disk.
* @param Filename - The path for the file.
* @param bAsPNG - If true, we write as a png.
* @param bFlipVertically - If true, we will flip the pixels.
* @return - True if saved.
*/
UFUNCTION(BlueprintCallable,Category = "LuckyWorld|Utils|Images")
static bool SaveRenderTargetToDisk(UTextureRenderTarget2D* RenderTarget, const FString& Filename, bool bAsPNG = true, bool bFlipVertically = false);
/**
* Save a texture to disk.
* @param Texture - The texure to save to disk.
* @param Filename - The path for the file.
* @param bAsPNG - If true, we write as a png.
* @param bFlipVertically - If true, we will flip the pixels.
* @return - True if saved.
*/
UFUNCTION(BlueprintCallable,Category = "LuckyWorld|Utils|Images")
static bool SaveTextureToDisk(UTexture2D* Texture, const FString& Filename, bool bAsPNG = true, bool bFlipVertically = true);
/**
* Convert a TMap<FString,FString> to a json struct.
* @param InMap - The Map to convert to a string.
* @return - The JSON string.
*/
UFUNCTION(BlueprintPure,Category = "LuckyWorld|Utils", meta = (BlueprintAutocast, CompactNodeTitle = "->"))
static FString ConvertMapToJsonString(const TMap<FString, FString>& InMap);
/**
* Convert a FVector to a json struct.
* @param Vector - The Vector to convert to a string.
* @return - The JSON string.
*/
UFUNCTION(BlueprintPure,Category = "LuckyWorld|Utils", meta = (BlueprintAutocast, CompactNodeTitle = "->"))
static FString FVectorToJsonString(const FVector& Vector);
};