Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//.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;
}