Commit 9154cfc0 authored by Oliver Bock's avatar Oliver Bock

Added visualizations for spin and magnetic axes

parent 99d8f06e
......@@ -42,9 +42,12 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
m_quadricPulsar = NULL;
m_quadricPulsarCone1 = NULL;
m_quadricPulsarCone2 = NULL;
m_quadricPulsarSpinAxis = NULL;
m_quadricPulsarMagneticAxis1 = NULL;
m_quadricPulsarMagneticAxis2 = NULL;
m_pulsarTexture = NULL;
m_backgroundTexture = NULL;
m_pulsarTexture = 0;
m_backgroundTexture = 0;
m_framesPerSecond = 25;
......@@ -67,6 +70,9 @@ PulsarAnimationWidget::~PulsarAnimationWidget()
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_quadricPulsarMagneticAxis1) gluDeleteQuadric(m_quadricPulsarMagneticAxis1);
if(m_quadricPulsarMagneticAxis2) gluDeleteQuadric(m_quadricPulsarMagneticAxis2);
if(m_pulsarTexture) deleteTexture(m_pulsarTexture);
if(m_backgroundTexture) deleteTexture(m_backgroundTexture);
......@@ -107,10 +113,17 @@ void PulsarAnimationWidget::initializeGL()
m_quadricPulsar = gluNewQuadric();
m_quadricPulsarCone1 = gluNewQuadric();
m_quadricPulsarCone2 = gluNewQuadric();
m_quadricPulsarSpinAxis = gluNewQuadric();
m_quadricPulsarMagneticAxis1 = gluNewQuadric();
m_quadricPulsarMagneticAxis2 = gluNewQuadric();
gluQuadricNormals(m_quadricPulsarOrbitPlane, GLU_SMOOTH);
gluQuadricNormals(m_quadricPulsar, GLU_SMOOTH);
gluQuadricNormals(m_quadricPulsarCone1, GLU_SMOOTH);
gluQuadricNormals(m_quadricPulsarCone2, GLU_SMOOTH);
gluQuadricNormals(m_quadricPulsarSpinAxis, GLU_SMOOTH);
gluQuadricNormals(m_quadricPulsarMagneticAxis1, GLU_SMOOTH);
gluQuadricNormals(m_quadricPulsarMagneticAxis2, GLU_SMOOTH);
// load textures
m_pulsarTexture = bindTexture(QImage(":/textures/resources/texture_pulsar.png"), GL_TEXTURE_2D, GL_RGBA);
......@@ -154,6 +167,7 @@ void PulsarAnimationWidget::paintGL()
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);
......@@ -175,14 +189,27 @@ void PulsarAnimationWidget::paintGL()
glPushMatrix();
// enable texture coordinates and bind texture
glEnable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glBindTexture(GL_TEXTURE_2D, m_pulsarTexture);
if(m_cameraInteraction) {
glPushMatrix();
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
glRotatef(90.0, 1.0f, 0.0f, 0.0f);
glRotatef(-m_pulsarSpinAxisInclination, 0.0f, 1.0f, 0.0f);
glTranslatef(0.0f, 0.0f, -5.0f);
gluCylinder(m_quadricPulsarSpinAxis, 0.05f, 0.05f, 10.0f, 32, 1);
glPopMatrix();
}
// FIXME: how to rotate texture?
glRotatef(m_pulsarRotationAngle, 0.0f, 1.0f, 0.0f);
glRotatef(m_pulsarSpinAxisInclination, 1.0f, 0.0f, 0.0f);
glEnable(GL_TEXTURE_2D);
glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
gluSphere(m_quadricPulsar, 1.0f, 32, 32);
// disable texture coordinates
......@@ -196,28 +223,43 @@ 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_AMBIENT, coneAmbient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, coneSpecular);
glPushMatrix();
glRotatef(m_pulsarRotationAngle - 90.0f, 0.0f, 1.0f, 0.0f);
glRotatef(-m_pulsarMagneticAxisInclination - m_pulsarSpinAxisInclination + 90.0f, 1.0f, 0.0f, 0.0f);
if(m_cameraInteraction) {
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
gluCylinder(m_quadricPulsarMagneticAxis1, 0.05f, 0.05f, 5.0f, 32, 1);
}
glTranslatef(0.0f, 0.0f, -4.0f);
glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse);
gluCylinder(m_quadricPulsarCone1, 0.5f, 0.0f, 3.0f, 32, 32);
glPopMatrix();
glPushMatrix();
glRotatef(m_pulsarRotationAngle + 90.0f, 0.0f, 1.0f, 0.0f);
glRotatef(m_pulsarMagneticAxisInclination + m_pulsarSpinAxisInclination - 90.0f, 1.0f, 0.0f, 0.0f);
if(m_cameraInteraction) {
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
gluCylinder(m_quadricPulsarMagneticAxis2, 0.05f, 0.05f, 5.0f, 32, 1);
}
glTranslatef(0.0f, 0.0f, -4.0f);
glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse);
gluCylinder(m_quadricPulsarCone2, 0.5f, 0.0f, 3.0f, 32, 32);
glPopMatrix();
glPopMatrix();
if(m_cameraInteraction) {
static GLfloat pulsarOrbitAmbientDiffuse[] = { 1.0, 1.0, 1.0, 0.33 };
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, pulsarOrbitAmbientDiffuse);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
glPushMatrix();
glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
......
......@@ -70,6 +70,9 @@ protected:
GLUquadricObj *m_quadricPulsar;
GLUquadricObj *m_quadricPulsarCone1;
GLUquadricObj *m_quadricPulsarCone2;
GLUquadricObj *m_quadricPulsarSpinAxis;
GLUquadricObj *m_quadricPulsarMagneticAxis1;
GLUquadricObj *m_quadricPulsarMagneticAxis2;
GLuint m_pulsarTexture;
GLuint m_backgroundTexture;
......
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