diff --git a/.gitignore b/.gitignore index d8ac2f2ade..272c03b5cf 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/JSBSimForUnrealLinux.sh b/JSBSimForUnrealLinux.sh new file mode 100755 index 0000000000..697959313b --- /dev/null +++ b/JSBSimForUnrealLinux.sh @@ -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/. diff --git a/JSBSimForUnrealMac.sh b/JSBSimForUnrealMac.sh new file mode 100755 index 0000000000..a7af65d33f --- /dev/null +++ b/JSBSimForUnrealMac.sh @@ -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/. diff --git a/UnrealEngine/.gitignore b/UnrealEngine/.gitignore deleted file mode 100644 index 95b56cbad3..0000000000 --- a/UnrealEngine/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -################# -## Unreal Engine -################# -Plugins/JSBSimFlightDynamicsModel/Binaries -Plugins/JSBSimFlightDynamicsModel/Intermediate -Plugins/JSBSimFlightDynamicsModel/Resources/JSBSim -Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim -Binaries -DerivedDataCache -Intermediate -Saved -Windows -UEReferenceApp.sln diff --git a/UnrealEngine/CleanProject.sh b/UnrealEngine/CleanProject.sh new file mode 100755 index 0000000000..75a9f323c7 --- /dev/null +++ b/UnrealEngine/CleanProject.sh @@ -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 \ No newline at end of file diff --git a/UnrealEngine/Config/DefaultInput.ini b/UnrealEngine/Config/DefaultInput.ini index 25f6dbc17c..82971843c0 100644 --- a/UnrealEngine/Config/DefaultInput.ini +++ b/UnrealEngine/Config/DefaultInput.ini @@ -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 - diff --git a/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModel/Private/JSBSimMovementComponent.cpp b/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModel/Private/JSBSimMovementComponent.cpp index 06c3fe44bb..afe5358311 100644 --- a/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModel/Private/JSBSimMovementComponent.cpp +++ b/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModel/Private/JSBSimMovementComponent.cpp @@ -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" @@ -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" @@ -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; diff --git a/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModel/Public/UEGroundCallback.h b/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModel/Public/UEGroundCallback.h index 501e917c4b..e0425cba22 100644 --- a/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModel/Public/UEGroundCallback.h +++ b/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModel/Public/UEGroundCallback.h @@ -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" diff --git a/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModelEditor/Private/JSBSimMovementCompVisualizer.cpp b/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModelEditor/Private/JSBSimMovementCompVisualizer.cpp index cc1736f2a8..a6a82370db 100644 --- a/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModelEditor/Private/JSBSimMovementCompVisualizer.cpp +++ b/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModelEditor/Private/JSBSimMovementCompVisualizer.cpp @@ -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" @@ -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 diff --git a/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim.Build.cs b/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim.Build.cs index ff2d9a0fb8..fb4ec6f124 100644 --- a/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim.Build.cs +++ b/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim.Build.cs @@ -5,45 +5,86 @@ public class JSBSim : ModuleRules { - public JSBSim(ReadOnlyTargetRules Target) : base(Target) - { - Type = ModuleType.External; - - // This folder is where the JSBSimForUnreal build has been generated - string JSBSimLocalFolder = "JSBSim"; - - if (Target.Platform == UnrealTargetPlatform.Win64) - { - string LibFolderName = "Lib"; - - // When working in debug mode, try to use the Debug version of JSBSim - if (Target.Configuration == UnrealTargetConfiguration.DebugGame) - { - // Source\ThirdParty\JSBSim\LibDebug - string DebugLibsPath = Path.Combine(ModuleDirectory, JSBSimLocalFolder, LibFolderName + "Debug"); - if (Directory.Exists(DebugLibsPath)) - { - System.Console.WriteLine(string.Format("Found Debug libraries for JSBSim in {0}", DebugLibsPath)); - LibFolderName += "Debug"; - } - } - - // Include headers - PublicSystemIncludePaths.Add(Path.Combine(ModuleDirectory, JSBSimLocalFolder, "Include")); - - // Link Lib - string LibPath = Path.Combine(ModuleDirectory, JSBSimLocalFolder, LibFolderName); - PublicAdditionalLibraries.Add(Path.Combine(LibPath, "JSBSim.lib")); - - // Stage DLL along the binaries files - string DllFullPath = Path.Combine(LibPath, "JSBSim.dll"); - if (!File.Exists(DllFullPath)) + public JSBSim(ReadOnlyTargetRules Target) : base(Target) + { + Type = ModuleType.External; + + bool bJSBSimSupported = Target.Platform == UnrealTargetPlatform.Win64 || + Target.Platform == UnrealTargetPlatform.Mac || + Target.Platform == UnrealTargetPlatform.Linux || + Target.Platform == UnrealTargetPlatform.Android; + + if (Target.Platform == UnrealTargetPlatform.Win64) + SetupWindowsPlatform(); + else + SetupUnixPlatform(); + } + + private void SetupWindowsPlatform() + { + string JSBSimLocalFolder = "JSBSim"; + string LibFolderName = "Lib"; + + // When working in debug mode, try to use the Debug version of JSBSim + if (Target.Configuration == UnrealTargetConfiguration.DebugGame) + { + // Source\ThirdParty\JSBSim\LibDebug + string DebugLibsPath = Path.Combine(ModuleDirectory, JSBSimLocalFolder, LibFolderName + "Debug"); + if (Directory.Exists(DebugLibsPath)) { - string Err = string.Format("JSBSim.dll not found in {0} - Make sure that you have built JSBSimForUnreal.sln first", LibPath); - System.Console.WriteLine(Err); - throw new BuildException(Err); + System.Console.WriteLine(string.Format("Found Debug libraries for JSBSim in {0}", DebugLibsPath)); + LibFolderName += "Debug"; } - RuntimeDependencies.Add("$(BinaryOutputDir)/" + "JSBSim.dll", DllFullPath); - } - } + } + + // Include headers + PublicSystemIncludePaths.Add(Path.Combine(ModuleDirectory, JSBSimLocalFolder, "Include")); + + // Link Lib + string LibPath = Path.Combine(ModuleDirectory, JSBSimLocalFolder, LibFolderName); + PublicAdditionalLibraries.Add(Path.Combine(LibPath, "JSBSim.lib")); + + // Stage DLL along the binaries files + string DllFullPath = CheckForFile(LibPath, "JSBSim.dll"); + RuntimeDependencies.Add("$(BinaryOutputDir)/" + "JSBSim.dll", DllFullPath); + } + + private void SetupUnixPlatform() + { + string JSBSimLocalFolder = "JSBSim"; + string LibFolderName = "Lib"; + string LibPath = Path.Combine(ModuleDirectory, JSBSimLocalFolder, LibFolderName, $"{Target.Platform}"); + + // Include headers + string IncludePath = Path.Combine(ModuleDirectory, JSBSimLocalFolder, "Include"); + PublicSystemIncludePaths.Add(IncludePath); + + string libExt = Target.Platform == UnrealTargetPlatform.Mac ? "dylib" : "so"; + LibPath = CheckForFile(LibPath, $"libJSBSim.{libExt}"); + + PublicAdditionalLibraries.Add(LibPath); + RuntimeDependencies.Add(LibPath); + + if (Target.Platform == UnrealTargetPlatform.Android) + { + string PluginPath = Utils.MakePathRelativeTo(ModuleDirectory, Target.RelativeEnginePath); + AdditionalPropertiesForReceipt.Add("AndroidPlugin", Path.Combine(PluginPath, "JSBSim/JSBSim_APL.xml")); + } + } + + private static string CheckForFile(string path, string file) + { + string filePath = Path.Combine(path, file); + + if (File.Exists(filePath)) + { + System.Console.WriteLine($"JSBSim Path Check OK: {filePath}"); + return filePath; + } + + string Err = $"{file} not found at {path}"; + System.Console.WriteLine(Err); + + throw new BuildException(Err); + } } diff --git a/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/JSBSim_APL.xml b/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/JSBSim_APL.xml new file mode 100755 index 0000000000..9e1f188968 --- /dev/null +++ b/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/JSBSim_APL.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/UnrealEngine/README-Unix.md b/UnrealEngine/README-Unix.md new file mode 100644 index 0000000000..a9aec8319a --- /dev/null +++ b/UnrealEngine/README-Unix.md @@ -0,0 +1,77 @@ +# JSBSim for Unreal - Unix build instructions + +This document describes how to build the JSBSim library as well as the Unreal Engine plugin for supported Unix operating systems. + +## Support +| Operating System | Status | +|------------------|--------| +| Linux | Supported | +| Macos | Supported | +| Android | Work in progress | + +## Building (Easy way) +Run `JSBSimForUnrealMac.sh` on Macos or `JSBSimForUnrealLinux.sh` on Linux + +## Building (Hard way) +The first step is to build JSBSim on your target platform using cmake. Open an terminal and type the following commands + +### For Macos + +```bash +mkdir build +cd build +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 +``` + +### For Linux +Make sure to install the following package `clang libc++-dev libc++1-x libc++abi1-x libc++abi-x-dev`. Where (x) is the version number of your distribution. +On Ubuntu 23.04 it was `libc++ 1.15, libc++abi1-15`. + +```bash +mkdir build +cd build +cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-stdlib=libc++" .. +make -j4 +``` + +### Copy headers and the libJSBSim library +```bash +# From the build folder +cd .. + +# Copy headers +rsync -avm --include='*.h' --include='*.hpp' --include='*.hxx' -f 'hide,! */' src/ UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/ + +# Copy the JSBSim library (Macos) +mkdir -p UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Lib/Mac/ +cp -Rf build/src/libJSBSim.1.2.0.dev1.dylib UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Lib/Mac/libJSBSim.dylib + +# Copy the JSBSim library (Linux) +mkdir -p UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Lib/Linux/ +cp -Rf build/src/libJSBSim.so UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Lib/Linux/ + +# Copy the JSBSim library (Android) +mkdir -p UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Lib/Android/ +cp -Rf build/src/libJSBSim.so UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Lib/Android/ + +# Copy the resource files +mkdir -p UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Resources/JSBSim +cp -Rf aircraft UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Resources/JSBSim +cp -Rf engine UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Resources/JSBSim +cp -Rf systems UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Resources/JSBSim +``` + +### Compile the Unreal Engine project + +Run the following command to compile and run JSBSim for Unreal + +You can generate a makefile or an Xcode workspace using the following command + +```bash +$PATH_TO_UNREAL/Engine/Build/BatchFiles/Mac/GenerateProjectFiles.sh $PATH_TO_JSBSIM/UnrealEngine/UEReferenceApp.uproject -game +``` + +```bash +$PATH_TO_UNREAL/Engine/Binaries/Linux/UnrealEditor $PATH_TO_JSBSIM/UnrealEngine/UEReferenceApp.uproject +``` \ No newline at end of file diff --git a/UnrealEngine/README.md b/UnrealEngine/README.md index a4f89354a4..3f21fd6549 100644 --- a/UnrealEngine/README.md +++ b/UnrealEngine/README.md @@ -16,8 +16,7 @@ Enjoy, and Simulation for the win! ## Building the application - **1. Install Unreal Engine 5.x** - +### 1. Install Unreal Engine 5.x The procedure to install Unreal Engine is described here : https://www.unrealengine.com/en-US/download For hobbyists, the [standard license](https://www.unrealengine.com/en-US/license) applies, and is 100% free! @@ -52,7 +51,7 @@ It is also recommended to set up Visual Studio for Unreal using the following pr [https://docs.unrealengine.com/5.0/en-US/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine/](https://docs.unrealengine.com/5.0/en-US/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine/) [https://docs.unrealengine.com/5.0/en-US/using-the-unrealvs-extension-for-unreal-engine-cplusplus-projects/](https://docs.unrealengine.com/5.0/en-US/using-the-unrealvs-extension-for-unreal-engine-cplusplus-projects/) -**2. Build JSBSim as Dynamic libraries and stage Model files** +### 2. Build JSBSim as Dynamic libraries and stage Model files (Windows) Unreal Engine requires that one plugin contains all its needed files in its sub-folders. This application contains a `Plugins/JSBSimFlightDynamicsModel` folder containing the JSBSim files. @@ -68,15 +67,15 @@ To make this process easier, there is a new solution named JSBSimForUnreal.sln a - It will take care of making a clean build, and copy all needed files at the right location - All libs and headers in `UnrealEngine\Plugins\JSBSimFlightDynamicsModel\Source\ThirdParty\JSBSim` - All resource files (aircrafts/engines/systems) in *UnrealEngine\Plugins\JSBSimFlightDynamicsModel\Resources\JSBSim* - -**3. [Optional] - Download HD resources** + +### 3. [Optional] - Download HD resources In order to keep the JSBSim repository lightweight, this application contains low quality resources. If you would like to use better looking content, you can download HQ aircraft model, HD textures and non-flat terrain here: [High Definition content pack (330 MB)](https://epicgames.box.com/s/93mupzix8qieu51v209ockq68heuxgwj) Simply extract this archive and copy/paste the content folder into the one of UEReferenceApp, overriding the existing files. -**4. Build/Open the Unreal Project** +### 4. Build/Open the Unreal Project **Option 1** : Simply double click on the `UnrealEngine\UEReferenceApp.uproject` file. It will open a popup complaining about missing modules (UEReferenceApp, JSBSimFlightDynamicsModel, JSBSimFlightDynamicsModelEditor). diff --git a/UnrealEngine/UEReferenceApp.uproject b/UnrealEngine/UEReferenceApp.uproject index 4c62a7cac0..eee25d44df 100644 --- a/UnrealEngine/UEReferenceApp.uproject +++ b/UnrealEngine/UEReferenceApp.uproject @@ -42,6 +42,8 @@ } ], "TargetPlatforms": [ - "Windows" + "Windows", + "Linux", + "Mac" ] } \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2a5ac1d5cf..a1f2765cdd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -141,8 +141,7 @@ endif() if(BUILD_SHARED_LIBS) set_target_properties(libJSBSim PROPERTIES - SOVERSION ${LIBRARY_SOVERSION} - FRAMEWORK ON) + SOVERSION ${LIBRARY_SOVERSION}) install(TARGETS libJSBSim LIBRARY DESTINATION lib NAMELINK_SKIP COMPONENT runtime