Skip to content

Commit

Permalink
Add visual helper option
Browse files Browse the repository at this point in the history
  • Loading branch information
n7275 committed Jan 7, 2024
1 parent 20c0aa5 commit 8677916
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions OVP/D3D7Client/VVessel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ void vVessel::UpdateRenderVectors()
if (logscale) len = log(len + 1e-5) - log(1e-5); else len *= scale * 1e5;
AddVector(unit(F) * (len * pscale), _V(0, 0, 0), scale2 * 0.5, std::string(cbuf), _V(1, 0, 1), alpha, D3DRGB(1, 0, 1));
}
if ((flag & BVF_SIDEFORCE) && vessel->GetSideForceVector(F)) {
if ((flag & BFV_SIDEFORCE) && vessel->GetSideForceVector(F)) {
sprintf(cbuf, "SF = %fN", len = length(F));
if (logscale) len = log(len + shift) - lshift; else len *= scale;
AddVector(unit(F) * (len * pscale), _V(0, 0, 0), scale2, std::string(cbuf), _V(0, 0, 1), alpha, D3DRGB(0.5, 0.0, 1.0));
AddVector(unit(F) * (len * pscale), _V(0, 0, 0), scale2, std::string(cbuf), _V(0, 0, 1), alpha, D3DRGB(0.0392, 0.6235, 0.4941));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Orbitersdk/include/GraphicsAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ typedef void *HDC;
#define BFV_DRAG 0x0020 ///< Show drag vector
#define BFV_TOTAL 0x0040 ///< Show total force vector
#define BFV_TORQUE 0x0080 ///< Show torque vector
#define BVF_SIDEFORCE 0x0100 ///< Show side-force vector
#define BFV_SIDEFORCE 0x0100 ///< Show side-force vector
/// @}

/// \defgroup favflag Bit flags for frame axis vector render options
Expand Down
1 change: 1 addition & 0 deletions Src/Orbiter/OptionsPages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,7 @@ void OptionsPage_Forces::UpdateControls(HWND hPage)
SendDlgItemMessage(hPage, IDC_OPT_VEC_THRUST, BM_SETCHECK, vecFlag & BFV_THRUST ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hPage, IDC_OPT_VEC_LIFT, BM_SETCHECK, vecFlag & BFV_LIFT ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hPage, IDC_OPT_VEC_DRAG, BM_SETCHECK, vecFlag & BFV_DRAG ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hPage, IDC_OPT_VEC_SIDEFORCE, BM_SETCHECK, vecFlag & BFV_SIDEFORCE ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hPage, IDC_OPT_VEC_TOTAL, BM_SETCHECK, vecFlag & BFV_TOTAL ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hPage, IDC_OPT_VEC_TORQUE, BM_SETCHECK, vecFlag & BFV_TORQUE ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hPage, IDC_OPT_VEC_LINSCL, BM_SETCHECK, vecFlag & BFV_LOGSCALE ? BST_UNCHECKED : BST_CHECKED, 0);
Expand Down
1 change: 1 addition & 0 deletions Src/Orbiter/Orbiter.rc
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ BEGIN
CONTROL "Thrust",IDC_OPT_VEC_THRUST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,40,44,10
CONTROL "Lift",IDC_OPT_VEC_LIFT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,56,28,44,10
CONTROL "Drag",IDC_OPT_VEC_DRAG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,56,40,44,10
CONTROL "Side", IDC_OPT_VEC_SIDEFORCE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 56, 56, 44, 10
CONTROL "Total",IDC_OPT_VEC_TOTAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,56,80,10
GROUPBOX "Angular moments",IDC_STATIC2,6,80,100,26
CONTROL "Torque",IDC_OPT_VEC_TORQUE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,92,80,10
Expand Down
6 changes: 4 additions & 2 deletions Src/Orbiter/Vessel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4055,7 +4055,7 @@ void Vessel::UpdateAerodynamicForces ()
Vector ddir (-sp.airvel_ship.unit()); // freestream airflow direction (= drag direction)
Vector ldir (0, sp.airvel_ship.z, -sp.airvel_ship.y); ldir.unify(); // lift direction (vertical on drag and transversal ship axis)
Vector sdir (sp.airvel_ship.z, 0, -sp.airvel_ship.x); sdir.unify(); // sidelift direction (vertical on drag and vertical ship axis)
double lift, drag, S;
double lift, drag, side, S;
double CL, CD; // lift, drag coeffs (used by AirfoilCoeffFunc and AirfoilCoeffFuncEx)
double CA, CN, CY; //force coefficients along Orbiter Z, Y, X axes (AirfoilCoeffFuncEx2)
double Cl, Cm, Cn; //moment coefficients about Orbiter Z, X, Y axes (AirfoilCoeffFuncEx2 uses Cl and Cn)
Expand All @@ -4080,9 +4080,10 @@ void Vessel::UpdateAerodynamicForces ()
((AirfoilCoeffFuncEx)af->cf)((VESSEL*)modIntf.v, beta, sp.atmM, Re0*af->c, af->context, &CL, &Cm, &CD);
if (af->S) S = af->S;
else S = fabs(ddir.z)*cs.z + fabs(ddir.x)*cs.z; // use projected vessel CS as reference area
AddForce (sdir*(CL*sp.dynp*S) + ddir*(drag=(CD*sp.dynp*S)), af->ref);
AddForce (sdir*(side = (CL*sp.dynp*S)) + ddir*(drag=(CD*sp.dynp*S)), af->ref);
if (Cm) Amom_add.y += Cm*sp.dynp*af->S*af->c;
Drag += drag;
SideForce += side;
} else if (af->align == FORCE_AND_MOMENT) {
((AirfoilCoeffFuncEx2)af->cf)((VESSEL*)modIntf.v, -_V(sp.airvel_ship.unit().x, sp.airvel_ship.unit().y, sp.airvel_ship.unit().z), aoa, beta, gamma, sp.atmM, Re0 * af->c, af->context, &CA, &CN, &CY, &Cl, &Cm, &Cn);
if (af->S) S = af->S;
Expand All @@ -4093,6 +4094,7 @@ void Vessel::UpdateAerodynamicForces ()
AddForce(AeroForce, af->ref);
Lift = dotp(AeroForce, ldir);
Drag = dotp(AeroForce, ddir);
SideForce = dotp(AeroForce, sdir);

Amom_add.x += Cm * sp.dynp * af->S * af->c;
Amom_add.y -= Cn * sp.dynp * af->S * af->c;
Expand Down
1 change: 1 addition & 0 deletions Src/Orbiter/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
#define IDC_OPT_JOY_STATIC2 1103
#define IDC_OPT_JOY_STATIC3 1104
#define IDC_OPT_JOY_STATIC4 1105
#define IDC_OPT_VEC_SIDEFORCE 1106

// Unsorted
#define IDC_SCN_LIST 1090
Expand Down

0 comments on commit 8677916

Please sign in to comment.