x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

UE4外部のアプリケーションに変数の値を渡したい

VRに関する研究を行っている者です。UE4のみでバッファリング等の加工を行うのは諦めて、 UE4とHRTFのリアルタイム畳み込み等の音声周りの制御を行う外部のアプリケーションとを 連携させた仮想空間を作ろうとしております。

UE4内部で、HMDの頭部の位置情報や方向の情報を取得するところまでは blueprintのGet Orientation and Position等でできることは把握しているのですが、

その変数をUE4の外部へ持続的に渡してやるということは現実的に可能なのでしょうか? プラグイン等でも構いませんのでどうかお力添えよろしくお願いいたします。

Product Version: UE 4.19
Tags:
more ▼

asked Jun 04 '18 at 04:13 AM in Japanese

avatar image

masabo07
14 1 1 7

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

TCP通信やUDP通信を用いて外部と更新することは可能です

C++を使えば、そこそこ自由な形で外部と通信できますので、挑戦してみてください

(その他の要件はプロジェクトによります)

more ▼

answered Jun 04 '18 at 04:25 AM

avatar image

T_Sumisaki
3k 24 4 8

(comments are locked)
10|2000 characters needed characters left

投稿主です。だいぶ遅くなってしまいすみません。

現時点では文字列を送るだけですが、おかげで完成に近づきました。 ありがとうございます。

.h

 #pragma once Fill out your
 #include "CoreMinimal.h"
 #include "winsock2.h"
 #include "AllowWindowsPlatformAtomics.h"
 #include "Windows.h"
 #include "HideWindowsPlatformAtomics.h"
 #include "Sockets.h"
 #include "HeadMountedDisplayFunctionLibrary.h"
 #include "Networking.h"
 #include "ws2tcpip.h"
 #include "GameFramework/Actor.h"
 #include "UDPSender_v2.generated.h"
 
 UCLASS()
 class VR1_API AUDPSender_v2 : public AActor
 {
     GENERATED_BODY()
     
 public:    
     // Sets default values for this actor's properties
     AUDPSender_v2();
 protected:
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
     virtual void EndPlay(const EEndPlayReason::Type EndPlayReason);
 public:    
     // Called every frame
     virtual void Tick(float DeltaTime) override;
     
 
     /*終了処理*/
     void Shutdown();
 
     /**
     * ソケットを削除
     */
     void DeleteSocket();
 
 
 private:
     SOCKET sock;
 
     int32 iResult;
     struct sockaddr_in addr;
     FVector DevicePosition;
     FRotator DeviceRotation;
     
 };
 


.cpp

 #include "UDPSender_v2.h"

 AUDPSender_v2::AUDPSender_v2()
 {
     PrimaryActorTick.bCanEverTick = true;
 
 }

 void AUDPSender_v2::BeginPlay()
 {
     Super::BeginPlay();
     WSAData wsaData;
     sock = socket(AF_INET, SOCK_DGRAM, 0);
     WSAStartup(MAKEWORD(2, 0), &wsaData);
     if (iResult != 0) {
         printf("WSAStartup failed: %d\n", iResult);
     }
     
     
     addr.sin_family = AF_INET;
     addr.sin_port = htons(1919);
     addr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
     UE_LOG(LogTemp, Log, TEXT("Init UdpSocket."));
     
 }
 
 // Called every frame
 void AUDPSender_v2::Tick(float DeltaTime)
 {
     Super::Tick(DeltaTime);
     UHeadMountedDisplayFunctionLibrary::GetOrientationAndPosition(DeviceRotation, DevicePosition);
     
 
     sendto(sock, "HELLO", 20, 0, (struct sockaddr *)&addr, sizeof(addr));
 
 }
 
 void AUDPSender_v2::EndPlay(const EEndPlayReason::Type EndPlayReason)
 {
     Super::EndPlay(EndPlayReason);
     
     Shutdown();
 }
 
 void AUDPSender_v2::Shutdown()
 {
     DeleteSocket();
     UE_LOG(LogTemp, Log, TEXT("Shutdown UdpSocket."));
 }
 void AUDPSender_v2::DeleteSocket()
 {
     if (!sock) return;
     /*
     sock->Close();
     delete sock;
     sock = nullptr;
     */
     closesocket(sock);
     WSACleanup();
 }

alt text

udp.png (309.2 kB)
more ▼

answered Aug 20 '18 at 10:39 AM

avatar image

masabo07
14 1 1 7

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question