Commit 5ac3281f by wester

test

parent 3d6c86e1
No preview for this file type
......@@ -10,7 +10,9 @@
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine",
"CoreUObject"
"CoreUObject",
"UMGEditor",
"UMG"
]
}
]
......
// Fill out your copyright notice in the Description page of Project Settings.
#include "MasterTestProject.h"
#include "ImageWidget.h"
TArray<UTexture2D*> UImageWidget::DynamicLoadContentFromPath(FString PathFromContentFolder /*= "Audio/Music"*/, bool LoadFromSubfolders)
{
TArray<UTexture2D*> Array;
UClass* AssetClass = UTexture::StaticClass();
FString RootFolderFullPath = FPaths::ConvertRelativePathToFull(FPaths::GameDir()) + "Content/" + PathFromContentFolder + "/";
UE_LOG(TILES, Error, TEXT("RootFolderPath = \"%s\""), *RootFolderFullPath);
//FPaths::NormalizeDirectoryName(RootFolderFullPath);
//Print("Normalized RootFolderPath = " + RootFolderFullPath);
IFileManager& FileManager = IFileManager::Get();
TArray<FString> Files;
FString Ext;
if (LoadFromSubfolders)
{
if (!Ext.Contains(TEXT("*")))
{
if (Ext == "")
{
Ext = "*.*";
}
else
{
Ext = (Ext.Left(1) == ".") ? "*" + Ext : "*." + Ext;
}
}
FileManager.FindFilesRecursive(Files, *RootFolderFullPath, *Ext, true, false);
}
else
{
if (!Ext.Contains(TEXT("*")))
{
if (Ext == "")
{
Ext = "*.*";
}
else
{
Ext = (Ext.Left(1) == ".") ? "*" + Ext : "*." + Ext;
}
}
FileManager.FindFiles(Files, *(RootFolderFullPath + Ext), true, false);
}
for (int32 i = 0; i < Files.Num(); i++)
{
FString Path;
if (LoadFromSubfolders)
{
int32 LastForwardSlash = Files[i].Find("/", ESearchCase::IgnoreCase, ESearchDir::FromEnd);
FString File = Files[i].RightChop(LastForwardSlash + 1);
FString Folder = Files[i].RightChop(Files[i].Find(PathFromContentFolder, ESearchCase::CaseSensitive, ESearchDir::FromEnd) + PathFromContentFolder.Len());
Folder = Folder.LeftChop(File.Len() + 1);
File = File.Left(File.Find(".", ESearchCase::IgnoreCase, ESearchDir::FromEnd));
Path = AssetClass->GetFName().ToString() + "'/Game/" + PathFromContentFolder + Folder + "/" + File + "." + File + "'";
}
else
{
Path = AssetClass->GetFName().ToString() + "'/Game/" + PathFromContentFolder + "/" + Files[i].LeftChop(7) + "." + Files[i].LeftChop(7) + "'";
}
UE_LOG(TILES, Error, TEXT("Path = \"%s\""), *Path);
UTexture2D* LoadedObj = Cast<UTexture2D>(StaticLoadObject(AssetClass, NULL, *Path));
Array.Add(LoadedObj);
}
for (int32 i = 0; i < Array.Num(); i++)
{
if (Array.Num() > 0 && Array[i] != nullptr)
{
UE_LOG(TILES, Error, TEXT("File = \"%s\""), *Array[i]->GetFName().ToString());
}
else
{
UE_LOG(TILES, Error, TEXT("Array is empty"), *Array[i]->GetFName().ToString());
}
}
return Array;
}
\ No newline at end of file
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "ImageWidget.generated.h"
/**
*
*/
UCLASS()
class MASTERTESTPROJECT_API UImageWidget : public UUserWidget
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "Sweet|Utilities")
static TArray<UTexture2D*> DynamicLoadContentFromPath(FString PathFromContentFolder = "Audio/Music", bool LoadFromSubfolders = false);
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "MasterTestProject.h"
#include "ImageWidgetCpp.h"
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "ImageWidgetCpp.generated.h"
/**
*
*/
UCLASS()
class MASTERTESTPROJECT_API UImageWidgetCpp : public UUserWidget
{
GENERATED_BODY()
};
......@@ -28,10 +28,16 @@ void ATilesetActor::BeginPlay()
//rootTileset = new FTileContent();
rootTileset.url = relativeURL;
UE_LOG(TILES, Error, TEXT("Tileset load %s: \"%s\" \"%s\""), GetWorld()->IsServer() ? TEXT("Server") : TEXT("Client") , *host, *relativeURL);
//UE_LOG(TILES, Error, TEXT("Tileset load : %s %s"), *relativeURL, *host);
UTileDownloader *downloader = NewObject<UTileDownloader>(UTileDownloader::StaticClass());
downloader->GetTileContent(this, &rootTileset, host);
if (loadTileset) {
UE_LOG(TILES, Error, TEXT("Tileset load %s: \"%s\" \"%s\""), GetWorld()->IsServer() ? TEXT("Server") : TEXT("Client"), *host, *relativeURL);
//UE_LOG(TILES, Error, TEXT("Tileset load : %s %s"), *relativeURL, *host);
UTileDownloader *downloader = NewObject<UTileDownloader>(UTileDownloader::StaticClass());
downloader->GetTileContent(this, &rootTileset, host);
}
else {
UE_LOG(TILES, Error, TEXT("Tileset skiped %s: \"%s\" \"%s\""), GetWorld()->IsServer() ? TEXT("Server") : TEXT("Client"), *host, *relativeURL);
}
}
......
......@@ -347,6 +347,11 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Generation")
FString relativeURL;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Generation")
bool loadTileset = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LOD")
float LODtreshold = 0.1;
......
......@@ -22,9 +22,6 @@ void AVRPawnCode::BeginPlay()
{
Super::BeginPlay();
UMyGameInstance *gameinstance = Cast<UMyGameInstance>(GetGameInstance());
char const *messagebody = "{\"timestamp\":15.600000381469727,\"start\":{\"x\":0.0,\"y\":0.0,\"z\":0.0},\"end\":{\"x\":1.0,\"y\":5.0,\"z\":16.0}}";
}
......@@ -44,7 +41,6 @@ void AVRPawnCode::SetupPlayerInputComponent(UInputComponent* PlayerInputComponen
void AVRPawnCode::PublishMessage(FVector start, FVector end, AUDPSender *socket)
{
UMyGameInstance *gameinstance = Cast<UMyGameInstance>(GetGameInstance());
//FPlatformTime::Seconds();
FString Message = FString::Printf(TEXT("{\"timestamp\":%f,\"start\":{\"x\":%f,\"y\":%f,\"z\":%f},\"end\":{\"x\":%f,\"y\":%f,\"z\":%f}}"), counter++, start.Y / 100.0f, start.Z / 100.0f, start.X/100.0f, end.Y / 100.0f, end.Z / 100.0f, end.X / 100.0f);
socket->SendString(Message);
......
// Fill out your copyright notice in the Description page of Project Settings.
#include "MasterTestProject.h"
#include "MyGameInstance.h"
#include "PointCloudActor.h"
#include "VRPawnCode.h"
// Sets default values
AVRPawnCode::AVRPawnCode()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AVRPawnCode::BeginPlay()
{
Super::BeginPlay();
UMyGameInstance *gameinstance = Cast<UMyGameInstance>(GetGameInstance());
if (gameinstance != nullptr && !gameinstance->connection) {
gameinstance->connection = NewObject<URabbitMQConnection>();
}
char const *messagebody = "{\"timestamp\":15.600000381469727,\"start\":{\"x\":0.0,\"y\":0.0,\"z\":0.0},\"end\":{\"x\":1.0,\"y\":5.0,\"z\":16.0}}";
}
// Called every frame
void AVRPawnCode::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AVRPawnCode::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
void AVRPawnCode::PublishMessage(FVector start, FVector end, AUDPSender *socket)
{
UMyGameInstance *gameinstance = Cast<UMyGameInstance>(GetGameInstance());
//FPlatformTime::Seconds();
FString Message = FString::Printf(TEXT("{\"timestamp\":%f,\"start\":{\"x\":%f,\"y\":%f,\"z\":%f},\"end\":{\"x\":%f,\"y\":%f,\"z\":%f}}"), counter++, start.Y / 100.0f, start.Z / 100.0f, start.X/100.0f, end.Y / 100.0f, end.Z / 100.0f, end.X / 100.0f);
socket->SendString(Message);
//UE_LOG(UDP, Warning, TEXT("Published Message %s"), *Message);
//gameinstance->connection->publishMessage(TCHAR_TO_UTF8(*Message));
}
void AVRPawnCode::setPoincloudPosition(FVector position, float angle)
{
if (!PointCloudMaterials) {
TArray<AActor*> FoundActors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), APointCloudActor::StaticClass(), FoundActors);
APointCloudActor* actor;
for (int i = 0; i < FoundActors.Num(); i++) {
actor = (APointCloudActor*) FoundActors[i];
PointCloudMaterials = actor->Material;
}
}
if (PointCloudMaterials) {
PointCloudMaterials->SetVectorParameterValue(FName("TrackerPos"), position);
PointCloudMaterials->SetScalarParameterValue(FName("TrackerZRotation"), angle);
UE_LOG(TILES, Warning, TEXT("Setting %s Pos %s Angle %f"), *position.ToString(), *PointCloudMaterials->GetName(), angle);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment