Skip to content

Commit

Permalink
Linux & Macos support for the Unreal Engine plugin (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
demonixis authored Aug 17, 2023
1 parent 951d312 commit e4aa2a9
Show file tree
Hide file tree
Showing 15 changed files with 371 additions and 76 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ cmake-build-*/
UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Binaries
UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Intermediate
UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Resources/JSBSim
UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim
UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Lib
UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/LibDebug
UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include
UnrealEngine/Binaries
UnrealEngine/DerivedDataCache
UnrealEngine/Intermediate
UnrealEngine/Saved
UnrealEngine/UEReferenceApp.xcworkspace
UnrealEngine/UEReferenceApp.sln
49 changes: 49 additions & 0 deletions JSBSimForUnrealLinux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# make build folder and cd into it
mkdir -p build
cd build

# build the jsbsim library with cmake
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-stdlib=libc++" ..
make -j4

# cd back to the root directory
cd ..

# set the unreal plugin folder for use in the script
UNREAL_PLUGIN_FOLDER=./UnrealEngine/Plugins/JSBSimFlightDynamicsModel
UNREAL_PLUGIN_INCLUDE_FOLDER=$UNREAL_PLUGIN_FOLDER/Source/ThirdParty/JSBSim/Include
UNREAL_PLUGIN_LIB_FOLDER=$UNREAL_PLUGIN_FOLDER/Source/ThirdParty/JSBSim/Lib/Linux
UNREAL_PLUGIN_RESOURCES_FOLDER=$UNREAL_PLUGIN_FOLDER/Resources/JSBSim

echo "Copying JSBSim header files to Unreal plugin folder: $UNREAL_PLUGIN_INCLUDE_FOLDER"

# make the unreal plugin thirdparty/jsbsim/include folder
rm -rf $UNREAL_PLUGIN_INCLUDE_FOLDER
mkdir -p $UNREAL_PLUGIN_INCLUDE_FOLDER
# copy the include files (.h,.hxx) from src (and its subdirectories) into unreal
# plugin thirdparty/jsbsim/include folder, keeping the same directory structure
# as in src. Since we're on macos, we use rsync instead of cp to preserve the
# directory structure

# Copy headers
rsync -avm --include='*.h' --include='*.hpp' --include='*.hxx' -f 'hide,! */' src/ UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/

echo "Copying JSBSim library to Unreal plugin folder:
$UNREAL_PLUGIN_LIB_FOLDER"
# make the unreal plugin thirdparty/jsbsim/lib folder
mkdir -p $UNREAL_PLUGIN_LIB_FOLDER
# copy the jsbsim library from the build folder into the unreal plugin
# thirdparty/jsbsim/lib folder
# cp ./build/src/libJSBSim.a $UNREAL_PLUGIN_LIB_FOLDER/.
cp ./build/src/*.so $UNREAL_PLUGIN_LIB_FOLDER/.

echo "Copying JSBSim resources to Unreal plugin folder:
$UNREAL_PLUGIN_RESOURCES_FOLDER"
# make the unreal plugin resources folder
mkdir -p $UNREAL_PLUGIN_RESOURCES_FOLDER
# copy the aircraft, engine, and systems folders into the unreal plugin resources folder
cp -r ./aircraft $UNREAL_PLUGIN_FOLDER/Resources/JSBSim/.
cp -r ./engine $UNREAL_PLUGIN_FOLDER/Resources/JSBSim/.
cp -r ./systems $UNREAL_PLUGIN_FOLDER/Resources/JSBSim/.
49 changes: 49 additions & 0 deletions JSBSimForUnrealMac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# make build folder and cd into it
mkdir -p build
cd build

# build the jsbsim library with cmake
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-stdlib=libc++" ..
make -j4

# cd back to the root directory
cd ..

# set the unreal plugin folder for use in the script
UNREAL_PLUGIN_FOLDER=./UnrealEngine/Plugins/JSBSimFlightDynamicsModel
UNREAL_PLUGIN_INCLUDE_FOLDER=$UNREAL_PLUGIN_FOLDER/Source/ThirdParty/JSBSim/Include
UNREAL_PLUGIN_LIB_FOLDER=$UNREAL_PLUGIN_FOLDER/Source/ThirdParty/JSBSim/Lib/Mac
UNREAL_PLUGIN_RESOURCES_FOLDER=$UNREAL_PLUGIN_FOLDER/Resources/JSBSim

echo "Copying JSBSim header files to Unreal plugin folder: $UNREAL_PLUGIN_INCLUDE_FOLDER"

# make the unreal plugin thirdparty/jsbsim/include folder
rm -rf $UNREAL_PLUGIN_INCLUDE_FOLDER
mkdir -p $UNREAL_PLUGIN_INCLUDE_FOLDER
# copy the include files (.h,.hxx) from src (and its subdirectories) into unreal
# plugin thirdparty/jsbsim/include folder, keeping the same directory structure
# as in src. Since we're on macos, we use rsync instead of cp to preserve the
# directory structure

# Copy headers
rsync -avm --include='*.h' --include='*.hpp' --include='*.hxx' -f 'hide,! */' src/ UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/

echo "Copying JSBSim library to Unreal plugin folder:
$UNREAL_PLUGIN_LIB_FOLDER"
# make the unreal plugin thirdparty/jsbsim/lib folder
mkdir -p $UNREAL_PLUGIN_LIB_FOLDER
# copy the jsbsim library from the build folder into the unreal plugin
# thirdparty/jsbsim/lib folder
# cp ./build/src/libJSBSim.a $UNREAL_PLUGIN_LIB_FOLDER/.
cp ./build/src/*.dylib $UNREAL_PLUGIN_LIB_FOLDER/.

echo "Copying JSBSim resources to Unreal plugin folder:
$UNREAL_PLUGIN_RESOURCES_FOLDER"
# make the unreal plugin resources folder
mkdir -p $UNREAL_PLUGIN_RESOURCES_FOLDER
# copy the aircraft, engine, and systems folders into the unreal plugin resources folder
cp -r ./aircraft $UNREAL_PLUGIN_FOLDER/Resources/JSBSim/.
cp -r ./engine $UNREAL_PLUGIN_FOLDER/Resources/JSBSim/.
cp -r ./systems $UNREAL_PLUGIN_FOLDER/Resources/JSBSim/.
13 changes: 0 additions & 13 deletions UnrealEngine/.gitignore

This file was deleted.

12 changes: 12 additions & 0 deletions UnrealEngine/CleanProject.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

rm -rf *.vs
rm -rf Saved
rm -rf Binaries
rm -rf Build
rm -rf Intermediate
rm -rf DerivedDataCache
rm -rf Script

rm -rf Plugins\JSBSimFlightDynamicsModel\Binaries
rm -rf Plugins\JSBSimFlightDynamicsModel\Intermediate
1 change: 0 additions & 1 deletion UnrealEngine/Config/DefaultInput.ini
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,3 @@ DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.Defaul
+DeviceConfigurations=(VendorID="06A3",ProductID="0763",AxisProperties=((Key=GenericUSBController_Axis3),(Key=GenericUSBController_Axis4),(Key=GenericUSBController_Axis5,Offset=-0.500000),(Key=GenericUSBController_Axis4),(Key=GenericUSBController_Axis5),(Key=GenericUSBController_Axis6),(Key=GenericUSBController_Axis7),(Key=GenericUSBController_Axis8),(Key=GenericUSBController_Axis9),(Key=GenericUSBController_Axis10),(Key=GenericUSBController_Axis11),(Key=GenericUSBController_Axis12),(Key=GenericUSBController_Axis13),(Key=GenericUSBController_Axis14),(Key=GenericUSBController_Axis15),(Key=GenericUSBController_Axis16)),ButtonProperties=((Key=GenericUSBController_Button1),(Key=GenericUSBController_Button2),(Key=GenericUSBController_Button3),(Key=GenericUSBController_Button4),(Key=GenericUSBController_Button5),(Key=GenericUSBController_Button6),(Key=GenericUSBController_Button7),(Key=GenericUSBController_Button8),(Key=GenericUSBController_Button9),(Key=GenericUSBController_Button10),(Key=GenericUSBController_Button11),(Key=GenericUSBController_Button12),(Key=GenericUSBController_Button13),(Key=GenericUSBController_Button14),(Key=GenericUSBController_Button15),(Key=GenericUSBController_Button16),(Key=GenericUSBController_Button17),(Key=GenericUSBController_Button18),(Key=GenericUSBController_Button19),(Key=GenericUSBController_Button20),(Key=GenericUSBController_Button21),(Key=GenericUSBController_Button22),(Key=GenericUSBController_Button23),(Key=GenericUSBController_Button24),(Key=GenericUSBController_Button25),(Key=GenericUSBController_Button26),(Key=GenericUSBController_Button27),(Key=GenericUSBController_Button28),(Key=GenericUSBController_Button29),(Key=GenericUSBController_Button30),(Key=GenericUSBController_Button31),(Key=GenericUSBController_Button32),(Key=GenericUSBController_Button33),(Key=GenericUSBController_Button34),(Key=GenericUSBController_Button35),(Key=GenericUSBController_Button36),(Key=GenericUSBController_Button37),(Key=GenericUSBController_Button38),(Key=GenericUSBController_Button39),(Key=GenericUSBController_Button40)))
+DeviceConfigurations=(VendorID="294B",ProductID="1901",AxisProperties=((Key=GenericUSBController_Axis6),(Key=GenericUSBController_Axis7),(Key=GenericUSBController_Axis8),(Key=GenericUSBController_Axis9),(Key=GenericUSBController_Axis10),(Key=GenericUSBController_Axis11,bInverted=True,Offset=1.000000),(Key=GenericUSBController_Axis7),(Key=GenericUSBController_Axis8),(Key=GenericUSBController_Axis9),(Key=GenericUSBController_Axis10),(Key=GenericUSBController_Axis11),(Key=GenericUSBController_Axis12),(Key=GenericUSBController_Axis13),(Key=GenericUSBController_Axis14),(Key=GenericUSBController_Axis15),(Key=GenericUSBController_Axis16)),ButtonProperties=((Key=GenericUSBController_Button1),(Key=GenericUSBController_Button2),(Key=GenericUSBController_Button3),(Key=GenericUSBController_Button4),(Key=GenericUSBController_Button5),(Key=GenericUSBController_Button6),(Key=GenericUSBController_Button7),(Key=GenericUSBController_Button8),(Key=GenericUSBController_Button9),(Key=GenericUSBController_Button10),(Key=GenericUSBController_Button11),(Key=GenericUSBController_Button12),(Key=GenericUSBController_Button13),(Key=GenericUSBController_Button14),(Key=GenericUSBController_Button15),(Key=GenericUSBController_Button16),(Key=GenericUSBController_Button17),(Key=GenericUSBController_Button18),(Key=GenericUSBController_Button19),(Key=GenericUSBController_Button20),(Key=GenericUSBController_Button21),(Key=GenericUSBController_Button22),(Key=GenericUSBController_Button23),(Key=GenericUSBController_Button24),(Key=GenericUSBController_Button25),(Key=GenericUSBController_Button26),(Key=GenericUSBController_Button27),(Key=GenericUSBController_Button28),(Key=GenericUSBController_Button29),(Key=GenericUSBController_Button30),(Key=GenericUSBController_Button31),(Key=GenericUSBController_Button32),(Key=GenericUSBController_Button33),(Key=GenericUSBController_Button34),(Key=GenericUSBController_Button35),(Key=GenericUSBController_Button36),(Key=GenericUSBController_Button37),(Key=GenericUSBController_Button38),(Key=GenericUSBController_Button39),(Key=GenericUSBController_Button40)))
bRegisterDefaultDevice=True

Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@
#include "JSBSimMovementComponent.h"
#include "JSBSimModule.h"

#pragma warning( push )

// UE treats warning as errors. JSBSim has some warnings in its include files, so if we don't catch them inside this push/pop pragma, we won't be able to build...

#pragma warning( disable : 4263 ) // FGOutputType.h(151): warning C4263: 'bool JSBSim::FGOutputType::Run(void)': member function does not override any base class virtual member function
#pragma warning( disable : 4264 ) // FGOutputType.h(215): warning C4264: 'bool JSBSim::FGModel::Run(bool)': no override available for virtual member function from base 'JSBSim::FGModel'; function is hidden --- And others
#pragma warning( disable : 4005 ) // compiler.h(58): warning C4005: 'DEPRECATED': macro redefinition with UE_5.0\Engine\Source\Runtime\Core\Public\Windows\WindowsPlatformCompilerPreSetup.h(55): note: see previous definition of 'DEPRECATED'
#pragma warning( disable : 4458 ) // FGXMLElement.h(369): error C4458: declaration of 'name' hides class member
// FGOutputType.h(151): warning C4263: 'bool JSBSim::FGOutputType::Run(void)': member function does not override any base class virtual member function
// FGOutputType.h(215): warning C4264: 'bool JSBSim::FGModel::Run(bool)': no override available for virtual member function from base 'JSBSim::FGModel'; function is hidden --- And others
// compiler.h(58): warning C4005: 'DEPRECATED': macro redefinition with UE_5.0\Engine\Source\Runtime\Core\Public\Windows\WindowsPlatformCompilerPreSetup.h(55): note: see previous definition of 'DEPRECATED'
// FGXMLElement.h(369): error C4458: declaration of 'name' hides class member
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4263 )
#pragma warning( disable : 4264 )
#pragma warning( disable : 4005 )
#pragma warning( disable : 4458 )
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Woverloaded-virtual"
#pragma clang diagnostic ignored "-Wshadow"
#endif

#include "FGFDMExec.h"
#include "math/FGLocation.h"
Expand All @@ -35,7 +43,11 @@
#include "Interfaces/IPluginManager.h"
#include "simgear/props/props.hxx"

#ifdef _MSC_VER
#pragma warning( pop )
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif

#include "UEGroundCallback.h"

Expand Down Expand Up @@ -406,11 +418,11 @@ void UJSBSimMovementComponent::InitializeJSBSim()
FString AircraftPath(TEXT("aircraft"));
FString EnginePath(TEXT("engine"));
FString SystemPath(TEXT("systems"));
Exec->SetRootDir(SGPath(*RootDir));
Exec->SetAircraftPath(SGPath(*AircraftPath));
Exec->SetEnginePath(SGPath(*EnginePath));
Exec->SetSystemsPath(SGPath(*SystemPath));

Exec->SetRootDir(SGPath(TCHAR_TO_UTF8(*RootDir)));
Exec->SetAircraftPath(SGPath(TCHAR_TO_UTF8(*AircraftPath)));
Exec->SetEnginePath(SGPath(TCHAR_TO_UTF8(*EnginePath)));
Exec->SetSystemsPath(SGPath(TCHAR_TO_UTF8(*SystemPath)));
// Prepare Initial Conditions
TrimNeeded = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,32 @@

#pragma once

// UE treats warning as errors. JSBSim has some warnings in its include files, so if we don't catch them inside this push/pop pragma, we won't be able to build...
// FGOutputType.h(151): warning C4263: 'bool JSBSim::FGOutputType::Run(void)': member function does not override any base class virtual member function
// FGOutputType.h(215): warning C4264: 'bool JSBSim::FGModel::Run(bool)': no override available for virtual member function from base 'JSBSim::FGModel'; function is hidden --- And others
// compiler.h(58): warning C4005: 'DEPRECATED': macro redefinition with UE_5.0\Engine\Source\Runtime\Core\Public\Windows\WindowsPlatformCompilerPreSetup.h(55): note: see previous definition of 'DEPRECATED'
// FGXMLElement.h(369): error C4458: declaration of 'name' hides class member
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4263 )
#pragma warning( disable : 4264 )
#pragma warning( disable : 4005 )
#pragma warning( disable : 4458 )
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Woverloaded-virtual"
#pragma clang diagnostic ignored "-Wshadow"
#endif

#include "models/FGInertial.h"
#include "math/FGLocation.h"
#include "math/FGColumnVector3.h"

#ifdef _MSC_VER
#pragma warning( pop )
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif

#include "CoreMinimal.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@

#include "JSBSimMovementCompVisualizer.h"
#include "JSBSimMovementComponent.h"


#include "CanvasTypes.h"

// UE treats warning as errors. JSBSim has some warnings in its include files, so if we don't catch them inside this push/pop pragma, we won't be able to build...
// FGOutputType.h(151): warning C4263: 'bool JSBSim::FGOutputType::Run(void)': member function does not override any base class virtual member function
// FGOutputType.h(215): warning C4264: 'bool JSBSim::FGModel::Run(bool)': no override available for virtual member function from base 'JSBSim::FGModel'; function is hidden --- And others
// compiler.h(58): warning C4005: 'DEPRECATED': macro redefinition with UE_5.0\Engine\Source\Runtime\Core\Public\Windows\WindowsPlatformCompilerPreSetup.h(55): note: see previous definition of 'DEPRECATED'
// FGXMLElement.h(369): error C4458: declaration of 'name' hides class member
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4263 )
#pragma warning( disable : 4264 )
#pragma warning( disable : 4005 )
#pragma warning( disable : 4458 )
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Woverloaded-virtual"
#pragma clang diagnostic ignored "-Wshadow"
#endif

#include "math/FGColumnVector3.h"
#include "models/FGLGear.h"
Expand All @@ -18,7 +30,11 @@
#include "DrawDebugHelpers.h"
#include "Engine/Engine.h"

#ifdef _MSC_VER
#pragma warning( pop )
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif

#define FEET_TO_METER 0.3048
#define METER_TO_FEET 3.2808398950131233595800524934383
Expand Down
Loading

0 comments on commit e4aa2a9

Please sign in to comment.