Commit 3526540e authored by Oliver Bock's avatar Oliver Bock

Cleansed source (tabs->spaces, indentation, trailing whitespaces)

parent 88dcf497
......@@ -41,11 +41,11 @@ TS_DIR = src/resources
TRANSLATIONS = src/resources/pulsatingscience_de.ts
win32 {
RC_FILE = src/resources/pulsatingscience.rc
RC_FILE = src/resources/pulsatingscience.rc
}
macx {
QMAKE_LFLAGS += -bind_at_load
ICON = src/resources/pulsatingscience.icns
QMAKE_LFLAGS += -bind_at_load
ICON = src/resources/pulsatingscience.icns
}
INCLUDEPATH += ./
......@@ -55,18 +55,18 @@ MOC_DIR = src/.moc
OBJECTS_DIR = src/.obj
!isEmpty(TRANSLATIONS) {
isEmpty(QMAKE_LRELEASE) {
win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe
else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
isEmpty(QMAKE_LRELEASE) {
win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe
else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
isEmpty(TS_DIR):TS_DIR = translations
isEmpty(TS_DIR):TS_DIR = translations
linguist.name = lrelease ${QMAKE_FILE_IN}
linguist.input = TRANSLATIONS
linguist.output = $$TS_DIR/${QMAKE_FILE_BASE}.qm
linguist.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN}
linguist.CONFIG = no_link
QMAKE_EXTRA_COMPILERS += linguist
PRE_TARGETDEPS += compiler_linguist_make_all
linguist.name = lrelease ${QMAKE_FILE_IN}
linguist.input = TRANSLATIONS
linguist.output = $$TS_DIR/${QMAKE_FILE_BASE}.qm
linguist.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN}
linguist.CONFIG = no_link
QMAKE_EXTRA_COMPILERS += linguist
PRE_TARGETDEPS += compiler_linguist_make_all
}
......@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
PulsatingScience window;
if(argc == 2 && QString(argv[1]) == "--demo") {
window.toggleHiddenDemoMode();
window.toggleHiddenDemoMode();
}
window.show();
......
......@@ -23,33 +23,33 @@
const double PulsarAnimationWidget::deg2rad = PI/180.0;
PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
QGLWidget(QGLFormat(QGL::AlphaChannel | QGL::SampleBuffers), parent),
m_frameTimer(),
m_pulseProfile(360, 0.0)
QGLWidget(QGLFormat(QGL::AlphaChannel | QGL::SampleBuffers), parent),
m_frameTimer(),
m_pulseProfile(360, 0.0)
{
QString msgThis = tr("3D animation");
if(!format().directRendering()) {
QString msg = tr("Sorry, no direct rendering support for %1...");
qWarning() << msg.arg(msgThis);
}
if(!format().doubleBuffer()) {
QString msg = tr("Sorry, no double buffering support for %1...");
qWarning() << msg.arg(msgThis);
}
if(!format().rgba()) {
QString msg = tr("Sorry, no RGBA support for %1...");
qWarning() << msg.arg(msgThis);
}
if(!format().alpha()) {
QString msg = tr("Sorry, no alpha channel support for %1...");
qWarning() << msg.arg(msgThis);
}
if(!format().sampleBuffers()) {
QString msg = tr("Sorry, no multisampling support for %1...");
qWarning() << msg.arg(msgThis);
}
// connect primary rendering timer to local callback
QString msgThis = tr("3D animation");
if(!format().directRendering()) {
QString msg = tr("Sorry, no direct rendering support for %1...");
qWarning() << msg.arg(msgThis);
}
if(!format().doubleBuffer()) {
QString msg = tr("Sorry, no double buffering support for %1...");
qWarning() << msg.arg(msgThis);
}
if(!format().rgba()) {
QString msg = tr("Sorry, no RGBA support for %1...");
qWarning() << msg.arg(msgThis);
}
if(!format().alpha()) {
QString msg = tr("Sorry, no alpha channel support for %1...");
qWarning() << msg.arg(msgThis);
}
if(!format().sampleBuffers()) {
QString msg = tr("Sorry, no multisampling support for %1...");
qWarning() << msg.arg(msgThis);
}
// connect primary rendering timer to local callback
connect(&m_frameTimer, SIGNAL(timeout()), this, SLOT(updateFrame()));
// initialize quadric pointers
......@@ -57,103 +57,103 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
m_quadricCompanion = NULL;
m_quadricPulsarOrbitPlane = NULL;
m_quadricPulsar = NULL;
m_quadricPulsarCone1 = NULL;
m_quadricPulsarCone2 = NULL;
m_quadricPulsarSpinAxis = NULL;
m_quadricPulsarMagneticAxis = NULL;
// initialize texture pointers
m_pulsarTexture = 0;
m_backgroundTexture = 0;
// initial render timing settings
m_framesPerSecond = 25;
m_pulsarRotationDelta = 0.0;
m_orbitRotationDelta = 0.0;
m_pulsarRotationAngle = 0.0;
m_orbitRotationAngle = 0.0;
// initial binary system parameters (have to match GUI!)
m_pulsarMass = 1.4;
// initial companion is "Neutron Star"
m_companionMass = 1.4;
m_pulsarSpinAxisInclination = 0.0;
m_pulsarMagneticAxisInclination = 60.0;
m_pulsarSemiMajorAxis = 5.0;
m_companionSemiMajorAxis = (m_pulsarMass/m_companionMass) * m_pulsarSemiMajorAxis;
// initial spin frequency of 0.5 Hz
m_pulsarRotationDelta = (360.0 * 0.5) / m_framesPerSecond;
// update orbital period (based on settings above)
updateOrbitPeriod();
// initial view features
m_showOrbits = false;
m_showRotationAxes = false;
m_cameraInteraction = false;
// initial view settings
m_mouseAngleH = 90.0;
m_mouseAngleV = 30.0;
m_cameraZoom = 150.0;
m_cameraZoomLBound = 10.0;
m_cameraZoomUBound = 4500.0;
m_mouseLastX = 0;
m_mouseLastY = 0;
// update camera based on settings above
updateCameraPosition(m_mouseAngleH, m_mouseAngleV, m_cameraZoom);
m_quadricPulsarCone1 = NULL;
m_quadricPulsarCone2 = NULL;
m_quadricPulsarSpinAxis = NULL;
m_quadricPulsarMagneticAxis = NULL;
// initialize texture pointers
m_pulsarTexture = 0;
m_backgroundTexture = 0;
// initial render timing settings
m_framesPerSecond = 25;
m_pulsarRotationDelta = 0.0;
m_orbitRotationDelta = 0.0;
m_pulsarRotationAngle = 0.0;
m_orbitRotationAngle = 0.0;
// initial binary system parameters (have to match GUI!)
m_pulsarMass = 1.4;
// initial companion is "Neutron Star"
m_companionMass = 1.4;
m_pulsarSpinAxisInclination = 0.0;
m_pulsarMagneticAxisInclination = 60.0;
m_pulsarSemiMajorAxis = 5.0;
m_companionSemiMajorAxis = (m_pulsarMass/m_companionMass) * m_pulsarSemiMajorAxis;
// initial spin frequency of 0.5 Hz
m_pulsarRotationDelta = (360.0 * 0.5) / m_framesPerSecond;
// update orbital period (based on settings above)
updateOrbitPeriod();
// initial view features
m_showOrbits = false;
m_showRotationAxes = false;
m_cameraInteraction = false;
// initial view settings
m_mouseAngleH = 90.0;
m_mouseAngleV = 30.0;
m_cameraZoom = 150.0;
m_cameraZoomLBound = 10.0;
m_cameraZoomUBound = 4500.0;
m_mouseLastX = 0;
m_mouseLastY = 0;
// update camera based on settings above
updateCameraPosition(m_mouseAngleH, m_mouseAngleV, m_cameraZoom);
}
PulsarAnimationWidget::~PulsarAnimationWidget()
{
if(m_quadricCompanionOrbitPlane) gluDeleteQuadric(m_quadricCompanionOrbitPlane);
if(m_quadricCompanion) gluDeleteQuadric(m_quadricCompanion);
if(m_quadricPulsarOrbitPlane) gluDeleteQuadric(m_quadricPulsarOrbitPlane);
if(m_quadricPulsar) gluDeleteQuadric(m_quadricPulsar);
if(m_quadricPulsarCone1) gluDeleteQuadric(m_quadricPulsarCone1);
if(m_quadricPulsarCone2) gluDeleteQuadric(m_quadricPulsarCone2);
if(m_quadricPulsarSpinAxis) gluDeleteQuadric(m_quadricPulsarSpinAxis);
if(m_quadricPulsarMagneticAxis) gluDeleteQuadric(m_quadricPulsarMagneticAxis);
if(m_pulsarTexture) deleteTexture(m_pulsarTexture);
if(m_backgroundTexture) deleteTexture(m_backgroundTexture);
if(m_quadricCompanionOrbitPlane) gluDeleteQuadric(m_quadricCompanionOrbitPlane);
if(m_quadricCompanion) gluDeleteQuadric(m_quadricCompanion);
if(m_quadricPulsarOrbitPlane) gluDeleteQuadric(m_quadricPulsarOrbitPlane);
if(m_quadricPulsar) gluDeleteQuadric(m_quadricPulsar);
if(m_quadricPulsarCone1) gluDeleteQuadric(m_quadricPulsarCone1);
if(m_quadricPulsarCone2) gluDeleteQuadric(m_quadricPulsarCone2);
if(m_quadricPulsarSpinAxis) gluDeleteQuadric(m_quadricPulsarSpinAxis);
if(m_quadricPulsarMagneticAxis) gluDeleteQuadric(m_quadricPulsarMagneticAxis);
if(m_pulsarTexture) deleteTexture(m_pulsarTexture);
if(m_backgroundTexture) deleteTexture(m_backgroundTexture);
}
void PulsarAnimationWidget::initializeGL()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
GLfloat LightAmbient[] = {0.3, 0.3, 0.3, 1.0};
GLfloat LightDiffuse[] = {1.0, 1.0, 1.0, 1.0};
GLfloat LightSpecular[] = {1.0, 1.0, 1.0, 1.0};
GLfloat LightPosition[] = {0.0, 0.0, 3.0, 1.0};
GLfloat spot_direction[] = {0.0, 0.0, -1.0};
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpecular);
glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 50.0);
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spot_direction);
glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 10.0);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
m_quadricCompanionOrbitPlane = gluNewQuadric();
m_quadricCompanion = gluNewQuadric();
m_quadricPulsarOrbitPlane = gluNewQuadric();
m_quadricPulsar = gluNewQuadric();
glClearColor(0.0, 0.0, 0.0, 0.0);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
GLfloat LightAmbient[] = {0.3, 0.3, 0.3, 1.0};
GLfloat LightDiffuse[] = {1.0, 1.0, 1.0, 1.0};
GLfloat LightSpecular[] = {1.0, 1.0, 1.0, 1.0};
GLfloat LightPosition[] = {0.0, 0.0, 3.0, 1.0};
GLfloat spot_direction[] = {0.0, 0.0, -1.0};
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpecular);
glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 50.0);
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spot_direction);
glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 10.0);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
m_quadricCompanionOrbitPlane = gluNewQuadric();
m_quadricCompanion = gluNewQuadric();
m_quadricPulsarOrbitPlane = gluNewQuadric();
m_quadricPulsar = gluNewQuadric();
m_quadricPulsarCone1 = gluNewQuadric();
m_quadricPulsarCone2 = gluNewQuadric();
m_quadricPulsarSpinAxis = gluNewQuadric();
......@@ -180,37 +180,37 @@ void PulsarAnimationWidget::initializeGL()
// prepare and check pulsar texture
QImage pulsarTexture(":/textures/resources/texture_pulsar.png");
if(pulsarTexture.width() != pulsarTexture.height()) {
qWarning() << msgShape.arg(tr("Pulsar"));
qWarning() << msgShape.arg(tr("Pulsar"));
}
else {
double integer = 0.0;
double fraction = 0.0;
fraction = modf(log(pulsarTexture.width()) / log(2.0), &integer);
if(fraction > 0.0) {
qWarning() << msgPower.arg(tr("Pulsar"));
}
double integer = 0.0;
double fraction = 0.0;
fraction = modf(log(pulsarTexture.width()) / log(2.0), &integer);
if(fraction > 0.0) {
qWarning() << msgPower.arg(tr("Pulsar"));
}
}
if(pulsarTexture.width() > maxTextureSize) {
qWarning() << msgSize.arg(tr("pulsar").arg(maxTextureSize).arg(maxTextureSize));
pulsarTexture = pulsarTexture.scaled(maxTextureSize, maxTextureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
qWarning() << msgSize.arg(tr("pulsar").arg(maxTextureSize).arg(maxTextureSize));
pulsarTexture = pulsarTexture.scaled(maxTextureSize, maxTextureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
// prepare and check background texture
QImage backgroundTexture(":/textures/resources/texture_background_carina.png");
if(backgroundTexture.width() != backgroundTexture.height()) {
qWarning() << msgShape.arg(tr("Background"));
qWarning() << msgShape.arg(tr("Background"));
}
else {
double integer = 0.0;
double fraction = 0.0;
fraction = modf(log(backgroundTexture.width()) / log(2.0), &integer);
if(fraction > 0.0) {
qWarning() << msgPower.arg(tr("Background"));
}
double integer = 0.0;
double fraction = 0.0;
fraction = modf(log(backgroundTexture.width()) / log(2.0), &integer);
if(fraction > 0.0) {
qWarning() << msgPower.arg(tr("Background"));
}
}
if(backgroundTexture.width() > maxTextureSize) {
qWarning() << msgSize.arg(tr("background").arg(maxTextureSize).arg(maxTextureSize));
backgroundTexture = backgroundTexture.scaled(maxTextureSize, maxTextureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
qWarning() << msgSize.arg(tr("background").arg(maxTextureSize).arg(maxTextureSize));
backgroundTexture = backgroundTexture.scaled(maxTextureSize, maxTextureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
// bind textures
......@@ -228,428 +228,426 @@ void PulsarAnimationWidget::initializeGL()
void PulsarAnimationWidget::resizeGL(int w, int h)
{
glViewport(0, 0, w, h);
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(4.5, (GLfloat)w / (GLfloat)h, 0.1, 5000.0);
gluPerspective(4.5, (GLfloat)w / (GLfloat)h, 0.1, 5000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void PulsarAnimationWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(m_cameraPosX, m_cameraPosY, m_cameraPosZ,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
// TODO: should be located elsewhere
static GLfloat no_mat[] = {0.0, 0.0, 0.0, 1.0};
static GLfloat mat_diffuse[] = {0.5, 0.5, 0.5, 1.0};
static GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
static GLfloat low_shininess[] = {2.5};
static GLfloat translucent[] = {1.0, 1.0, 1.0, 0.33};
glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess);
glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
// draw companion
glPushMatrix();
glTranslatef(sin((m_orbitRotationAngle + 180.0) * deg2rad) * m_companionSemiMajorAxis,
0.0,
cos((m_orbitRotationAngle + 180.0) * deg2rad) * m_companionSemiMajorAxis);
gluSphere(m_quadricCompanion, 1.0, 32, 32);
glPopMatrix();
// draw pulsar
glPushMatrix();
glTranslatef(sin(m_orbitRotationAngle * deg2rad) * m_pulsarSemiMajorAxis,
0.0,
cos(m_orbitRotationAngle * deg2rad) * m_pulsarSemiMajorAxis);
glPushMatrix();
glRotatef(m_pulsarSpinAxisInclination, 0.0, 0.0, 1.0);
glRotatef(m_pulsarRotationAngle, 0.0, 1.0, 0.0);
// draw spin axis
if(m_showRotationAxes) {
glPushMatrix();
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
glRotatef(90.0, 1.0, 0.0, 0.0);
glTranslatef(0.0, 0.0, -5.0);
gluCylinder(m_quadricPulsarSpinAxis, 0.05, 0.05, 10.0, 32, 1);
glPopMatrix();
}
// create texture coordinates and enable texturing
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glBindTexture(GL_TEXTURE_2D, m_pulsarTexture);
glEnable(GL_TEXTURE_2D);
glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
gluSphere(m_quadricPulsar, 1.0, 32, 32);
// disable texturing
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_2D);
glPopMatrix();
// TODO: should be located elsewhere
static GLfloat coneAmbient[] = {1.0, 1.0, 0.0, 1.0};
static GLfloat coneDiffuse[] = {1.0, 1.0, 0.0, 1.0};
static GLfloat coneSpecular[] = {1.0, 1.0, 0.5, 1.0};
glMaterialfv(GL_FRONT, GL_SPECULAR, coneSpecular);
// first cone
glPushMatrix();
glRotatef(90.0, 1.0, 0.0, 0.0);
glRotatef(m_pulsarSpinAxisInclination, 0.0, 1.0, 0.0);
glRotatef(-m_pulsarRotationAngle - 90.0, 0.0, 0.0, 1.0);
glRotatef(-m_pulsarMagneticAxisInclination, 1.0, 0.0, 0.0);
// draw magnetic axis (for both cones)
if(m_showRotationAxes) {
glPushMatrix();
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
glTranslatef(0.0, 0.0, -5.0);
gluCylinder(m_quadricPulsarMagneticAxis, 0.05, 0.05, 10.0, 32, 1);
glPopMatrix();
}
glTranslatef(0.0, 0.0, -4.0);
glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse);
gluCylinder(m_quadricPulsarCone1, 0.475, 0.0, 3.0, 32, 32);
glPopMatrix();
// second cone
glPushMatrix();
glRotatef(-90.0, 1.0, 0.0, 0.0);
glRotatef(-m_pulsarSpinAxisInclination, 0.0, 1.0, 0.0);
glRotatef(m_pulsarRotationAngle - 90.0, 0.0, 0.0, 1.0);
glRotatef(m_pulsarMagneticAxisInclination, 1.0, 0.0, 0.0);
glTranslatef(0.0, 0.0, -4.0);
glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse);
gluCylinder(m_quadricPulsarCone2, 0.475, 0.0, 3.0, 32, 32);
glPopMatrix();
glPopMatrix();
// save current state
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, width(), 0, height(), 0.1, 501.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
// draw backdrop (independent parallel projection)
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat_specular);
glTranslatef(0.0, 0.0, -501.0);
drawTexture(QPointF(0.0, 0.0), m_backgroundTexture);
// restore original state
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
// draw orbital planes
if(m_cameraInteraction || m_showOrbits) {
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
static double sizeOffset = 0.25;
// companion's plane (only if not identical with pulsar's)
if(m_companionSemiMajorAxis != m_pulsarSemiMajorAxis) {
glPushMatrix();
glRotatef(90.0, 1.0, 0.0, 0.0);
// separate them slightly in case of overlap
// based on ugly mass diff check (no collision detection)
// single known problematic pair: (m_c=1.4, m_p=1.5)
if((int)(10*(m_pulsarMass-m_companionMass)+0.5) == 1){
glTranslatef(0.0, 0.0, 0.01);
}
gluDisk(m_quadricCompanionOrbitPlane,
m_companionSemiMajorAxis - sizeOffset,
m_companionSemiMajorAxis + sizeOffset,
64, 1);
glPopMatrix();
}
// pulsar's plane
glPushMatrix();
glRotatef(90.0, 1.0, 0.0, 0.0);
gluDisk(m_quadricPulsarOrbitPlane,
m_pulsarSemiMajorAxis - sizeOffset,
m_pulsarSemiMajorAxis + sizeOffset,
64, 1);
glPopMatrix();
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(m_cameraPosX, m_cameraPosY, m_cameraPosZ,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
// TODO: should be located elsewhere
static GLfloat no_mat[] = {0.0, 0.0, 0.0, 1.0};
static GLfloat mat_diffuse[] = {0.5, 0.5, 0.5, 1.0};
static GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
static GLfloat low_shininess[] = {2.5};
static GLfloat translucent[] = {1.0, 1.0, 1.0, 0.33};
glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess);
glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
// draw companion
glPushMatrix();
glTranslatef(sin((m_orbitRotationAngle + 180.0) * deg2rad) * m_companionSemiMajorAxis,
0.0,
cos((m_orbitRotationAngle + 180.0) * deg2rad) * m_companionSemiMajorAxis);
gluSphere(m_quadricCompanion, 1.0, 32, 32);
glPopMatrix();
// draw pulsar
glPushMatrix();
glTranslatef(sin(m_orbitRotationAngle * deg2rad) * m_pulsarSemiMajorAxis,
0.0,
cos(m_orbitRotationAngle * deg2rad) * m_pulsarSemiMajorAxis);
glPushMatrix();
glRotatef(m_pulsarSpinAxisInclination, 0.0, 0.0, 1.0);
glRotatef(m_pulsarRotationAngle, 0.0, 1.0, 0.0);
// draw spin axis
if(m_showRotationAxes) {
glPushMatrix();
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
glRotatef(90.0, 1.0, 0.0, 0.0);
glTranslatef(0.0, 0.0, -5.0);
gluCylinder(m_quadricPulsarSpinAxis, 0.05, 0.05, 10.0, 32, 1);
glPopMatrix();
}
// create texture coordinates and enable texturing
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glBindTexture(GL_TEXTURE_2D, m_pulsarTexture);
glEnable(GL_TEXTURE_2D);
glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
gluSphere(m_quadricPulsar, 1.0, 32, 32);
// disable texturing
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);