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

Enclosed glPushMatrix in blocks to help formatter

parent 3526540e
......@@ -265,29 +265,35 @@ void PulsarAnimationWidget::paintGL()
// 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();
}
......@@ -305,6 +311,7 @@ void PulsarAnimationWidget::paintGL()
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_2D);
}
glPopMatrix();
// TODO: should be located elsewhere
......@@ -312,10 +319,9 @@ void PulsarAnimationWidget::paintGL()
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);
......@@ -325,9 +331,11 @@ void PulsarAnimationWidget::paintGL()
// 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();
}
......@@ -336,10 +344,12 @@ void PulsarAnimationWidget::paintGL()
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);
......@@ -351,16 +361,20 @@ void PulsarAnimationWidget::paintGL()
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)
......@@ -370,8 +384,10 @@ void PulsarAnimationWidget::paintGL()
// restore original state
glMatrixMode(GL_PROJECTION);
}
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
glPopMatrix();
// draw orbital planes
......@@ -383,6 +399,7 @@ void PulsarAnimationWidget::paintGL()
// 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
......@@ -396,16 +413,19 @@ void PulsarAnimationWidget::paintGL()
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();
}
}
......
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