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

Simple fixed disk for source plane (removed obsolete pulsar beam cones)

parent a8002d68
No related branches found
No related tags found
No related merge requests found
......@@ -311,15 +311,15 @@ void PulsarAnimationWidget::paintGL()
}
glPopMatrix();
// enable wireframe mode
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
// back to solid rendering
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
// draw pulsar
// draw source
glPushMatrix();
{
glTranslatef(sin(m_orbitRotationAngle * deg2rad) * m_pulsarSemiMajorAxis,
0.0,
cos(m_orbitRotationAngle * deg2rad) * m_pulsarSemiMajorAxis);
glTranslatef(3.0,
3.0,
0.0);
glPushMatrix();
{
......@@ -349,189 +349,26 @@ void PulsarAnimationWidget::paintGL()
gluDisk(m_quadricPulsarSpinAxisTop2, 0, 0.020, 32, 8);
}
glPopMatrix();
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
}
// draw sphere, with proper lighting
glEnable(GL_LIGHTING);
glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
gluSphere(m_quadricPulsar, m_pulsarRadius, 32, 32);
glDisable(GL_LIGHTING);
}
glPopMatrix();
// 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) {
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glColor3f(1.0f, 1.0f, 0.0f);
glPushMatrix();
{
glTranslatef(0.0, 0.0, -4.5);
gluCylinder(m_quadricPulsarMagneticAxis, 0.020, 0.020, 9.0, 32, 1);
}
glPopMatrix();
glPushMatrix();
{
glTranslatef(0.0, 0.0, -4.5);
gluDisk(m_quadricPulsarSpinAxisTop1, 0, 0.020, 32, 8);
}
glPopMatrix();
glPushMatrix();
{
glTranslatef(0.0, 0.0, 4.5);
gluDisk(m_quadricPulsarSpinAxisTop2, 0, 0.020, 32, 8);
}
glPopMatrix();
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
}
glTranslatef(0.0, 0.0, -(m_pulsarBeamLength + m_pulsarRadius + 0.1));
// draw first cone's outer layer
glBegin(GL_TRIANGLE_FAN);
{
// Pinnacle of cone is shared vertex for fan, moved up z-axis
// to produce a cone instead of a circle
glColor4f(1.0f, 1.0f, 0.0f, 0.33f);
glVertex3f(0.0f, 0.0f, m_pulsarBeamLength);
// Loop around in a circle and specify even points along the circle
// as the vertices of the triangle fan (32 sections)
for(angle = 0.0f; angle < (2.0f*PI); angle += (PI/32.0f))
{
// Calculate x and y position of the next vertex
x = m_pulsarBeamOuterRadius * sin(angle);
y = m_pulsarBeamOuterRadius * cos(angle);
// Specify the next vertex for the triangle fan
glVertex2f(x, y);
}
}
glEnd();
// draw first cone's "base" (textured bottom to visualize beam intensity)
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
// create texture coordinates and enable texturing
gluQuadricTexture(m_quadricPulsarCone1Shell, GL_TRUE);
glBindTexture(GL_TEXTURE_2D, m_beamTexture);
glEnable(GL_TEXTURE_2D);
gluDisk(m_quadricPulsarCone1Shell, 0, m_pulsarBeamOuterRadius, 32, 1);
// disable texturing
glDisable(GL_TEXTURE_2D);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
}
glPopMatrix();
// second cone (pointing towards from camera)
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, -(m_pulsarBeamLength + m_pulsarRadius + 0.1));
// draw second cone's outer layer
glBegin(GL_TRIANGLE_FAN);
{
// Pinnacle of cone is shared vertex for fan, moved up z-axis
// to produce a cone instead of a circle
glColor4f(1.0f, 1.0f, 0.0f, 0.33f);
glVertex3f(0.0f, 0.0f, m_pulsarBeamLength);
// Loop around in a circle and specify even points along the circle
// as the vertices of the triangle fan (32 sections)
for(angle = 0.0f; angle < (2.0f*PI); angle += (PI/32.0f))
{
// Calculate x and y position of the next vertex
x = m_pulsarBeamOuterRadius * sin(angle);
y = m_pulsarBeamOuterRadius * cos(angle);
// Specify the next vertex for the triangle fan
glVertex2f(x, y);
}
}
glEnd();
// draw second cone's "base" (textured bottom to visualize beam intensity)
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
// create texture coordinates and enable texturing
gluQuadricTexture(m_quadricPulsarCone2Shell, GL_TRUE);
glBindTexture(GL_TEXTURE_2D, m_beamTexture);
glEnable(GL_TEXTURE_2D);
gluDisk(m_quadricPulsarCone2Shell, 0, m_pulsarBeamOuterRadius, 32, 1);
// disable texturing
glDisable(GL_TEXTURE_2D);
}
glPopMatrix();
}
glPopMatrix();
// back to solid rendering
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
// draw orbital planes
if(m_cameraInteraction || m_showOrbits) {
// draw disc
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
glEnable(GL_LIGHTING);
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,
0,
2,
64, 1);
}
glPopMatrix();
glDisable(GL_LIGHTING);
}
glPopMatrix();
}
glPopMatrix();
// save current state (the following is using parallel projection)
glMatrixMode(GL_PROJECTION);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment