Skip to content

Commit

Permalink
281 visual helpers (#282)
Browse files Browse the repository at this point in the history
Visual helpers dialog (Ctrl-F9):
-    Split Planetarium tab in two: Planetarium and surface/object markers.
-    New planetarium options: constellation boundaries and galactic grid
-    Cleaned up visual helpers dialog code
-    D3D9 client: updated the oapi extension control IDs for force vector and coordinate axis hooks
-    Updated gauge custom dialog control and fixed bug in 64-bit build
  • Loading branch information
mschweiger authored Oct 26, 2022
1 parent 636e278 commit 0e51a10
Show file tree
Hide file tree
Showing 22 changed files with 1,161 additions and 1,049 deletions.
31 changes: 21 additions & 10 deletions OVP/D3D7Client/CelSphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ D3D7CelestialSphere::~D3D7CelestialSphere ()

void D3D7CelestialSphere::InitCelestialTransform()
{
MATRIX3 R = Celestial2Ecliptic();
MATRIX3 R = Ecliptic_CelestialAtEpoch();

m_rotCelestial._11 = (float)R.m11; m_rotCelestial._12 = (float)R.m12; m_rotCelestial._13 = (float)R.m13; m_rotCelestial._14 = 0.0f;
m_rotCelestial._21 = (float)R.m21; m_rotCelestial._22 = (float)R.m22; m_rotCelestial._23 = (float)R.m23; m_rotCelestial._24 = 0.0f;
Expand Down Expand Up @@ -237,16 +237,27 @@ void D3D7CelestialSphere::Render(LPDIRECT3DDEVICE7 dev, const VECTOR3 &skyCol)
dev->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
dev->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);

// render ecliptic grid
if (renderFlag & PLN_EGRID) {
FVECTOR4 baseCol(0.0f, 0.0f, 0.4f, 1.0f);
RenderGrid(dev, baseCol, !(renderFlag & PLN_ECL));
// render galactic grid
if (renderFlag & PLN_GGRID) {
FVECTOR4 baseCol1(0.3f, 0.0f, 0.0f, 1.0f);
static const MATRIX3& R = Ecliptic_Galactic();
static D3DMATRIX T = { (float)R.m11, (float)R.m12, (float)R.m13, 0.0f,
(float)R.m21, (float)R.m22, (float)R.m23, 0.0f,
(float)R.m31, (float)R.m32, (float)R.m33, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &T);
RenderGrid(dev, baseCol1, false);
FVECTOR4 baseCol2(0.7f, 0.0f, 0.0f, 1.0f);
RenderGreatCircle(dev, baseCol2);
dev->SetTransform(D3DTRANSFORMSTATE_WORLD, &ident);
}

// render ecliptic equator
if (renderFlag & PLN_ECL) {
FVECTOR4 baseCol(0.0f, 0.0f, 0.8f, 1.0f);
RenderGreatCircle(dev, baseCol);
// render ecliptic grid
if (renderFlag & PLN_EGRID) {
FVECTOR4 baseCol1(0.0f, 0.0f, 0.4f, 1.0f);
RenderGrid(dev, baseCol1, false);
FVECTOR4 baseCol2(0.0f, 0.0f, 0.8f, 1.0f);
RenderGreatCircle(dev, baseCol2);
}

// render celestial grid
Expand Down Expand Up @@ -281,7 +292,7 @@ void D3D7CelestialSphere::Render(LPDIRECT3DDEVICE7 dev, const VECTOR3 &skyCol)
}

// render constellation boundaries
if (renderFlag & PLN_CONST) // for now, hijack the constellation line flag
if (renderFlag & PLN_CNSTBND) // for now, hijack the constellation line flag
RenderConstellationBoundaries(dev);

// render constellation lines
Expand Down
44 changes: 30 additions & 14 deletions OVP/D3D9Client/CelSphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ D3D9CelestialSphere::~D3D9CelestialSphere()

void D3D9CelestialSphere::InitCelestialTransform()
{
MATRIX3 R = Celestial2Ecliptic();
MATRIX3 R = Ecliptic_CelestialAtEpoch();

m_rotCelestial._11 = (float)R.m11; m_rotCelestial._12 = (float)R.m12; m_rotCelestial._13 = (float)R.m13; m_rotCelestial._14 = 0.0f;
m_rotCelestial._21 = (float)R.m21; m_rotCelestial._22 = (float)R.m22; m_rotCelestial._23 = (float)R.m23; m_rotCelestial._24 = 0.0f;
Expand Down Expand Up @@ -198,23 +198,39 @@ void D3D9CelestialSphere::Render(LPDIRECT3DDEVICE9 pDevice, const VECTOR3& skyCo
HR(s_FX->SetTechnique(s_eLine));
HR(s_FX->SetMatrix(s_eWVP, m_scene->GetProjectionViewMatrix()));

// render ecliptic grid
if (renderFlag & PLN_EGRID) {
FVECTOR4 baseCol(0.0f, 0.0f, 0.4f, 1.0f);
D3DXVECTOR4 vColor = ColorAdjusted(baseCol);
HR(s_FX->SetVector(s_eColor, &vColor));
RenderGrid(s_FX, !(renderFlag & PLN_ECL));
// render galactic grid
if (renderFlag & PLN_GGRID) {
static const MATRIX3& R = Ecliptic_Galactic();
static D3DXMATRIX T = { (float)R.m11, (float)R.m12, (float)R.m13, 0.0f,
(float)R.m21, (float)R.m22, (float)R.m23, 0.0f,
(float)R.m31, (float)R.m32, (float)R.m33, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
D3DXMATRIX rot;
D3DXMatrixMultiply(&rot, &T, m_scene->GetProjectionViewMatrix());
HR(s_FX->SetMatrix(s_eWVP, &rot));
FVECTOR4 baseCol1(0.3f, 0.0f, 0.0f, 1.0f);
D3DXVECTOR4 vColor1 = ColorAdjusted(baseCol1);
HR(s_FX->SetVector(s_eColor, &vColor1));
RenderGrid(s_FX, false);
FVECTOR4 baseCol2(0.7f, 0.0f, 0.0f, 1.0f);
D3DXVECTOR4 vColor2 = ColorAdjusted(baseCol2);
HR(s_FX->SetVector(s_eColor, &vColor2));
RenderGreatCircle(s_FX);
}

// render ecliptic equator
if (renderFlag & PLN_ECL) {
FVECTOR4 baseCol(0.0f, 0.0f, 0.8f, 1.0f);
D3DXVECTOR4 vColor = ColorAdjusted(baseCol);
HR(s_FX->SetVector(s_eColor, &vColor));
// render ecliptic grid
if (renderFlag & PLN_EGRID) {
FVECTOR4 baseCol1(0.0f, 0.0f, 0.4f, 1.0f);
D3DXVECTOR4 vColor1 = ColorAdjusted(baseCol1);
HR(s_FX->SetVector(s_eColor, &vColor1));
RenderGrid(s_FX, false);
FVECTOR4 baseCol2(0.0f, 0.0f, 0.8f, 1.0f);
D3DXVECTOR4 vColor2 = ColorAdjusted(baseCol2);
HR(s_FX->SetVector(s_eColor, &vColor2));
RenderGreatCircle(s_FX);
}

// render celestial grid ----------------------------------------------------------------------------
// render celestial grid
if (renderFlag & PLN_CGRID) {
if (fabs(m_mjdPrecessionChecked - oapiGetSimMJD()) > 1e3)
InitCelestialTransform();
Expand Down Expand Up @@ -254,7 +270,7 @@ void D3D9CelestialSphere::Render(LPDIRECT3DDEVICE9 pDevice, const VECTOR3& skyCo
}

// render constellation boundaries ----------------------------------------
if (renderFlag & PLN_CONST) { // for now, hijack the constellation line flag
if (renderFlag & PLN_CNSTBND) { // for now, hijack the constellation line flag
HR(s_FX->SetMatrix(s_eWVP, m_scene->GetProjectionViewMatrix()));
RenderConstellationBoundaries(s_FX);
}
Expand Down
44 changes: 22 additions & 22 deletions OVP/D3D9Client/OapiExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@
#include <psapi.h>

// ===========================================================================
// Orbiter [v110830] up to [v111105]
#define IDC_BODYFORCE_PAGE 231
#define IDC_BODYFORCE_ENABLE 1194
#define IDC_BODYFORCE_WEIGHT 1195
#define IDC_BODYFORCE_THRUST 1196
#define IDC_BODYFORCE_LIFT 1197
#define IDC_BODYFORCE_DRAG 1198
#define IDC_BODYFORCE_TOTAL 1199
#define IDC_BODYFORCE_TORQUE 1200
#define IDC_BODYFORCE_SCALE_LIN 1201
#define IDC_BODYFORCE_SCALE_LOG 1202
#define IDC_BODYFORCE_SCALE_GAUGE 1204
#define IDC_BODYFORCE_OPACITY_GAUGE 1205

#define IDC_SHOW_AXES_PAGE 233
#define IDC_SHOW_AXES_ENABLE 1206
#define IDC_SHOW_AXES_VESSEL 1207
#define IDC_SHOW_AXES_CELBODY 1208
#define IDC_SHOW_AXES_SURFBASE 1209
#define IDC_SHOW_AXES_NEGATIVE 1210
#define IDC_SHOW_AXES_SCALE_GAUGE 1211
#define IDC_SHOW_AXES_OPACITY_GAUGE 1212
// Orbiter [v110830] up to [v111105] up to [v221025]
#define IDC_BODYFORCE_PAGE 233
#define IDC_BODYFORCE_ENABLE 1819
#define IDC_BODYFORCE_WEIGHT 1820
#define IDC_BODYFORCE_THRUST 1821
#define IDC_BODYFORCE_LIFT 1822
#define IDC_BODYFORCE_DRAG 1823
#define IDC_BODYFORCE_TOTAL 1824
#define IDC_BODYFORCE_TORQUE 1825
#define IDC_BODYFORCE_SCALE_LIN 1826
#define IDC_BODYFORCE_SCALE_LOG 1827
#define IDC_BODYFORCE_SCALE_GAUGE 1828
#define IDC_BODYFORCE_OPACITY_GAUGE 1829

#define IDC_SHOW_AXES_PAGE 234
#define IDC_SHOW_AXES_ENABLE 1830
#define IDC_SHOW_AXES_VESSEL 1831
#define IDC_SHOW_AXES_CELBODY 1832
#define IDC_SHOW_AXES_SURFBASE 1833
#define IDC_SHOW_AXES_NEGATIVE 1834
#define IDC_SHOW_AXES_SCALE_GAUGE 1835
#define IDC_SHOW_AXES_OPACITY_GAUGE 1836

// Little binary helper
#define SETFLAG(bitmap, bit, value) (value ? bitmap |= bit : bitmap &= ~bit)
Expand Down
20 changes: 17 additions & 3 deletions Orbitersdk/include/CelSphereAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,24 @@ namespace oapi {
virtual bool EclDir2WindowPos(const VECTOR3& dir, int& x, int& y) const = 0;

/**
* \brief Returns the rotation matrix for mapping from celestial frame at epoch
* to J2000 ecliptic frame.
* \brief Returns the rotation matrix for mapping from J2000 ecliptic frame
* to celestial frame at current epoch.
*/
MATRIX3 Celestial2Ecliptic() const;
MATRIX3 Ecliptic_CelestialAtEpoch() const;

/**
* \brief Returns the rotation matrix for mapping from J2000 ecliptic frame
* to J2000 celestial frame.
*/
const MATRIX3& Ecliptic_CelestialJ2000() const;

/**
* \brief Returns the rotation matrix for mapping from galactic frame
* to J2000 celestial frame.
*/
const MATRIX3& CelestialJ2000_Galactic() const;

const MATRIX3& Ecliptic_Galactic() const;

void SetSkyColour(const VECTOR3& skyCol);
const VECTOR3& GetSkyColour() const { return m_skyCol; }
Expand Down
8 changes: 4 additions & 4 deletions Orbitersdk/include/GraphicsAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,17 @@ typedef void *HDC;
#define PLN_ENABLE 0x0001 ///< Enable planetarium mode (master flag)
#define PLN_CGRID 0x0002 ///< Enable celestial grid
#define PLN_EGRID 0x0004 ///< Enable ecliptic grid
#define PLN_ECL 0x0008 ///< Enable line of ecliptic
#define PLN_EQU 0x0010 ///< Enable celestial equator
#define PLN_CONST 0x0020 ///< Enable constellation lines
#define PLN_GGRID 0x0008 ///< Enable galactic grid
#define PLN_EQU 0x0010 ///< Enable target body equator
#define PLN_CONST 0x0020 ///< Enable constellation patterns
#define PLN_CNSTLABEL 0x0040 ///< Enable constellation labels
#define PLN_CMARK 0x0080 ///< Enable celestial body markers
#define PLN_VMARK 0x0100 ///< Enable vessel markers
#define PLN_BMARK 0x0200 ///< Enable surface base markers
#define PLN_RMARK 0x0400 ///< Enable VOR transmitter markers
#define PLN_LMARK 0x0800 ///< Enable planetary surface labels
#define PLN_CNSTLONG 0x1000 ///< Enable long constellation names
#define PLN_CNSTSHORT 0x2000 ///< Enable short constellation names
#define PLN_CNSTBND 0x2000 ///< Enable constellation boundaries
#define PLN_CCMARK 0x4000 ///< Enable celestial sphere labels
#define PLN_SURFMARK (PLN_BMARK | PLN_RMARK | PLN_LMARK)
/// @}
Expand Down
11 changes: 11 additions & 0 deletions Orbitersdk/include/OrbiterAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -7211,6 +7211,17 @@ inline MATRIX3 identity ()
return mat;
}

/**
* \ingroup vec
* \brief Return transpose of a matrix
*/
inline MATRIX3 transp(const MATRIX3& M)
{
return _M(M.m11, M.m21, M.m31,
M.m12, M.m22, M.m32,
M.m13, M.m23, M.m33);
}

/**
* \ingroup vec
* \brief Outer product of two vectors
Expand Down
Loading

0 comments on commit 0e51a10

Please sign in to comment.