Add cockpit headtracking, mouse zoom and smoothing#5460
Add cockpit headtracking, mouse zoom and smoothing#5460sturnclaw merged 7 commits intopioneerspacesim:masterfrom
Conversation
|
Yupp, it won't build on windows. Tried with the cmake solution in VS |
|
@fluffyfreak I'd really like to ship this PR in the upcoming Pioneer Day update, but there are Windows build issues due to a new |
|
Progress report: |
90e4530 to
6a3a044
Compare
Add interpolation/smoothing to internal camera mouselook. Add zoom capability to internal camera, for use with cockpit displays.
- Lightweight portable wrapper around Win/Linux/Mac socket libraries - Only supports UDP sockets, only need UDP sockets
UDP packets are handled with nanosockets External headtracking state takes priority over look pitch/yaw axes (joystick-based headtracking).
- Allow the user to enable/disable smoothing by changing a config setting. Not exposed to the UI yet.
- Loaded from config file, no UI available to configure it in-game yet
0920ffc to
c41fc07
Compare
|
@nozmajner I have completely replaced the SDL_Net dependency with NanoSockets instead - the code should now compile without any external dependencies on Windows and (hopefully) prevent any errors when opening the socket now. I'd appreciate you (and anyone else reading this) giving the latest build a try and ensuring there are no platform-specific issues. |
|
Roger roger! |
|
I'm all for stupid jokes! |
|
Going to merge this PR even though the VS solution is failing. Unless @fluffyfreak or others are able to update that solution before Pioneer day (it's mostly complaining about the Headtracker files and nanosockets source being missing from the sln) we'll be deprecating that and moving on to a purely CMake based setup. |
|
Sorry for not being around folks, I should schedule some regular time to checkin and help out more often 😞 |
|
We use the CMake build for generating the "nightly" windows build artifacts, so I think you and maybe 1-2 other people who have talked here on Github are the only ones who would be impacted by removing the manual VS solution. |
|
On Windows here. I haven't compiled in a while but have previously used both the VS solution and CMake successfully. Makes sense to me to standardise on a single build strategy. |
|
I just compiled using the CMake with MSVC. Successful build, though it doesn't show -x64 at the end of the file name when x64 was selected. Connecting my opentrack headtracker to FlightGear mode, nothing happens. I've never used this mode before so I'm not sure it even works, or maybe I need to install something else for it to work. I haven't tried FlightGear since before there was any headtracking support. (Of course, I've been using headtracking in joystick emulation mode with Pioneer for a couple years now, so even if this FlightGear mode support doesn't work, I'm fine going back to stick emulation.) |
Double check in opentrack that you're outputting packets to |
|
Ah, I had to use not the FlightGear mode but UDP Receiver, and change the settings to that 127.0.0.1 with port 4242. It works. Pretty smooth! I'll have to see if I can get a nice dead zone in the middle so I can have the camera straight ahead when I need it. The joystick emulation setup I've been using has a deadzone setup in Pioneer's joystick profiles. It does make looking around a little wonky as there's a pause in the middle of both X and Y axes, though. Maybe I'll just get used to no-deadzone flying and paying attention to the crosshair! |
Ah, my mistake - the UDP output mode uses the FlightGear UDP packet format for the data format it sends, so I've just referred to it as "the FlightGear protocol".
If you want, you can setup a button to disable headtracking output in Opentrack (called "zero output" IIRC) which acts as a toggleable 100% deadzone for when you don't want to be looking around in the cockpit. If you're just looking for something which centers the view when looking relatively forwards... I'd honestly recommend trying to work without the deadzone; I've not had any issues with the view feeling offset in other games or Pioneer without any deadzone. That being said, you can definitely adjust your pitch/yaw output curves in Opentrack to put a big zero-output deadzone between 0 and ±5 degrees or so. 😄 |
|
I wonder if there's a way to use this for VR 🤔 Not the rendering side obviously, but I had a (VERY) old branch which did that and it wasn't as tough as I'd imagined. Trickiest part was the UI |
|
This code is separated out from a larger effort to replace the cockpit code with a full 6-DOF cockpit which isn't moving the ship around the player to indicate motion, as well as some nice things like clickable buttons and screens in the cockpit... when that code lands, it could be quite compatible with VR headtracking. |


This PR has been a long time in the making. The original commit dates back to May 2021, and I've finally unearthed it from the annals of my git history and dusted it off.
I've added support for mouse smoothing and scroll-wheel zooming to the internal (cockpit) camera. Now if you want to see what that thing in the distance is, you no longer have to use the sidereal camera mode but can simply just zoom in on it from your cockpit. This pairs extremely well with the next feature, which is...
Headtracking! (Finally!) - I've added proper UDP headtracking support which can listen to a configurable host/port to support any headtracking source that outputs the FlightGear UDP protocol. This is primarily designed to support OpenTrack, though if you have another software that outputs the right data then you should be able to use that too.
https://youtu.be/MuGB3oN43Kc
I've also added the ability for users to customize their mouse aim sensitivity when flying - I found that the default sensitivity was way too high for my setup, and a value of 0.3 works really well.
None of these values have UI configuration available at this time - I don't think it'd be a large task to implement, but I'd rather change how the lua->engine config interface works than copy around another 6-8 boilerplate functions.
I'd appreciate some double-checking from those on Windows regarding the
SDL2_netdependency - I'll add it topioneer-thirdpartyif needed, but I develop primarily and solely on Linux.