Skip to content
Snippets Groups Projects
Commit be8492e7 authored by Neil Smith's avatar Neil Smith
Browse files

tutorial

parent 65cbd241
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -3,70 +3,7 @@
#include "OffAxisBlueprintFunctionLibrary.h"
#include "EngineUtils.h"
int32 UOffAxisBlueprintFunctionLibrary::LoadScreenId()
{
int32 id = -1;
FString result;
FString filename = FPaths::ProjectSavedDir() + "/screenid.txt";
GEngine->AddOnScreenDebugMessage(-1, 30.0f, FColor::Green, filename);
if (FFileHelper::LoadFileToString(result, *filename))
{
id = (FCString::Atoi(*result));
}
return id;
}
TArray<FScreenData> UOffAxisBlueprintFunctionLibrary::LoadConfig(FString filename)
{
TArray<FScreenData> screenData;
FString result;
filename = FPaths::ProjectSavedDir() + "/" + filename;
GEngine->AddOnScreenDebugMessage(-1, 30.0f, FColor::Green, filename);
if (FFileHelper::LoadFileToString(result, *filename))
{
TArray<FString> stringData;
FString comma = "\n";
int32 num = 0;
num = result.ParseIntoArray(stringData, *comma);
for (int i = 1; i < stringData.Num(); i++)
{
comma = " ";
TArray<FString> lineData;
num = stringData[i].ParseIntoArray(lineData, *comma);
FScreenData item;
item.id = (FCString::Atoi(*lineData[0]));
item.name = lineData[1];
double x = (FCString::Atod(*lineData[2]));
double y = (FCString::Atod(*lineData[3]));
double z = (FCString::Atod(*lineData[4]));
item.center = FVector(x, y, z);
float rx = (FCString::Atof(*lineData[5]));
float ry = (FCString::Atof(*lineData[6]));
float rz = (FCString::Atof(*lineData[7]));
float px = (FCString::Atof(*lineData[8]));
float py = (FCString::Atof(*lineData[9]));
item.rot = FRotator(rx, ry, rz);
item.width = (FCString::Atof(*lineData[10]));
item.height = (FCString::Atof(*lineData[11]));
screenData.Add(item);
}
}
return screenData;
}
......
......@@ -13,38 +13,13 @@
*
*/
USTRUCT(BlueprintType)
struct FScreenData
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
int32 id;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
FString name;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
FVector center;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
FRotator rot;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
FVector2D resolution;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
float width;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
float height;
};
UCLASS()
class OFFAXISPROJECTION_API UOffAxisBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Load Id", Keywords = "OffAxisProjection"), Category = "OffAxisProjection")
static int32 LoadScreenId();
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Load Config", Keywords = "OffAxisProjection"), Category = "OffAxisProjection")
static TArray<FScreenData> LoadConfig(FString filename);
};
//.h
USTRUCT(BlueprintType)
struct FScreenData
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
int32 id;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
FString name;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
FVector center;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
FRotator rot;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
FVector2D resolution;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
float width;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OffAxisProjection")
float height;
};
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Load Id", Keywords = "OffAxisProjection"), Category = "OffAxisProjection")
static int32 LoadScreenId();
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Load Config", Keywords = "OffAxisProjection"), Category = "OffAxisProjection")
static TArray<FScreenData> LoadConfig(FString filename);
//.cpp
int32 UOffAxisBlueprintFunctionLibrary::LoadScreenId()
{
int32 id = -1;
FString result;
FString filename = FPaths::ProjectSavedDir() + "/screenid.txt";
GEngine->AddOnScreenDebugMessage(-1, 30.0f, FColor::Green, filename);
if (FFileHelper::LoadFileToString(result, *filename))
{
id = (FCString::Atoi(*result));
}
return id;
}
TArray<FScreenData> UOffAxisBlueprintFunctionLibrary::LoadConfig(FString filename)
{
TArray<FScreenData> screenData;
FString result;
filename = FPaths::ProjectSavedDir() + "/" + filename;
GEngine->AddOnScreenDebugMessage(-1, 30.0f, FColor::Green, filename);
if (FFileHelper::LoadFileToString(result, *filename))
{
TArray<FString> stringData;
FString comma = "\n";
int32 num = 0;
num = result.ParseIntoArray(stringData, *comma);
for (int i = 1; i < stringData.Num(); i++)
{
comma = " ";
TArray<FString> lineData;
num = stringData[i].ParseIntoArray(lineData, *comma);
FScreenData item;
item.id = (FCString::Atoi(*lineData[0]));
item.name = lineData[1];
double x = (FCString::Atod(*lineData[2]));
double y = (FCString::Atod(*lineData[3]));
double z = (FCString::Atod(*lineData[4]));
item.center = FVector(x, y, z);
float rx = (FCString::Atof(*lineData[5]));
float ry = (FCString::Atof(*lineData[6]));
float rz = (FCString::Atof(*lineData[7]));
float px = (FCString::Atof(*lineData[8]));
float py = (FCString::Atof(*lineData[9]));
item.rot = FRotator(rx, ry, rz);
item.width = (FCString::Atof(*lineData[10]));
item.height = (FCString::Atof(*lineData[11]));
screenData.Add(item);
}
}
return screenData;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment