Commit f8f7ba27 by wester

sync

parent 4caa3f1c
No preview for this file type
...@@ -7,4 +7,5 @@ IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, MasterTestProject, "Maste ...@@ -7,4 +7,5 @@ IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, MasterTestProject, "Maste
//General Log //General Log
DEFINE_LOG_CATEGORY(GLTF); DEFINE_LOG_CATEGORY(GLTF);
DEFINE_LOG_CATEGORY(UDP);
DEFINE_LOG_CATEGORY(TILES); DEFINE_LOG_CATEGORY(TILES);
...@@ -6,5 +6,6 @@ ...@@ -6,5 +6,6 @@
//General Log //General Log
DECLARE_LOG_CATEGORY_EXTERN(GLTF, Log, All); DECLARE_LOG_CATEGORY_EXTERN(GLTF, Log, All);
DECLARE_LOG_CATEGORY_EXTERN(UDP, Log, All);
DECLARE_LOG_CATEGORY_EXTERN(TILES, Log, All); DECLARE_LOG_CATEGORY_EXTERN(TILES, Log, All);
...@@ -30,7 +30,6 @@ APointCloudActor::APointCloudActor(const FObjectInitializer& ObjectInitializer) ...@@ -30,7 +30,6 @@ APointCloudActor::APointCloudActor(const FObjectInitializer& ObjectInitializer)
Material = UMaterialInstanceDynamic::Create(TheMaterial, nullptr); Material = UMaterialInstanceDynamic::Create(TheMaterial, nullptr);
StaticMeshComponent->SetMaterial(0, Material); StaticMeshComponent->SetMaterial(0, Material);
} }
} }
...@@ -40,7 +39,8 @@ void APointCloudActor::setPoints(UTexture2D* PointCloud, FVector pos, FVector sc ...@@ -40,7 +39,8 @@ void APointCloudActor::setPoints(UTexture2D* PointCloud, FVector pos, FVector sc
UE_LOG(TILES, Log, TEXT("PointclodActor pos: %s size: %s"), *pos.ToString(), *scale.ToString()); UE_LOG(TILES, Log, TEXT("PointclodActor pos: %s size: %s"), *pos.ToString(), *scale.ToString());
Material->SetTextureParameterValue(FName("PointCloud"), PointCloud); Material->SetTextureParameterValue(FName("PointCloud"), PointCloud);
Material->SetScalarParameterValue(FName("TextureSize"), PointCloud->GetSizeX()); Material->SetScalarParameterValue(FName("TextureSize"), PointCloud->GetSizeX());
Material->SetVectorParameterValue(FName("CloudCenter"), pos); Offset = pos;
Material->SetVectorParameterValue(FName("CloudCenter"), pos+this->GetActorLocation());
Material->SetVectorParameterValue(FName("BoundigBox"), scale); Material->SetVectorParameterValue(FName("BoundigBox"), scale);
Material->SetScalarParameterValue(FName("TextureOffset"), TextureOffset); Material->SetScalarParameterValue(FName("TextureOffset"), TextureOffset);
Points = PointCloud; Points = PointCloud;
......
...@@ -31,12 +31,12 @@ public: ...@@ -31,12 +31,12 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Points") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Points")
UTexture2D* Colors; UTexture2D* Colors;
protected: protected:
// Called when the game starts or when spawned // Called when the game starts or when spawned
virtual void BeginPlay() override; virtual void BeginPlay() override;
public: public:
FVector Offset;
// Called every frame // Called every frame
virtual void Tick(float DeltaTime) override; virtual void Tick(float DeltaTime) override;
......
...@@ -465,6 +465,13 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile) ...@@ -465,6 +465,13 @@ void ATilesetActor::parsePointCloudTile(const TArray<uint8> data, FTile * tile)
PointCloud->SetFolderPath(FName(*("SpawnedGLTF/" + this->GetName()))); PointCloud->SetFolderPath(FName(*("SpawnedGLTF/" + this->GetName())));
#endif #endif
PointCloud->AttachToActor(this, FAttachmentTransformRules::KeepWorldTransform); PointCloud->AttachToActor(this, FAttachmentTransformRules::KeepWorldTransform);
FMatrix leftToRight(FVector(-1, 0, 0), FVector(0, 0, 1), FVector(0, 1, 0), FVector(0, 0, 0));
FMatrix globalTielTransform = /*leftToRight */ *tile->getAbsoluteTransform();
UE_LOG(TILES, Error, TEXT("Pointcloud Transform: %s"), *globalTielTransform.ToString());
//PointCloud->SetActorRelativeTransform(FTransform(globalTielTransform));
if (ColorTexture) if (ColorTexture)
PointCloud->setColors(ColorTexture); PointCloud->setColors(ColorTexture);
} }
......
// Fill out your copyright notice in the Description page of Project Settings.
#include "MasterTestProject.h"
#include "UDPSender.h"
// Sets default values
AUDPSender::AUDPSender()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
SenderSocket = nullptr;
}
bool AUDPSender::SendString(FString ToSend)
{
if (!SenderSocket)
{
UE_LOG(UDP, Error, TEXT("No UDP sender socket"));
return false;
}
//~~~~~~~~~~~~~~~~
int32 BytesSent = 0;
//FAnyCustomData NewData;
//NewData.Scale = FMath::FRandRange(0, 1000);
//NewData.Count = FMath::RandRange(0, 100);
//NewData.Color = FLinearColor(FMath::FRandRange(0, 1), FMath::FRandRange(0, 1), FMath::FRandRange(0, 1), 1);
FArrayWriter Writer;
//Writer << ToSend; // NewData; //Serializing our custom data, thank you UE4!
FTCHARToUTF8 EchoStrUtf8(*ToSend);
int32 DestLen = EchoStrUtf8.Length();
//int SentLen = libwebsocket_write(Wsi, (unsigned char*)(TCHAR_TO_UTF8(*EchoStr)), DestLen, LWS_WRITE_TEXT);
//std::string messageSTDString = TCHAR_TO_UTF8(*Message);
SenderSocket->SendTo((unsigned char*)(TCHAR_TO_UTF8(*ToSend)), DestLen, BytesSent, *RemoteAddr);
if (BytesSent <= 0)
{
UE_LOG(UDP, Error, TEXT("Socket is valid but the receiver received 0 bytes, make sure it is listening properly! DestLen = %d "), DestLen);
return false;
}
//UE_LOG(LogTemp, Log, TEXT("UDP~ Send Succcess! Bytes Sent = %d"), BytesSent);
return true;
}
bool AUDPSender::StartUDPSender(const FString & YourChosenSocketName, const FString & TheIP, const int32 ThePort)
{
//Create Remote Address.
RemoteAddr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
bool bIsValid;
RemoteAddr->SetIp(*TheIP, bIsValid);
RemoteAddr->SetPort(ThePort);
if (!bIsValid)
{
UE_LOG(UDP, Error, TEXT("Rama UDP Sender>> IP address %s was not valid!"), *TheIP);
return false;
}
SenderSocket = FUdpSocketBuilder(*YourChosenSocketName)
.AsReusable()
.WithBroadcast()
;
//check(SenderSocket->GetSocketType() == SOCKTYPE_Datagram);
//Set Send Buffer Size
int32 SendSize = 2 * 1024 * 1024;
SenderSocket->SetSendBufferSize(SendSize, SendSize);
SenderSocket->SetReceiveBufferSize(SendSize, SendSize);
UE_LOG(UDP, Log, TEXT("\n\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"));
UE_LOG(UDP, Log, TEXT("Rama ****UDP**** Sender Initialized Successfully!!!"));
UE_LOG(UDP, Log, TEXT("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\n"));
return true;
}
// Called when the game starts or when spawned
void AUDPSender::BeginPlay()
{
Super::BeginPlay();
}
void AUDPSender::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
Super::EndPlay(EndPlayReason);
//~~~~~~~~~~~~~~~~
if (SenderSocket)
{
SenderSocket->Close();
ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(SenderSocket);
}
}
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Networking.h"
#include "UDPSender.generated.h"
UCLASS()
class MASTERTESTPROJECT_API AUDPSender : public AActor
{
GENERATED_BODY()
bool IsUDP;
public:
// Sets default values for this actor's properties
AUDPSender();
TSharedPtr<FInternetAddr> RemoteAddr;
FSocket* SenderSocket;
UFUNCTION(BlueprintCallable, Category = UDPSender)
bool StartUDPSender(
const FString& YourChosenSocketName,
const FString& TheIP,
const int32 ThePort
);
UFUNCTION(BlueprintCallable, Category = UDPSender)
bool SendString(FString ToSend);
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
/** Called whenever this actor is being removed from a level */
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
};
...@@ -49,10 +49,9 @@ void AVRPawnCode::PublishMessage(FVector start, FVector end, AUDPSender *socket) ...@@ -49,10 +49,9 @@ void AVRPawnCode::PublishMessage(FVector start, FVector end, AUDPSender *socket)
{ {
UMyGameInstance *gameinstance = Cast<UMyGameInstance>(GetGameInstance()); UMyGameInstance *gameinstance = Cast<UMyGameInstance>(GetGameInstance());
//FPlatformTime::Seconds(); //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);
FString Message = FString::Printf(TEXT("{\"timestamp\":%d,\"start\":{\"x\":%f,\"y\":%f,\"z\":%f},\"end\":{\"x\":%f,\"y\":%f,\"z\":%f}}"), 0.0f, start.X, start.Y, start.Z, end.X, end.Y, end.Z);
socket->SendString(Message); socket->SendString(Message);
//UE_LOG(TILES, Warning, TEXT("Published Message %s"), *Message); UE_LOG(UDP, Warning, TEXT("Published Message %s"), *Message);
//gameinstance->connection->publishMessage(TCHAR_TO_UTF8(*Message)); //gameinstance->connection->publishMessage(TCHAR_TO_UTF8(*Message));
} }
......
...@@ -16,6 +16,7 @@ class MASTERTESTPROJECT_API AVRPawnCode : public APawn ...@@ -16,6 +16,7 @@ class MASTERTESTPROJECT_API AVRPawnCode : public APawn
public: public:
// Sets default values for this pawn's properties // Sets default values for this pawn's properties
AVRPawnCode(); AVRPawnCode();
float counter = 0;
protected: protected:
......
netsh wlan set hostednetwork mode=allow ssid=adhocname key=password
netsh wlan start hostednetwork
\ No newline at end of file
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