Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Visual Studio 2015 user specific files
.vs/

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
*.ipa

# These project files can be generated by the engine
*.xcodeproj
*.xcworkspace
*.sln
*.suo
*.opensdf
*.sdf
*.VC.db
*.VC.opendb

# Precompiled Assets
SourceArt/**/*.png
SourceArt/**/*.tga

# Binary Files
Binaries/*
Plugins/*/Binaries/*

# Builds
Build/*

# Whitelist PakBlacklist-<BuildConfiguration>.txt files
!Build/*/
Build/*/**
!Build/*/PakBlacklist*.txt

# Don't ignore icon files in Build
!Build/**/*.ico

# Built data for maps
*_BuiltData.uasset

# Configuration files generated by the Editor
Saved/*

# Compiled source files for the engine to use
Intermediate/*
Plugins/*/Intermediate/*

# Cache files for the editor to use
DerivedDataCache/*
5 changes: 2 additions & 3 deletions DTrackPlugin.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@
"DocsURL": "https://github.com/ar-tracking/UnrealDTrackPlugin",
"MarketplaceURL": "",
"SupportURL": "https://ar-tracking.com/",
"EngineVersion": "4.25.0",
"CanContainContent": false,
"Installed" : true,
"Modules": [
{
"Name": "DTrackPlugin",
"Type": "Runtime",
"WhitelistPlatforms": [ "Win64" ]
"WhitelistPlatforms": [ "Win64" , "Linux" ]
},
{
"Name": "DTrackInput",
"Type": "Runtime",
"WhitelistPlatforms": [ "Win64" ]
"WhitelistPlatforms": [ "Win64" , "Linux" ]
}
],
"Plugins": [
Expand Down
5 changes: 1 addition & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ This is a plug-in for the Unreal Engine with the purpose of native integration o
## Prerequisites

- Unreal Engine 4.23 or later
- Windows
- Microsoft Visual Studio 2015 or later (Express or Community Edition should suffice)


## Installation

Expand All @@ -17,7 +14,7 @@ This is a plug-in for the Unreal Engine with the purpose of native integration o
- Adapt the _.uplugin_ file to the version of your _UnrealEditor_:<br>The `EngineVersion` key in the file _DTrackPlugin.uplugin_ comes with a default value corresponding to the latest tested _UE4Editor_ version (e.g. `"EngineVersion": "4.25.0"`).<br>If you are using an _UE4Editor_ version with a different minor version number (e.g. 4.23 instead of 4.25), you should adjust this value (e.g. to `"EngineVersion": "4.23.0"`).

### Install into the global Engine plugin folder
- Compile the plugin manually:<br> *&lt;UE4Dir&gt;\Engine\Build\BatchFiles\RunUAT.bat* BuildPlugin -Plugin=*/Path/to/DTrackPlugin.uplugin* -TargetPlatforms=Win64 -Package=*&lt;OutDir&gt;* -Rocket
- Compile the plugin manually:<br> *&lt;UE4Dir&gt;\Engine\Build\BatchFiles\RunUAT.bat* BuildPlugin -Plugin=*/Path/to/DTrackPlugin.uplugin* -TargetPlatforms=*&lt;Win64/Linux&gt;* -Package=*&lt;OutDir&gt;* -Rocket
- Copy *&lt;OutDir&gt;* to *&lt;UE4Dir&gt;\Engine\Plugins\DTrackPlugin*


Expand Down
24 changes: 12 additions & 12 deletions Source/DTrackInput/Private/DTrackFlystickInputDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ FDTrackFlystickInputDevice::FDTrackFlystickInputDevice(const TSharedRef< FGeneri
ModularFeatures.OnModularFeatureRegistered().AddRaw(this, &FDTrackFlystickInputDevice::on_modular_feature_registerd);
}

m_button_mapping.Add( EKeys::Gamepad_LeftTrigger.GetFName() );
m_button_mapping.Add( EKeys::Gamepad_FaceButton_Bottom.GetFName() );
m_button_mapping.Add( EKeys::Gamepad_FaceButton_Right.GetFName() );
m_button_mapping.Add( EKeys::Gamepad_FaceButton_Left.GetFName() );
m_button_mapping.Add( EKeys::Gamepad_FaceButton_Top.GetFName() );
m_button_mapping.Add( EKeys::Gamepad_DPad_Up.GetFName() );
m_button_mapping.Add( EKeys::Gamepad_DPad_Down.GetFName() );
m_button_mapping.Add( EKeys::Gamepad_DPad_Right.GetFName() );
m_button_mapping.Add( EKeys::Gamepad_DPad_Left.GetFName() );

m_joystick_mapping.Add( EKeys::Gamepad_LeftX.GetFName() );
m_joystick_mapping.Add( EKeys::Gamepad_LeftY.GetFName() );
m_button_mapping.Add( FDTrackInputModule::FlystickTrigger.GetFName() );
m_button_mapping.Add( FDTrackInputModule::FlystickButton1.GetFName() );
m_button_mapping.Add( FDTrackInputModule::FlystickButton2.GetFName() );
m_button_mapping.Add( FDTrackInputModule::FlystickButton3.GetFName() );
m_button_mapping.Add( FDTrackInputModule::FlystickButton4.GetFName() );
m_button_mapping.Add( FDTrackInputModule::FlystickButton5.GetFName() );
m_button_mapping.Add( FDTrackInputModule::FlystickButton6.GetFName() );
m_button_mapping.Add( FDTrackInputModule::FlystickButton7.GetFName() );
m_button_mapping.Add( FDTrackInputModule::FlystickButton8.GetFName() );

m_joystick_mapping.Add( FDTrackInputModule::FlystickThumbstickX.GetFName() );
m_joystick_mapping.Add( FDTrackInputModule::FlystickThumbstickY.GetFName() );
}

FDTrackFlystickInputDevice::~FDTrackFlystickInputDevice() {
Expand Down
28 changes: 27 additions & 1 deletion Source/DTrackInput/Private/DTrackInputModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,35 @@

DEFINE_LOG_CATEGORY(LogDTrackInput);


/* Keys */
const FKey FDTrackInputModule::FlystickTrigger = FKey("Flystick_Trigger");
const FKey FDTrackInputModule::FlystickButton1 = FKey("Flystick_Button_1");
const FKey FDTrackInputModule::FlystickButton2 = FKey("Flystick_Button_2");
const FKey FDTrackInputModule::FlystickButton3 = FKey("Flystick_Button_3");
const FKey FDTrackInputModule::FlystickButton4 = FKey("Flystick_Button_4");
const FKey FDTrackInputModule::FlystickButton5 = FKey("Flystick_Button_5");
const FKey FDTrackInputModule::FlystickButton6 = FKey("Flystick_Button_6");
const FKey FDTrackInputModule::FlystickButton7 = FKey("Flystick_Button_7");
const FKey FDTrackInputModule::FlystickButton8 = FKey("Flystick_Button_8");
/* Axis */
const FKey FDTrackInputModule::FlystickThumbstickX = FKey("Flystick_Thumbstick_X");
const FKey FDTrackInputModule::FlystickThumbstickY = FKey("Flystick_Thumbstick_Y");

TSharedPtr< class IInputDevice > FDTrackInputModule::CreateInputDevice(const TSharedRef< FGenericApplicationMessageHandler >& InMessageHandler) {
EKeys::AddMenuCategoryDisplayInfo(FlystickKeyCategory, FText::AsCultureInvariant("A.R.T. Flystick"), TEXT("GraphEditor.PadEvent_16x"));

EKeys::AddKey(FKeyDetails(FlystickTrigger, FText::AsCultureInvariant("Flystick Trigger"), FKeyDetails::GamepadKey, FlystickKeyCategory));
EKeys::AddKey(FKeyDetails(FlystickButton1, FText::AsCultureInvariant("Flystick Button 1"), FKeyDetails::GamepadKey, FlystickKeyCategory));
EKeys::AddKey(FKeyDetails(FlystickButton2, FText::AsCultureInvariant("Flystick Button 2"), FKeyDetails::GamepadKey, FlystickKeyCategory));
EKeys::AddKey(FKeyDetails(FlystickButton3, FText::AsCultureInvariant("Flystick Button 3"), FKeyDetails::GamepadKey, FlystickKeyCategory));
EKeys::AddKey(FKeyDetails(FlystickButton4, FText::AsCultureInvariant("Flystick Button 4"), FKeyDetails::GamepadKey, FlystickKeyCategory));
EKeys::AddKey(FKeyDetails(FlystickButton5, FText::AsCultureInvariant("Flystick Button 5"), FKeyDetails::GamepadKey, FlystickKeyCategory));
EKeys::AddKey(FKeyDetails(FlystickButton6, FText::AsCultureInvariant("Flystick Button 6"), FKeyDetails::GamepadKey, FlystickKeyCategory));
EKeys::AddKey(FKeyDetails(FlystickButton7, FText::AsCultureInvariant("Flystick Button 7"), FKeyDetails::GamepadKey, FlystickKeyCategory));
EKeys::AddKey(FKeyDetails(FlystickButton8, FText::AsCultureInvariant("Flystick Button 8"), FKeyDetails::GamepadKey, FlystickKeyCategory));
EKeys::AddKey(FKeyDetails(FlystickThumbstickX, FText::AsCultureInvariant("Flystick Thumbstick X"), FKeyDetails::GamepadKey | FKeyDetails::Axis1D, FlystickKeyCategory));
EKeys::AddKey(FKeyDetails(FlystickThumbstickY, FText::AsCultureInvariant("Flystick Thumbstick Y"), FKeyDetails::GamepadKey | FKeyDetails::Axis1D, FlystickKeyCategory));

return TSharedPtr< class IInputDevice >(new FDTrackFlystickInputDevice(InMessageHandler));
}

Expand Down
19 changes: 18 additions & 1 deletion Source/DTrackInput/Private/DTrackInputModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@


#include "IDTrackInputModule.h"
#include "InputCoreTypes.h"

class FDTrackFlystickInputDevice;
class ILiveLinkClient;
Expand All @@ -42,7 +43,23 @@ DECLARE_LOG_CATEGORY_EXTERN(LogDTrackInput, Log, All);
class FDTrackInputModule : public IDTrackInputModule
{
public:


/* Category */
const FName FlystickKeyCategory = FName("ART_Flystick");
/* Keys */
static const FKey FlystickTrigger;
static const FKey FlystickButton1;
static const FKey FlystickButton2;
static const FKey FlystickButton3;
static const FKey FlystickButton4;
static const FKey FlystickButton5;
static const FKey FlystickButton6;
static const FKey FlystickButton7;
static const FKey FlystickButton8;
/* Axis */
static const FKey FlystickThumbstickX;
static const FKey FlystickThumbstickY;

//~ Begin IInputDeviceModule implementation
virtual TSharedPtr< class IInputDevice > CreateInputDevice(const TSharedRef< FGenericApplicationMessageHandler >& InMessageHandler) override;
//~ End IInputDeviceModule implementation
Expand Down
21 changes: 18 additions & 3 deletions Source/DTrackPlugin/Private/DTrackLiveLinkSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "DTrackPlugin.h"
#include "DTrackLiveLinkSourceSettings.h"
#include "DTrackSDKHandler.h"
#include "DTrackLiveLinkRole.h"
#include "ILiveLinkClient.h"
#include "Misc/App.h"
#include "Roles/LiveLinkAnimationRole.h"
Expand All @@ -48,12 +49,15 @@ void FDTrackLiveLinkSource::ReceiveClient(ILiveLinkClient* InClient, FGuid InSou

m_client = InClient;
m_source_guid = InSourceGuid;
m_sdk_handler = MakeUnique<FDTrackSDKHandler>(this);
if (!m_sdk_handler.IsValid()) {
m_sdk_handler = MakeUnique<FDTrackSDKHandler>(this);
}
}

void FDTrackLiveLinkSource::InitializeSettings(ULiveLinkSourceSettings* InSettings) {

m_source_settings = CastChecked<UDTrackLiveLinkSourceSettings>(InSettings);
reset_datamaps();
m_sdk_handler->start_listening(m_source_settings->m_server_settings);
}

Expand Down Expand Up @@ -117,8 +121,19 @@ void FDTrackLiveLinkSource::handle_body_data_anythread(double n_worldtime, doubl
}
else {

FString subject_name;
std::string body_name = "";
if(m_sdk_handler->get_body_name(n_itemId, body_name))
{
body_name.erase(std::remove(body_name.begin(), body_name.end(), '\"'), body_name.end()); //Removing quotes
subject_name = UTF8_TO_TCHAR(body_name.c_str());
}
else
{
subject_name = FString::Printf(TEXT("DTrack-Body-%02d"), n_itemId);
}

//Body data always consists of Location and Rotation. No need to make verification to resend static data
const FString subject_name = FString::Printf(TEXT("DTrack-Body-%02d"), n_itemId);
key = FLiveLinkSubjectKey(m_source_guid, *subject_name);
m_body_subjects.Add(n_itemId, key);

Expand Down Expand Up @@ -209,7 +224,6 @@ void FDTrackLiveLinkSource::handle_flystick_input_anythread(double n_worldtime,
}
}
else {

const FString subject_name = FString::Printf(TEXT("DTrack-FlystickInput-%02d"), n_itemId);
key = FLiveLinkSubjectKey(m_source_guid, *subject_name);
m_flystick_input_subjects.Add(n_itemId, key);
Expand Down Expand Up @@ -290,6 +304,7 @@ void FDTrackLiveLinkSource::reset_datamaps() {
bool FDTrackLiveLinkSource::RequestSourceShutdown() {

m_sdk_handler->Stop();
reset_datamaps();
return true;
}

Expand Down
7 changes: 1 addition & 6 deletions Source/DTrackPlugin/Private/DTrackPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,9 @@ TSharedPtr<FDTrackLiveLinkSource> FDTrackPlugin::create_livelink_source() {
if (!m_livelink_source.IsValid()) {

m_livelink_source = MakeShared<FDTrackLiveLinkSource>();
return m_livelink_source;
}
else {

return m_livelink_source;
}

return nullptr;
return m_livelink_source;
}

void FDTrackPlugin::handle_app_pre_exit() {
Expand Down
11 changes: 8 additions & 3 deletions Source/DTrackPlugin/Private/DTrackSDKHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ void FDTrackSDKHandler::stop_listening() {
}
}

bool FDTrackSDKHandler::get_body_name(uint32 body_index, std::string& body_name)
{
return m_dtrack->getParam(TCHAR_TO_UTF8(*FString::Printf(TEXT("body desc standard b%02d"), body_index + 1)), body_name);
}

bool FDTrackSDKHandler::is_active() const {
return m_is_active;
}
Expand Down Expand Up @@ -188,12 +193,12 @@ uint32 FDTrackSDKHandler::Run() {

m_is_connecting = true;

if (CopiedSettings.m_dtrack_start_mea) {
UE_LOG(LogDTrackPlugin, Verbose, TEXT("Connecting to DTrack2 server with IP '%s' on port '%d'."), *CopiedSettings.m_dtrack_server_ip, m_server_settings.m_dtrack_server_port);
if (!CopiedSettings.m_dtrack_server_ip.IsEmpty()) {
UE_LOG(LogDTrackPlugin, Verbose, TEXT("Connecting to DTrack2 server with IP '%s' and listening on port '%d'."), *CopiedSettings.m_dtrack_server_ip, m_server_settings.m_dtrack_server_port);
m_dtrack = MakeUnique<DTrackSDK>(TCHAR_TO_UTF8(*CopiedSettings.m_dtrack_server_ip), CopiedSettings.m_dtrack_server_port);
}
else {
UE_LOG(LogDTrackPlugin, Verbose, TEXT("Connecting to DTrack server on port '%d'."), CopiedSettings.m_dtrack_server_port);
UE_LOG(LogDTrackPlugin, Verbose, TEXT("Listening to DTrack on port '%d'."), CopiedSettings.m_dtrack_server_port);
m_dtrack = MakeUnique<DTrackSDK>(CopiedSettings.m_dtrack_server_port);
}

Expand Down
3 changes: 3 additions & 0 deletions Source/DTrackPlugin/Public/DTrackLiveLinkSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
class FDTrackSDKHandler;
class ILiveLinkClient;

/**
* Singleton class generated by FDTrackPlugin (DTrackPlugin.cpp)
*/
class DTRACKPLUGIN_API FDTrackLiveLinkSource : public ILiveLinkSource
{
public:
Expand Down
8 changes: 4 additions & 4 deletions Source/DTrackPlugin/Public/DTrackLiveLinkSourceSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ struct FDTrackServerSettings
UPROPERTY(EditAnywhere, Category = "Server Settings", meta = (DisplayName = "DTrack Data Port", ToolTip = "Port your server sends data to"))
int32 m_dtrack_server_port = 5000;

//UPROPERTY(EditAnywhere, Category = "Server Settings", meta = (DisplayName = "Start DTrack Measurement", ToolTip = "Start measurement via the DTrack2 TCP command channel"))
UPROPERTY(EditAnywhere, Category = "Server Settings", meta = (DisplayName = "Start DTrack Measurement", ToolTip = "Start measurement via the DTrack2 TCP command channel"))
bool m_dtrack_start_mea = false;

//UPROPERTY(EditAnywhere, Category = "Server Settings", meta = (DisplayName = "DTrack Server IP", ToolTip = "IP of DTrack server host for starting measurement"))
FString m_dtrack_server_ip = "127.0.0.1";
UPROPERTY(EditAnywhere, Category = "Server Settings", meta = (DisplayName = "DTrack Server IP", ToolTip = "IP of DTrack server host for starting measurement"))
FString m_dtrack_server_ip = "";

//UPROPERTY(EditAnywhere, Category = "Server Settings", meta = (DisplayName = "DTrack Room Calibration", ToolTip = "Set this according to your DTrack system's room calibration"))
UPROPERTY(EditAnywhere, Category = "Server Settings", meta = (DisplayName = "DTrack Room Calibration", ToolTip = "Set this according to your DTrack system's room calibration"))
EDTrackCoordinateSystemType m_coordinate_system = EDTrackCoordinateSystemType::CST_Unreal_Adapted;
};

Expand Down
19 changes: 14 additions & 5 deletions Source/DTrackPlugin/Public/DTrackSDKHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@

#include "ILiveLinkSource.h"

// Avoid 'warning C4005' when including DTrackSDK
#include "Windows/AllowWindowsPlatformTypes.h"
#include "Windows/PreWindowsApi.h"
#if PLATFORM_WINDOWS
// Avoid 'warning C4005' when including DTrackSDK
#include "Windows/AllowWindowsPlatformTypes.h"
#include "Windows/PreWindowsApi.h"
#endif

#include "DTrackSDK.hpp"
#include "Windows/PostWindowsApi.h"
#include "Windows/HideWindowsPlatformTypes.h"

#if PLATFORM_WINDOWS
#include "Windows/PostWindowsApi.h"
#include "Windows/HideWindowsPlatformTypes.h"
#endif

#include "HAL/Runnable.h"
#include "HAL/ThreadSafeBool.h"
Expand Down Expand Up @@ -61,6 +67,9 @@ class DTRACKPLUGIN_API FDTrackSDKHandler : public FRunnable
// Stops the server listening thread if any and stop measurements on the SDK
void stop_listening();

// Get the name for a specific body index
bool get_body_name(uint32 body_index, std::string& body_name);

public:

// Returns true if connection to server is active
Expand Down