Skip to content
Snippets Groups Projects
Commit b6a2f40b authored by Oliver Bock's avatar Oliver Bock
Browse files

Added the possibility for specializing engines to add their own observatories

* StarsphereRadio adds the Arecibo observatory (dish, struts and dome)
* Regular observatories (IFOs) can optionally be dimmed (factor 0.0-1.0)
* Had to move base class stuff from private to protected (subclass render support)
* Added more comments
parent 3d578b0e
No related branches found
No related tags found
No related merge requests found
......@@ -258,8 +258,12 @@ GLfloat Starsphere::RAofZenith(double T, GLfloat LONdeg)
/**
* Draw the observatories at their zenith positions
*/
void Starsphere::make_obs()
void Starsphere::generateObservatories(float dimFactor)
{
// sanity check
if(dimFactor < 0.0) dimFactor = 0.0;
if(dimFactor > 1.0) dimFactor = 1.0;
GLfloat Lat, Lon; // Latitute/Longitude of IFO is
GLfloat RAdeg, DEdeg; // converted to RA/DEC of sky sphere position
GLfloat radius; // radius of sphere for obs
......@@ -293,7 +297,7 @@ void Starsphere::make_obs()
LLOmarker = glGenLists(1);
glNewList(LLOmarker, GL_COMPILE);
glColor3f(0.0, 1.0, 0.0);
glColor3f(dimFactor * 0.0, dimFactor * 1.0, dimFactor * 0.0);
glLineWidth(lineSize);
glBegin(GL_LINE_STRIP);
......@@ -327,7 +331,7 @@ void Starsphere::make_obs()
LHOmarker = glGenLists(1);
glNewList(LHOmarker, GL_COMPILE);
glColor3f(0.0, 0.0, 1.0);
glColor3f(dimFactor * 0.0, dimFactor * 0.0, dimFactor * 1.0);
glLineWidth(lineSize);
glBegin(GL_LINE_STRIP);
......@@ -376,7 +380,7 @@ void Starsphere::make_obs()
GEOmarker = glGenLists(1);
glNewList(GEOmarker, GL_COMPILE);
glColor3f(1.0, 0.0, 0.0);
glColor3f(dimFactor * 1.0, dimFactor * 0.0, dimFactor * 0.0);
glLineWidth(lineSize);
glBegin(GL_LINE_STRIP);
......@@ -411,7 +415,7 @@ void Starsphere::make_obs()
VIRGOmarker = glGenLists(1);
glNewList(VIRGOmarker, GL_COMPILE);
glColor3f(1.0, 1.0, 1.0);
glColor3f(dimFactor * 1.0, dimFactor * 1.0, dimFactor * 1.0);
glLineWidth(lineSize);
glBegin(GL_LINE_STRIP);
......@@ -764,7 +768,6 @@ void Starsphere::initialize(const int width, const int height, const Resource *f
make_snrs();
make_axes();
make_globe();
make_obs();
glDisable(GL_CLIP_PLANE0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
......@@ -850,6 +853,7 @@ void Starsphere::render(const double timeOfDay)
glCallList(LHOmarker);
glCallList(GEOmarker);
glCallList(VIRGOmarker);
renderAdditionalObservatories();
glPopMatrix();
}
......@@ -909,6 +913,10 @@ void Starsphere::render(const double timeOfDay)
SDL_GL_SwapBuffers();
}
void Starsphere::renderAdditionalObservatories() {
// default implementation doesn't do anything
}
void Starsphere::mouseButtonEvent(const int positionX, const int positionY,
const AbstractGraphicsEngine::MouseButton buttonPressed)
{
......
......@@ -108,6 +108,12 @@ public:
* \param height The new height of the display surface
*/
virtual void resize(const int width, const int height);
/**
* \brief This method renders one frame of the animation
*
* \param timeOfDay The current time (e.g. BOINC's dtime(), used for time-based rendering evolution)
*/
void render(const double timeOfDay);
// event handling
......@@ -143,6 +149,20 @@ protected:
*/
virtual void renderSearchInformation() = 0;
/**
* \brief Render additional observatories
*
* This method doesn't do anything in its local implementation. It's provided
* for potential specializing classes to add additional observatories by
* overriding the empty default implementation.
*
* Important: overriding classes should just provide additional display lists
* by via calls to glCallList().
*
* \see StarsphereRadio::renderAdditionalObservatories()
*/
virtual void renderAdditionalObservatories();
/**
* \brief This method has to be called in order to update the BOINC client information
*
......@@ -154,6 +174,42 @@ protected:
*/
virtual void refreshLocalBOINCInformation();
/**
* \brief Generates the OpenGL call lists for the displayed observatories
*
* \param dimFactor A dim factor (range: 0 <= x <= 1) that will, well, dim the color
* of the observatories.
*/
virtual void generateObservatories(const float dimFactor);
// feature control
enum Features {
STARS = 1,
CONSTELLATIONS = 2,
OBSERVATORIES = 4,
XRAYS = 8,
PULSARS = 16,
SNRS = 32,
GLOBE = 64,
AXES = 128,
SEARCHINFO = 256,
LOGO = 512,
MARKER = 1024
};
void setFeature(const Features features, const bool enable);
bool isFeature(const Features features);
GLfloat RAofZenith(double T, GLfloat LONdeg);
void sphVertex3D(GLfloat RAdeg, GLfloat DEdeg, GLfloat radius);
void sphVertex(GLfloat RAdeg, GLfloat DEdeg);
GLfloat sphRadius;
// observatory movement
// (in seconds since 1970 with usec precision)
double m_ObservatoryDrawTimeLocal;
// resource handling
const Resource *m_FontResource;
OGLFT::TranslucentTexture *m_FontLogo1;
......@@ -187,14 +243,10 @@ private:
void make_pulsars();
void make_snrs();
void make_constellations();
void make_obs();
void make_axes();
void make_globe();
void make_search_marker(GLfloat RAdeg, GLfloat DEdeg, GLfloat size);
GLfloat RAofZenith(double T, GLfloat LONdeg);
void sphVertex3D(GLfloat RAdeg, GLfloat DEdeg, GLfloat radius);
void sphVertex(GLfloat RAdeg, GLfloat DEdeg);
void star_marker(float RAdeg, float DEdeg, float size);
/**
......@@ -206,9 +258,8 @@ private:
GLuint sphGrid, SNRs, SearchMarker;
/**
* Parameters and State info:
* State info:
*/
GLfloat sphRadius;
int featureFlags;
/**
......@@ -231,28 +282,6 @@ private:
// view control
void rotateSphere(const int relativeRotation, const int relativeElevation);
void zoomSphere(const int relativeZoom);
// feature control
enum Features {
STARS = 1,
CONSTELLATIONS = 2,
OBSERVATORIES = 4,
XRAYS = 8,
PULSARS = 16,
SNRS = 32,
GLOBE = 64,
AXES = 128,
SEARCHINFO = 256,
LOGO = 512,
MARKER = 1024
};
void setFeature(const Features features, const bool enable);
bool isFeature(const Features features);
// observatory movement
// (in seconds since 1970 with usec precision)
double m_ObservatoryDrawTimeLocal;
};
/* Constellation & star coordinates are in starlist.C */
......
......@@ -74,6 +74,9 @@ void StarsphereRadio::initialize(const int width, const int height, const Resour
// prepare power spectrum
generatePowerSpectrumCoordSystem(m_PowerSpectrumXPos, m_PowerSpectrumYPos);
// prepare base class observatories (dimmed to 33%)
generateObservatories(0.33);
}
void StarsphereRadio::resize(const int width, const int height)
......@@ -94,6 +97,10 @@ void StarsphereRadio::resize(const int width, const int height)
generatePowerSpectrumBins(m_PowerSpectrumXPos, m_PowerSpectrumYPos);
}
void StarsphereRadio::renderAdditionalObservatories() {
glCallList(m_areciboObservatory);
}
void StarsphereRadio::refreshBOINCInformation()
{
// call base class implementation
......@@ -300,3 +307,106 @@ void StarsphereRadio::generatePowerSpectrumBins(const int originX, const int ori
glEndList();
}
void StarsphereRadio::generateObservatories(float dimFactor)
{
// call base class implementation first
Starsphere::generateObservatories(dimFactor);
GLfloat Lat, Lon; // Latitute/Longitude of IFO is
GLfloat RAdeg, DEdeg; // converted to RA/DEC of sky sphere position
GLfloat radius; // radius of sphere for obs
double factorRadDeg = 1.0 / 57.29577957795135; // RAD/DEG conversion factor
GLfloat dishRadius = 1; // radius of the Arecibo telescope antenna
GLfloat domeRadius = 0.2; // radius of the Arecibo telescope receiver dome
// get current time and UTC offset (for zenith position)
m_ObservatoryDrawTimeLocal = dtime();
time_t local = m_ObservatoryDrawTimeLocal;
tm *utc = gmtime(&local);
double utcOffset = difftime(local, mktime(utc));
double observatoryDrawTimeGMT = m_ObservatoryDrawTimeLocal - utcOffset;
radius = 1.0*sphRadius; // radius of sphere on which they are drawn
/**
* Arecibo Observatory:
*/
Lat = 18.344167;
Lon = 66.752778;
RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon);
DEdeg= Lat;
// delete existing, create new (required for windoze)
if(m_areciboObservatory) glDeleteLists(m_areciboObservatory, 1);
m_areciboObservatory = glGenLists(1);
glNewList(m_areciboObservatory, GL_COMPILE);
// we don't dim Arecibo, just IFOs
glColor3f(0.75, 0.75, 0.75);
// lines used to draw triangles
glLineWidth(1.0);
// draw antenna dish
float originX = RAdeg;
float originY = DEdeg;
float vectorY1 = originY;
float vectorX1 = originX;
float vectorX;
float vectorY;
float angle;
// make sure both side are visible
glDisable(GL_CULL_FACE);
glBegin(GL_TRIANGLES);
for(int i=0; i <= 360; i++) {
angle = ((double)i) * factorRadDeg;
vectorX = originX + dishRadius * (float)sin(angle);
vectorY = originY + dishRadius * (float)cos(angle);
sphVertex(originX, originY);
sphVertex(vectorX1, vectorY1);
sphVertex(vectorX, vectorY);
vectorY1 = vectorY;
vectorX1 = vectorX;
}
glEnd();
// draw receiver dome
glColor3f(0.5, 0.5, 0.5);
glBegin(GL_TRIANGLES);
for(int i=0; i <= 360; i++) {
angle = ((double)i) * factorRadDeg;
vectorX = originX + domeRadius * (float)sin(angle);
vectorY = originY + domeRadius * (float)cos(angle);
sphVertex(originX, originY);
sphVertex(vectorX1, vectorY1);
sphVertex(vectorX, vectorY);
vectorY1 = vectorY;
vectorX1 = vectorX;
}
glEnd();
// enable culling again
glEnable(GL_CULL_FACE);
// draw receiver struts
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_LINES);
// north guide
sphVertex3D(RAdeg, DEdeg, radius);
sphVertex3D(RAdeg, DEdeg+1.0, radius);
glEnd();
glBegin(GL_LINE_STRIP);
// south-west & south-east guides:
sphVertex3D(RAdeg-0.7, DEdeg-0.7, radius);
sphVertex3D(RAdeg, DEdeg, radius);
sphVertex3D(RAdeg+0.7, DEdeg-0.7, radius);
glEnd();
glEndList();
}
......@@ -108,6 +108,14 @@ private:
*/
void renderSearchInformation();
/**
* \brief Renders the Arecibo observatory
*
* This specific implementation invokes a single display list rendering the
* Arecibo observatory. It overrides the (empty) base class implementation.
*/
void renderAdditionalObservatories();
/**
* \brief Creates an OpenGL call list which contains the static power spectrum coordinate system
*
......@@ -124,6 +132,16 @@ private:
*/
void generatePowerSpectrumBins(const int originX, const int originY);
/**
* \brief Generates the OpenGL call lists for the displayed observatories
*
* \param dimFactor A dim factor (range: 0 <= x <= 1) that will, well, dim the color
* of the observatories. Right now the factor is propagated to the base class
* implementation, hence dims the IFOs. The local Arecibo observatory is currently
* unaffected.
*/
void generateObservatories(const float dimFactor);
/// ID of the OpenGL call list which contains the static power spectrum coordinate system
GLuint m_PowerSpectrumCoordSystemList;
......@@ -234,6 +252,9 @@ private:
/// HUD configuration setting (vertical start position for the bottom part, line 6)
GLfloat m_Y6StartPosBottom;
/// Arecibo Observatory display list
GLuint m_areciboObservatory;
};
/**
......
......@@ -50,6 +50,9 @@ void StarsphereS5R3::initialize(const int width, const int height, const Resourc
m_Y3StartPosBottom = m_Y2StartPosBottom - m_YOffsetMedium;
m_Y4StartPosBottom = m_Y3StartPosBottom - m_YOffsetMedium;
}
// prepare base class observatories (not dimmed)
generateObservatories(1.0);
}
void StarsphereS5R3::resize(const int width, const int height)
......@@ -140,3 +143,9 @@ void StarsphereS5R3::renderSearchInformation()
m_FontText->draw(m_XStartPosRight, m_Y3StartPosBottom, m_WUPercentDone.c_str());
m_FontText->draw(m_XStartPosRight, m_Y4StartPosBottom, m_WUCPUTime.c_str());
}
void StarsphereS5R3::generateObservatories(float dimFactor)
{
// we don't do anything special here, just call base class
Starsphere::generateObservatories(dimFactor);
}
......@@ -101,6 +101,15 @@ private:
*/
void renderSearchInformation();
/**
* \brief Generates the OpenGL call lists for the displayed observatories
*
* \param dimFactor A dim factor (range: 0 <= x <= 1) that will, well, dim the color
* of the observatories. Right now the factor is propagated to the base class
* implementation, hence dims the IFOs.
*/
void generateObservatories(const float dimFactor);
/// Specialized BOINC client adapter instance for information retrieval
EinsteinS5R3Adapter m_EinsteinAdapter;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment