Hello Everyone.
I’m currently on a student team working on a project where we’re trying to use Samsung Gear VR and a motion capture studio together in order to translate movements in reality to a Virtual Reality. The data from our motion capture is put on a socket server and our unreal client is supposed to connect to it and receive constantly updated coordinates. Our code works perfectly in the editor, but on our Android Phone (Samsung Galaxy S6) it only connects to the server, but doesn’t receive data.
The relevant sections of our code:
SpillerMedSocket.h
FString StringFromBinaryArray(const TArray& BinaryArray);
FVector FindFirstDatapoint(const FString& SData);
private:
FSocket* Socket;
TArray<uint8> ReceivedData;
FVector StartingLocation;
SpillerMedSocket.cpp
// Called every frame
void ASpillerMedSocket::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
{
uint32 PendingDataSize;
if (Socket->HasPendingData(PendingDataSize)) {
ReceivedData.SetNumUninitialized(PendingDataSize);
int32 Read = 0;
Socket->Recv(ReceivedData.GetData(), ReceivedData.Num(), Read);
}
}
{
if (ReceivedData.Num() > 0) {
FString Sdata = StringFromBinaryArray(ReceivedData);
FVector Vec = FindFirstDatapoint(Sdata);
Vec *= Speed;
SetActorLocation(StartingLocation + Vec);
}
}
}
FString ASpillerMedSocket::StringFromBinaryArray(const TArray<uint8>& BinaryArray)
{
//Create a string from a byte array!
std::string cstr(reinterpret_cast<const char*>(BinaryArray.GetData()), BinaryArray.Num());
return FString(cstr.c_str());
}
FVector ASpillerMedSocket::FindFirstDatapoint(const FString& SData) {
FString Chopped = SData.Mid(0, 25);
TArray< FString > OutArray;
Chopped.ParseIntoArrayWS(OutArray);
print(OutArray[0]);
print(OutArray[1]);
float x = FCString::Atof(*(OutArray[0]));
float y = FCString::Atof(*(OutArray[1]));
float z = FCString::Atof(*(OutArray[2]));
return FVector(y, x, z);
}
Could there be a problem with the use of unsigned integers like uint8 and uint32 due to not being supported in Java? If so, how do we fix it? We would really appreciate any help here.