Commit 5d8927f0 authored by Oliver Bock's avatar Oliver Bock

Enclosed glPushMatrix in blocks to help formatter

parent 3526540e
...@@ -265,113 +265,129 @@ void PulsarAnimationWidget::paintGL() ...@@ -265,113 +265,129 @@ void PulsarAnimationWidget::paintGL()
// draw companion // draw companion
glPushMatrix(); glPushMatrix();
glTranslatef(sin((m_orbitRotationAngle + 180.0) * deg2rad) * m_companionSemiMajorAxis, {
0.0, glTranslatef(sin((m_orbitRotationAngle + 180.0) * deg2rad) * m_companionSemiMajorAxis,
cos((m_orbitRotationAngle + 180.0) * deg2rad) * m_companionSemiMajorAxis); 0.0,
gluSphere(m_quadricCompanion, 1.0, 32, 32); cos((m_orbitRotationAngle + 180.0) * deg2rad) * m_companionSemiMajorAxis);
gluSphere(m_quadricCompanion, 1.0, 32, 32);
}
glPopMatrix(); glPopMatrix();
// draw pulsar // draw pulsar
glPushMatrix(); glPushMatrix();
glTranslatef(sin(m_orbitRotationAngle * deg2rad) * m_pulsarSemiMajorAxis, {
0.0, glTranslatef(sin(m_orbitRotationAngle * deg2rad) * m_pulsarSemiMajorAxis,
cos(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(); glPushMatrix();
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent); {
glRotatef(90.0, 1.0, 0.0, 0.0); glRotatef(m_pulsarSpinAxisInclination, 0.0, 0.0, 1.0);
glTranslatef(0.0, 0.0, -5.0); glRotatef(m_pulsarRotationAngle, 0.0, 1.0, 0.0);
gluCylinder(m_quadricPulsarSpinAxis, 0.05, 0.05, 10.0, 32, 1);
glPopMatrix(); // draw spin axis
} if(m_showRotationAxes) {
glPushMatrix();
// create texture coordinates and enable texturing {
glEnable(GL_TEXTURE_GEN_S); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
glEnable(GL_TEXTURE_GEN_T); glRotatef(90.0, 1.0, 0.0, 0.0);
glBindTexture(GL_TEXTURE_2D, m_pulsarTexture); glTranslatef(0.0, 0.0, -5.0);
glEnable(GL_TEXTURE_2D); gluCylinder(m_quadricPulsarSpinAxis, 0.05, 0.05, 10.0, 32, 1);
}
glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); glPopMatrix();
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); }
gluSphere(m_quadricPulsar, 1.0, 32, 32);
// disable texturing // create texture coordinates and enable texturing
glDisable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_pulsarTexture);
glPopMatrix(); glEnable(GL_TEXTURE_2D);
// TODO: should be located elsewhere glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
static GLfloat coneAmbient[] = {1.0, 1.0, 0.0, 1.0}; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
static GLfloat coneDiffuse[] = {1.0, 1.0, 0.0, 1.0}; gluSphere(m_quadricPulsar, 1.0, 32, 32);
static GLfloat coneSpecular[] = {1.0, 1.0, 0.5, 1.0};
glMaterialfv(GL_FRONT, GL_SPECULAR, coneSpecular); // disable texturing
glDisable(GL_TEXTURE_GEN_S);
// first cone glDisable(GL_TEXTURE_GEN_T);
glPushMatrix(); glDisable(GL_TEXTURE_2D);
glRotatef(90.0, 1.0, 0.0, 0.0); }
glRotatef(m_pulsarSpinAxisInclination, 0.0, 1.0, 0.0); glPopMatrix();
glRotatef(-m_pulsarRotationAngle - 90.0, 0.0, 0.0, 1.0); // TODO: should be located elsewhere
glRotatef(-m_pulsarMagneticAxisInclination, 1.0, 0.0, 0.0); 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};
// draw magnetic axis (for both cones) // first cone
if(m_showRotationAxes) {
glPushMatrix(); glPushMatrix();
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent); {
glTranslatef(0.0, 0.0, -5.0); glRotatef(90.0, 1.0, 0.0, 0.0);
gluCylinder(m_quadricPulsarMagneticAxis, 0.05, 0.05, 10.0, 32, 1); glRotatef(m_pulsarSpinAxisInclination, 0.0, 1.0, 0.0);
glPopMatrix();
} 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); glTranslatef(0.0, 0.0, -4.0);
glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient); glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse); glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse);
gluCylinder(m_quadricPulsarCone1, 0.475, 0.0, 3.0, 32, 32); gluCylinder(m_quadricPulsarCone1, 0.475, 0.0, 3.0, 32, 32);
glPopMatrix(); }
glPopMatrix();
// second cone // second cone
glPushMatrix(); glPushMatrix();
glRotatef(-90.0, 1.0, 0.0, 0.0); {
glRotatef(-m_pulsarSpinAxisInclination, 0.0, 1.0, 0.0); 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_pulsarRotationAngle - 90.0, 0.0, 0.0, 1.0);
glRotatef(m_pulsarMagneticAxisInclination, 1.0, 0.0, 0.0); glRotatef(m_pulsarMagneticAxisInclination, 1.0, 0.0, 0.0);
glTranslatef(0.0, 0.0, -4.0); glTranslatef(0.0, 0.0, -4.0);
glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient); glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse); glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse);
gluCylinder(m_quadricPulsarCone2, 0.475, 0.0, 3.0, 32, 32); gluCylinder(m_quadricPulsarCone2, 0.475, 0.0, 3.0, 32, 32);
glPopMatrix(); }
glPopMatrix();
}
glPopMatrix(); glPopMatrix();
// save current state // save current state
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); {
glOrtho(0, width(), 0, height(), 0.1, 501.0); glLoadIdentity();
glMatrixMode(GL_MODELVIEW); glOrtho(0, width(), 0, height(), 0.1, 501.0);
glPushMatrix(); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glPushMatrix();
{
glLoadIdentity();
// draw backdrop (independent parallel projection) // draw backdrop (independent parallel projection)
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat_specular); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat_specular);
glTranslatef(0.0, 0.0, -501.0); glTranslatef(0.0, 0.0, -501.0);
drawTexture(QPointF(0.0, 0.0), m_backgroundTexture); drawTexture(QPointF(0.0, 0.0), m_backgroundTexture);
// restore original state // restore original state
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPopMatrix(); }
glMatrixMode(GL_MODELVIEW); glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
glPopMatrix(); glPopMatrix();
// draw orbital planes // draw orbital planes
...@@ -383,29 +399,33 @@ void PulsarAnimationWidget::paintGL() ...@@ -383,29 +399,33 @@ void PulsarAnimationWidget::paintGL()
// companion's plane (only if not identical with pulsar's) // companion's plane (only if not identical with pulsar's)
if(m_companionSemiMajorAxis != m_pulsarSemiMajorAxis) { if(m_companionSemiMajorAxis != m_pulsarSemiMajorAxis) {
glPushMatrix(); glPushMatrix();
glRotatef(90.0, 1.0, 0.0, 0.0); {
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) // separate them slightly in case of overlap
// single known problematic pair: (m_c=1.4, m_p=1.5) // based on ugly mass diff check (no collision detection)
if((int)(10*(m_pulsarMass-m_companionMass)+0.5) == 1){ // single known problematic pair: (m_c=1.4, m_p=1.5)
glTranslatef(0.0, 0.0, 0.01); 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);
} }
gluDisk(m_quadricCompanionOrbitPlane,
m_companionSemiMajorAxis - sizeOffset,
m_companionSemiMajorAxis + sizeOffset,
64, 1);
glPopMatrix(); glPopMatrix();
} }
// pulsar's plane // pulsar's plane
glPushMatrix(); glPushMatrix();
glRotatef(90.0, 1.0, 0.0, 0.0); {
gluDisk(m_quadricPulsarOrbitPlane, glRotatef(90.0, 1.0, 0.0, 0.0);
m_pulsarSemiMajorAxis - sizeOffset, gluDisk(m_quadricPulsarOrbitPlane,
m_pulsarSemiMajorAxis + sizeOffset, m_pulsarSemiMajorAxis - sizeOffset,
64, 1); m_pulsarSemiMajorAxis + sizeOffset,
64, 1);
}
glPopMatrix(); glPopMatrix();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment