mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
Ref T245, a P3D version of follow aircraft, still experimental
* testing approaches camera, observer, and guessing view name * SimObject code for camera/observer * functions aircraft situation -> FSX formats
This commit is contained in:
@@ -182,12 +182,28 @@ namespace BlackSimPlugin
|
||||
//! Camera rotation;
|
||||
const SIMCONNECT_DATA_PBH &cameraRotation() const { return m_cameraRotation; }
|
||||
|
||||
//! Camera position/rotation
|
||||
void setCameraPositionAndRotation(const SIMCONNECT_DATA_XYZ &position, const SIMCONNECT_DATA_PBH &rotation)
|
||||
{
|
||||
m_cameraPosition = position;
|
||||
m_cameraRotation = rotation;
|
||||
}
|
||||
|
||||
//! Camera GUID
|
||||
GUID getCameraGUID() const { return m_cameraGuid; }
|
||||
|
||||
//! Set camera GUID
|
||||
void setCameraGUID(GUID guid) { m_cameraGuid = guid; m_camera = true; }
|
||||
|
||||
//! No camera anymore
|
||||
void removeCamera() { m_camera = false; }
|
||||
|
||||
//! Set observer
|
||||
void setObserverName(const QString &observer) { m_observerName = observer; }
|
||||
|
||||
//! Observer name
|
||||
const QString &getObserverName() const { return m_observerName; }
|
||||
|
||||
//! Reset the state (like it was a new onject) without affecting interpolator and aircraft
|
||||
void resetState();
|
||||
|
||||
@@ -288,6 +304,7 @@ namespace BlackSimPlugin
|
||||
SIMCONNECT_DATA_XYZ m_cameraPosition;
|
||||
SIMCONNECT_DATA_PBH m_cameraRotation;
|
||||
QByteArray m_callsignByteArray;
|
||||
QString m_observerName;
|
||||
BlackMisc::Aviation::CAircraftLights m_currentLightsInSim { nullptr }; //!< current lights to know state for toggling
|
||||
BlackMisc::Aviation::CAircraftLights m_lightsAsSent { nullptr }; //!< lights as sent to simulator
|
||||
SIMCONNECT_PERIOD m_requestSimDataPeriod = SIMCONNECT_PERIOD_NEVER; //!< how often do we query ground elevation
|
||||
|
||||
@@ -539,6 +539,18 @@ namespace BlackSimPlugin
|
||||
return m_simConnectObjects.removeByOtherSimObject(trace.simObject);
|
||||
}
|
||||
|
||||
void CSimulatorFsxCommon::removeCamera(CSimConnectObject &simObject)
|
||||
{
|
||||
// not in FSX
|
||||
Q_UNUSED(simObject);
|
||||
}
|
||||
|
||||
void CSimulatorFsxCommon::removeObserver(CSimConnectObject &simObject)
|
||||
{
|
||||
// not in FSX
|
||||
Q_UNUSED(simObject);
|
||||
}
|
||||
|
||||
bool CSimulatorFsxCommon::triggerAutoTraceSendId(qint64 traceTimeMs)
|
||||
{
|
||||
if (m_traceSendId) { return false; } // no need
|
||||
@@ -1554,6 +1566,8 @@ namespace BlackSimPlugin
|
||||
|
||||
// call in SIM
|
||||
const SIMCONNECT_DATA_REQUEST_ID requestId = simObject.getRequestId(CSimConnectDefinitions::SimObjectRemove);
|
||||
this->removeCamera(simObject);
|
||||
this->removeObserver(simObject);
|
||||
const HRESULT result = SimConnect_AIRemoveObject(m_hSimConnect, static_cast<SIMCONNECT_OBJECT_ID>(simObject.getObjectId()), requestId);
|
||||
if (isOk(result))
|
||||
{
|
||||
@@ -1968,6 +1982,16 @@ namespace BlackSimPlugin
|
||||
return position;
|
||||
}
|
||||
|
||||
SIMCONNECT_DATA_PBH CSimulatorFsxCommon::aircraftSituationToFsxPBH(const CAircraftSituation &situation)
|
||||
{
|
||||
// MSFS has inverted pitch and bank angles
|
||||
SIMCONNECT_DATA_PBH pbh;
|
||||
pbh.Pitch = -situation.getPitch().value(CAngleUnit::deg());
|
||||
pbh.Bank = -situation.getBank().value(CAngleUnit::deg());
|
||||
pbh.Heading = situation.getHeading().value(CAngleUnit::deg());
|
||||
return pbh;
|
||||
}
|
||||
|
||||
SIMCONNECT_DATA_INITPOSITION CSimulatorFsxCommon::coordinateToFsxPosition(const ICoordinateGeodetic &coordinate)
|
||||
{
|
||||
SIMCONNECT_DATA_INITPOSITION position;
|
||||
@@ -1982,6 +2006,15 @@ namespace BlackSimPlugin
|
||||
return position;
|
||||
}
|
||||
|
||||
SIMCONNECT_DATA_LATLONALT CSimulatorFsxCommon::coordinateToFsxLatLonAlt(const ICoordinateGeodetic &coordinate)
|
||||
{
|
||||
SIMCONNECT_DATA_LATLONALT lla;
|
||||
lla.Latitude = coordinate.latitude().value(CAngleUnit::deg());
|
||||
lla.Longitude = coordinate.longitude().value(CAngleUnit::deg());
|
||||
lla.Altitude = coordinate.geodeticHeight().value(CLengthUnit::ft()); // already corrected in interpolator if there is an underflow
|
||||
return lla;
|
||||
}
|
||||
|
||||
void CSimulatorFsxCommon::synchronizeTime(const CTime &zuluTimeSim, const CTime &localTimeSim)
|
||||
{
|
||||
if (!m_simTimeSynced) { return; }
|
||||
|
||||
@@ -261,6 +261,12 @@ namespace BlackSimPlugin
|
||||
//! Remove the CSimConnectObject linked in the trace
|
||||
bool removeSimObjectForTrace(const TraceFsxSendId &trace);
|
||||
|
||||
//! Remove camera if any
|
||||
virtual void removeCamera(CSimConnectObject &simObject);
|
||||
|
||||
//! Remove observer if any
|
||||
virtual void removeObserver(CSimConnectObject &simObject);
|
||||
|
||||
//! Trace if required, log errors
|
||||
HRESULT logAndTraceSendId(HRESULT hr, const QString &warningMsg, const QString &functionName, const QString &functionDetails = {});
|
||||
|
||||
@@ -281,6 +287,20 @@ namespace BlackSimPlugin
|
||||
static bool is64bit() { return (BlackConfig::CBuildConfig::buildWordSize() == 64); }
|
||||
//! @}
|
||||
|
||||
//! Format conversion
|
||||
//! \note must be valid situation
|
||||
static SIMCONNECT_DATA_INITPOSITION aircraftSituationToFsxPosition(const BlackMisc::Aviation::CAircraftSituation &situation, bool sendGnd = true);
|
||||
|
||||
//! Format conversion
|
||||
//! \note must be valid situation
|
||||
static SIMCONNECT_DATA_PBH aircraftSituationToFsxPBH(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
|
||||
//! Format conversion
|
||||
static SIMCONNECT_DATA_INITPOSITION coordinateToFsxPosition(const BlackMisc::Geo::ICoordinateGeodetic &coordinate);
|
||||
|
||||
//! Format conversion
|
||||
static SIMCONNECT_DATA_LATLONALT coordinateToFsxLatLonAlt(const BlackMisc::Geo::ICoordinateGeodetic &coordinate);
|
||||
|
||||
static constexpr qint64 AutoTraceOffsetMs = 10 * 1000; //!< how long do we trace?
|
||||
HANDLE m_hSimConnect = nullptr; //!< handle to SimConnect object
|
||||
DispatchProc m_dispatchProc = &CSimulatorFsxCommon::SimConnectProc; //!< called function for dispatch, can be overriden by specialized P3D function
|
||||
@@ -454,13 +474,6 @@ namespace BlackSimPlugin
|
||||
//! The SimConnect object for idxs
|
||||
CSimConnectObject getSimObjectForObjectId(DWORD objectId) const;
|
||||
|
||||
//! Format conversion
|
||||
//! \note must be valid situation
|
||||
SIMCONNECT_DATA_INITPOSITION aircraftSituationToFsxPosition(const BlackMisc::Aviation::CAircraftSituation &situation, bool sendGnd = true);
|
||||
|
||||
//! Format conversion
|
||||
SIMCONNECT_DATA_INITPOSITION coordinateToFsxPosition(const BlackMisc::Geo::ICoordinateGeodetic &coordinate);
|
||||
|
||||
//! Sync time with user's computer
|
||||
void synchronizeTime(const BlackMisc::PhysicalQuantities::CTime &zuluTimeSim, const BlackMisc::PhysicalQuantities::CTime &localTimeSim);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user