Add Games File
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
// VRM4U Copyright (c) 2021-2024 Haruyoshi Yamamoto. This software is released under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/ObjectMacros.h"
|
||||
#include "BoneContainer.h"
|
||||
#include "BonePose.h"
|
||||
#include "BoneControllers/AnimNode_ModifyBone.h"
|
||||
#include "Misc/EngineVersionComparison.h"
|
||||
|
||||
#include "AnimNode_VrmVMC.generated.h"
|
||||
|
||||
class USkeletalMeshComponent;
|
||||
class UVrmMetaObject;
|
||||
class UVrmAssetListObject;
|
||||
|
||||
/**
|
||||
* Simple controller that replaces or adds to the translation/rotation of a single bone.
|
||||
*/
|
||||
USTRUCT(BlueprintInternalUseOnly)
|
||||
struct VRM4UCAPTURE_API FAnimNode_VrmVMC : public FAnimNode_SkeletalControlBase
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Skeleton, meta = (PinHiddenByDefault))
|
||||
bool EnableAutoSearchMetaData = true;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Skeleton, meta=(PinHiddenByDefault))
|
||||
const UVrmMetaObject *VrmMetaObject = nullptr;
|
||||
|
||||
#if UE_VERSION_OLDER_THAN(5,0,0)
|
||||
TAssetPtr<UVrmMetaObject> VrmMetaObject_Internal = nullptr;
|
||||
TAssetPtr<UVrmAssetListObject> VrmAssetListObject_Internal = nullptr;
|
||||
#else
|
||||
TSoftObjectPtr<UVrmMetaObject> VrmMetaObject_Internal = nullptr;
|
||||
TSoftObjectPtr<UVrmAssetListObject> VrmAssetListObject_Internal = nullptr;
|
||||
#endif
|
||||
|
||||
//UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Skeleton, meta = (PinShownByDefault))
|
||||
//TMap<FString, FTransform> BoneTrans;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Skeleton, meta = (PinShownByDefault))
|
||||
bool bUseRemoteCenterPos = true;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Skeleton, meta = (PinShownByDefault))
|
||||
float ModelRelativeScale = 1.f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Skeleton, meta = (PinShownByDefault))
|
||||
bool bIgnoreLocalRotation = false;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Skeleton, meta = (PinShownByDefault))
|
||||
FString ServerAddress = "0.0.0.0";
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Skeleton, meta = (PinShownByDefault))
|
||||
int Port = 39539;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Skeleton, meta = (PinShownByDefault))
|
||||
bool bApplyPerfectSync = true;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Skeleton, meta = (PinHiddenByDefault))
|
||||
bool bForceUpdate = false;
|
||||
|
||||
bool bCreateServer = false;
|
||||
|
||||
TArray<FTransform> RefSkeletonTransform_global;
|
||||
|
||||
FAnimNode_VrmVMC();
|
||||
virtual ~FAnimNode_VrmVMC();
|
||||
|
||||
// FAnimNode_Base interface
|
||||
virtual void GatherDebugData(FNodeDebugData& DebugData) override;
|
||||
// End of FAnimNode_Base interface
|
||||
|
||||
// FAnimNode_SkeletalControlBase interface
|
||||
virtual void Initialize_AnyThread(const FAnimationInitializeContext& Context) override;
|
||||
virtual void CacheBones_AnyThread(const FAnimationCacheBonesContext& Context) override;
|
||||
// virtual void Update_AnyThread(const FAnimationUpdateContext& Context) override;
|
||||
virtual void EvaluateSkeletalControl_AnyThread(FComponentSpacePoseContext& Output, TArray<FBoneTransform>& OutBoneTransforms) override;
|
||||
virtual void EvaluateComponentPose_AnyThread(FComponentSpacePoseContext& Output) override;
|
||||
virtual bool IsValidToEvaluate(const USkeleton* Skeleton, const FBoneContainer& RequiredBones) override;
|
||||
|
||||
virtual void UpdateInternal(const FAnimationUpdateContext& Context)override;
|
||||
// End of FAnimNode_SkeletalControlBase interface
|
||||
|
||||
virtual void ConditionalDebugDraw(FPrimitiveDrawInterface* PDI, USkeletalMeshComponent* PreviewSkelMeshComp, bool bPreviewForeground = false) const;
|
||||
|
||||
private:
|
||||
// FAnimNode_SkeletalControlBase interface
|
||||
virtual void InitializeBoneReferences(const FBoneContainer& RequiredBones) override;
|
||||
// End of FAnimNode_SkeletalControlBase interface
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Subsystems/EngineSubsystem.h"
|
||||
#include "Misc/EngineVersionComparison.h"
|
||||
#include "UObject/StrongObjectPtr.h"
|
||||
|
||||
#include "OSCServer.h"
|
||||
#include "VrmVMCObject.h"
|
||||
|
||||
#include "VRM4U_VMCSubsystem.generated.h"
|
||||
|
||||
|
||||
#if UE_VERSION_OLDER_THAN(4,22,0)
|
||||
|
||||
//Couldn't find parent type for 'VRM4U_AnimSubsystem' named 'UEngineSubsystem'
|
||||
#error "please remove VRM4U_AnimSubsystem.h/cpp for <=UE4.21"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
UCLASS()
|
||||
class VRM4UCAPTURE_API UVRM4U_VMCSubsystem : public UEngineSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = VRM4U)
|
||||
bool CreateVMCServer(const FString ServerAddress, int port);
|
||||
|
||||
void ClearData(const FString ServerAddress, int port);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = VRM4U)
|
||||
void DestroyVMCServer(const FString ServerAddress, int port);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = VRM4U)
|
||||
void DestroyVMCServerAll();
|
||||
|
||||
UVrmVMCObject* FindOrAddServer(const FString ServerAddress, int port);
|
||||
|
||||
TArray< TStrongObjectPtr<UVrmVMCObject> > VMCObjectList;
|
||||
|
||||
bool CopyVMCData(FVMCData& DstData, FString ServerAddress, int port);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = VRM4U)
|
||||
bool GetVMCData(TMap<FString, FTransform> &BoneData, TMap<FString, float> &CurveData, FString ServerAddress, int port);
|
||||
|
||||
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
|
||||
private:
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
// VRM4U Copyright (c) 2021-2024 Haruyoshi Yamamoto. This software is released under the MIT License.
|
||||
|
||||
#pragma once
|
||||
#include "Engine/LatentActionManager.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "VrmCaptureManager.generated.h"
|
||||
|
||||
class UVrmMocopiReceiver;
|
||||
|
||||
UCLASS()
|
||||
class VRM4UCAPTURE_API UVrmCaptureManager : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category = "VRM4U")
|
||||
static UVrmMocopiReceiver* CreateVrmMocopiReceiver(FString ReceiveIPAddress, int32 Port, bool bMulticastLoopback, bool bStartListening, FString ServerName, UObject* Outer = nullptr);
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,157 @@
|
||||
// VRM4U Copyright (c) 2021-2024 Haruyoshi Yamamoto. This software is released under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Misc/CoreDelegates.h"
|
||||
#include "UObject/NoExportTypes.h"
|
||||
#include "Interfaces/IPv4/IPv4Address.h"
|
||||
#include "Interfaces/IPv4/IPv4Endpoint.h"
|
||||
#include "Common/UdpSocketReceiver.h"
|
||||
#include "Sockets.h"
|
||||
#include "Common/UdpSocketBuilder.h"
|
||||
#include "Misc/EngineVersionComparison.h"
|
||||
#include "Tickable.h"
|
||||
|
||||
|
||||
#if UE_VERSION_OLDER_THAN(4,26,0)
|
||||
#else
|
||||
#include "Containers/RingBuffer.h"
|
||||
#endif
|
||||
|
||||
#include "VrmMocopiReceiver.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
enum MocopiData{
|
||||
BoneNum = 27,
|
||||
};
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FStructMocopiData{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRM4U")
|
||||
int FrameNo = 0;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRM4U")
|
||||
int Time = 0;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, EditFixedSize, Category = "VRM4U")
|
||||
TArray<FTransform> MocopiTransformWorld;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, EditFixedSize, Category = "VRM4U")
|
||||
TArray<FTransform> MocopiTransformLocal;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, EditFixedSize, Category = "VRM4U")
|
||||
TArray<FTransform> VrmTransformLocal;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRM4U")
|
||||
TMap<FString, FTransform> VrmTransformBoneList;
|
||||
|
||||
FStructMocopiData() {
|
||||
MocopiTransformWorld.SetNum(MocopiData::BoneNum);
|
||||
MocopiTransformLocal.SetNum(MocopiData::BoneNum);
|
||||
VrmTransformLocal.SetNum(MocopiData::BoneNum);
|
||||
}
|
||||
};
|
||||
|
||||
class VRM4UCAPTURE_API FMocopiReceiverProxy : public FTickableGameObject
|
||||
{
|
||||
UVrmMocopiReceiver* Receiver;
|
||||
FSocket* Socket = nullptr;
|
||||
FUdpSocketReceiver* SocketReceiver = nullptr;
|
||||
|
||||
FIPv4Address ReceiveIPAddress;
|
||||
int32 Port = 8888;
|
||||
|
||||
TArray<uint8> RecvDataSet;
|
||||
|
||||
public:
|
||||
FMocopiReceiverProxy(UVrmMocopiReceiver *InReceiver);
|
||||
//FMocopiReceiverProxy(UVrmMocopiReceiver& InServer);
|
||||
virtual ~FMocopiReceiverProxy();
|
||||
|
||||
#if WITH_EDITOR
|
||||
virtual bool IsTickableInEditor() const override {
|
||||
return true;
|
||||
}
|
||||
#endif // WITH_EDITOR
|
||||
|
||||
void Listen();
|
||||
|
||||
void Stop();
|
||||
|
||||
bool SetAddress(const FString& ReceiveIPAddress, int32 Port);
|
||||
|
||||
virtual void Tick(float InDeltaTime) override;
|
||||
virtual TStatId GetStatId() const override;
|
||||
|
||||
void OnPacketReceived(const FArrayReaderPtr& InData, const FIPv4Endpoint& InEndpoint);
|
||||
};
|
||||
|
||||
|
||||
UCLASS(BlueprintType)
|
||||
class VRM4UCAPTURE_API UVrmMocopiReceiver : public UObject
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
int BufferNum = 10;
|
||||
int currentFrameNo = 0;
|
||||
int currentTime = 0;
|
||||
|
||||
mutable FCriticalSection BufferCS;
|
||||
|
||||
TUniquePtr<FMocopiReceiverProxy> ReceiverProxy;
|
||||
|
||||
#if UE_VERSION_OLDER_THAN(4,26,0)
|
||||
TArray<FStructMocopiData> MocopiReceiveBuffer;
|
||||
#else
|
||||
TRingBuffer<FStructMocopiData> MocopiReceiveBuffer;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "VRM4U")
|
||||
void Listen();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "VRM4U")
|
||||
void Stop();
|
||||
|
||||
void OnPacketReceived(const FArrayReaderPtr& InData, const FIPv4Endpoint& InEndpoint);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "VRM4U")
|
||||
bool SetAddress(const FString& ReceiveIPAddress, int32 Port);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "VRM4U")
|
||||
void SetBufferNum(int32 Num = 10);
|
||||
|
||||
void OnPacketReceived(FStructMocopiData data);
|
||||
|
||||
void PacketBroadcast();
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FVrmMocopiReceiverDelegate, FStructMocopiData, data);
|
||||
|
||||
UPROPERTY(BlueprintAssignable, Category = "VRM4U")
|
||||
FVrmMocopiReceiverDelegate OnReceived;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "VRM4U")
|
||||
void GetNextFrameData(FStructMocopiData &data, bool &bEnable, bool &bUpdate);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "VRM4U")
|
||||
void GetLatestFrameData(FStructMocopiData &data, bool &bEnable, bool &bUpdate);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "VRM4U")
|
||||
void GetCurrentTime(int& FrameNo, int& Time) {
|
||||
FrameNo = currentFrameNo;
|
||||
Time = currentTime;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void BeginDestroy() override;
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Misc/EngineVersionComparison.h"
|
||||
#include "UObject/StrongObjectPtr.h"
|
||||
#include "OSCServer.h" // for game build link error
|
||||
|
||||
#include "VrmVMCObject.generated.h"
|
||||
|
||||
struct FOSCMessage;
|
||||
|
||||
struct FVMCData {
|
||||
FString ServerAddress = "";
|
||||
int Port = 0;
|
||||
|
||||
TMap<FString, FTransform> BoneData;
|
||||
TMap<FString, float> CurveData;
|
||||
|
||||
void ClearData() {
|
||||
BoneData.Empty();
|
||||
CurveData.Empty();
|
||||
}
|
||||
|
||||
bool operator==(const FVMCData& Other) const {
|
||||
if (Port != Other.Port) return false;
|
||||
if (ServerAddress != Other.ServerAddress) return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
UCLASS()
|
||||
class VRM4UCAPTURE_API UVrmVMCObject : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
FCriticalSection cs;
|
||||
|
||||
TStrongObjectPtr<UOSCServer> OSCServer;
|
||||
|
||||
FVMCData VMCData;
|
||||
FVMCData VMCData_Cache;
|
||||
|
||||
bool bDataUpdated = false;
|
||||
public:
|
||||
|
||||
|
||||
FString ServerName;
|
||||
uint16 port;
|
||||
|
||||
bool bForceUpdate = false;
|
||||
|
||||
void CreateServer(FString name, uint16 port);
|
||||
void DestroyServer();
|
||||
void OSCReceivedMessageEvent(const FOSCMessage& Message, const FString& IPAddress, uint16 Port);
|
||||
|
||||
bool CopyVMCData(FVMCData& dst);
|
||||
void ClearVMCData();
|
||||
};
|
||||
Reference in New Issue
Block a user