TwinFan / XPPlanes

Display additional planes controled by network messages
https://twinfan.github.io/XPPlanes/
2 stars 1 forks source link

Using own 3D model #2

Closed gameengineer closed 2 months ago

gameengineer commented 6 months ago

I just learned about this project. We want to show our aircraft in X-Plane 12. We do not have an aircraft plugin for our aircraft, just a 3D OBJ model. We need to move it around in X-Plane using our external simulator. Your XPPlane readme states we need to supply a CSL model under Resources for our plane(s) that are used by XPPlane. Do we need to create a CSL model for our aircraft? If so what are the procedures? Our aircraft just needs to be a static mesh moving in the air given the position and orientation values we will send to XPPlane plugin from our external app using the JSON format you describe.

TwinFan commented 6 months ago

You don't need to create your own CSL model, but you need to have one installed. The Readme also provides a link:

The Resources folder needs to hold the CSL model installation, similar to LiveTraffic

If you follow that link you'll find the "CSL Model Installation" chapter that explains exactly that. You would need just one single CSL model so that XPPlanes has something to put into in the sky. But at least that one single model you need. If you have question to that documentation I'm happy to help.

TwinFan commented 6 months ago

Found your conversation on X-Plane.org as HellG had tagged me.

t depends on their other library XPMP2. Needed to copy it to the lib/XPMP2 folder before CMaking.

XPMP2 is a submodule, so git clone --recurse-submodules https://github.com/TwinFan/XPPlanes should do the trick. I should probably add that to the readme.

They set optimization flag for Debug which conflicts with another option. Debug builds now.

What exactly was your originaly problem and how did you solve it? Might be worth checking in.

gameengineer commented 6 months ago

Ok cool you found my conversation. Yeah in VS 2019 Debug build it was complaining (build error actually) that the XMP2 library was not created. XPMP2 fails because of a flag conflict See this line in the dump below: 2>cl : command line error D8016: '/O2' and '/RTC1' command-line options are incompatible

Looks like you have in the XPMP2 Debug configuration the Optimization set to Max (/02) but that conflicts with The Basic Runtime Checks setting under Code Generation which is /RTC1 or "Both". When I change the Basic Runtime Checks to it sets the field to "default" and the lib successfully builds in Debug configuration. Unclear if that's what you intended or if there is a different problem that I missed but that made it compile for me. I needed the Debug symbols for debugging with VS and X-Plane. Release configuration builds fine with no changes.

Rebuild started... 1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Debug x64 ------ 1>Checking Build System 2>------ Rebuild All started: Project: XPMP2, Configuration: Debug x64 ------ 2>Building Custom Rule F:/Dev/X-Plane/XPPlanes/XPPlanes-main/lib/XPMP2/CMakeLists.txt 2>cl : command line error D8016: '/O2' and '/RTC1' command-line options are incompatible 2>Done building project "XPMP2.vcxproj" -- FAILED. 3>------ Rebuild All started: Project: XPPlanes, Configuration: Debug x64 ------ 3>Building Custom Rule F:/Dev/X-Plane/XPPlanes/XPPlanes-main/CMakeLists.txt 3>cmake_pch.cxx 3>parson.c 3>parsonWrapper.cpp 3>FlightData.cpp 3>FD_RTTFC.cpp 3>FD_XPPTraffic.cpp 3>Global.cpp 3>Listener.cpp 3>main.cpp 3>Network.cpp 3>Plane.cpp 3>Utilities.cpp 3>LINK : fatal error LNK1104: cannot open file 'lib\XPMP2\Debug\XPMP2.lib' 3>Done building project "XPPlanes.vcxproj" -- FAILED. 4>------ Skipped Rebuild All: Project: ALL_BUILD, Configuration: Debug x64 ------ 4>Project not selected to build for this solution configuration ========== Rebuild All: 1 succeeded, 2 failed, 1 skipped ==========

gameengineer commented 6 months ago

You don't need to create your own CSL model, but you need to have one installed. The Readme also provides a link:

The Resources folder needs to hold the CSL model installation, similar to LiveTraffic

If you follow that link you'll find the "CSL Model Installation" chapter that explains exactly that. You would need just one single CSL model so that XPPlanes has something to put into in the sky. But at least that one single model you need. If you have question to that documentation I'm happy to help.

I did download one of the BB CSL files, installed and ran it and the XXPlane now shows enabled. Ok so adding one CSL file worked as far as getting the plugin to go but about not having my model to be a CSL file or defined as CSL what do I need to do to get my 3D model into X-Plane using your XPPlane plugin? Backing up a bit, maybe using your plugin is overkill for me and my application. We may be interested in ADS-B data in the future but not at the moment. We just need to render our model in X-Plane (without having to define a full aircraft plugin, if possible) and move it around.

TwinFan commented 6 months ago

Models in X-Plane's 3D world are in fact CSL models. And "moving around" won't work without some plugin pushing an instance of such a model.

I am not a 3D modeler myself. While I could point you to the .OBJ file format definition of CSL files it will probably not help you much. Nobody is writing that code manually. I hear people use tools like Blender for modeling, but I don't have the details. This Forum might be of help for modelling.

Once you have a model you may find XPPlanes helpful again. Alternatively, you can certainly write your own plugin using X-Plane's Instance API. Laminar offers sample code showing how to use the Instancing API.