diff --git a/src/pulsaranimationwidget.cpp b/src/pulsaranimationwidget.cpp
index 630f2c8818c57f16a90b8f05e11a47dde6bd7d71..7a201285b1fd8cd0504fb085d4839a36f41a80fd 100644
--- a/src/pulsaranimationwidget.cpp
+++ b/src/pulsaranimationwidget.cpp
@@ -70,6 +70,7 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
// initialize texture pointers
m_backgroundTexture = 0;
+ m_beamTexture = 0;
// initial render timing settings
m_framesPerSecond = 25;
@@ -118,6 +119,7 @@ PulsarAnimationWidget::~PulsarAnimationWidget()
if(m_quadricLineOfSightCone) gluDeleteQuadric(m_quadricLineOfSightCone);
if(m_quadricLineOfSightConeBase) gluDeleteQuadric(m_quadricLineOfSightConeBase);
if(m_backgroundTexture) deleteTexture(m_backgroundTexture);
+ if(m_beamTexture) deleteTexture(m_beamTexture);
}
void PulsarAnimationWidget::initializeGL()
@@ -202,16 +204,31 @@ void PulsarAnimationWidget::initializeGL()
backgroundTexture = backgroundTexture.scaled(maxTextureSize, maxTextureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
+ // prepare and check beam texture
+ QImage beamTexture(":/textures/resources/texture_beam.png");
+ if(beamTexture.width() != beamTexture.height()) {
+ qWarning() << msgShape.arg(tr("Beam"));
+ }
+ else {
+ double integer = 0.0;
+ double fraction = 0.0;
+ fraction = modf(log(beamTexture.width()) / log(2.0), &integer);
+ if(fraction > 0.0) {
+ qWarning() << msgPower.arg(tr("Beam"));
+ }
+ }
+ if(beamTexture.width() > maxTextureSize) {
+ qWarning() << msgSize.arg(tr("beam").arg(maxTextureSize).arg(maxTextureSize));
+ beamTexture = beamTexture.scaled(maxTextureSize, maxTextureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ }
+
// bind textures
m_backgroundTexture = bindTexture(backgroundTexture, GL_TEXTURE_2D, GL_RGBA);
+ m_beamTexture = bindTexture(beamTexture, GL_TEXTURE_2D, GL_RGBA);
// use mipmapped textures
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
-
- // enable 2D mapping (s/t coordinates, sphere map won't rotate texture!)
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
}
void PulsarAnimationWidget::resizeGL(int w, int h)
@@ -331,14 +348,7 @@ void PulsarAnimationWidget::paintGL()
}
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
+ // first cone (pointing away from camera)
glPushMatrix();
{
glRotatef(-m_pulsarSpinAxisInclination, 1.0, 0.0, 0.0);
@@ -373,15 +383,13 @@ void PulsarAnimationWidget::paintGL()
glTranslatef(0.0, 0.0, -m_pulsarBeamLength);
- glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient);
- glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse);
// 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
- glColor3f(1.0f, 1.0f, 0.0f);
+ 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
@@ -398,26 +406,25 @@ void PulsarAnimationWidget::paintGL()
}
glEnd();
- // draw first cone's inner layer (do we need/want this?)
- glBegin(GL_TRIANGLE_FAN);
- {
- glColor3f(0.66f, 0.66f, 0.0f);
- glVertex3f(0.0f, 0.0f, m_pulsarBeamLength);
- for(angle = 0.0f; angle < (2.0f*PI); angle += (PI/32.0f)) {
- x = m_pulsarBeamInnerRadius * sin(angle);
- y = m_pulsarBeamInnerRadius * cos(angle);
- 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_quadricPulsarConeRim1, GL_TRUE);
+ glBindTexture(GL_TEXTURE_2D, m_beamTexture);
+ glEnable(GL_TEXTURE_2D);
+
+ gluDisk(m_quadricPulsarConeRim1, 0, m_pulsarBeamOuterRadius, 32, 1);
- // draw first cone's "rim" (disk topping gap between both cones)
- glColor3f(1.0f, 1.0f, 0.5f);
- gluDisk(m_quadricPulsarConeRim1, m_pulsarBeamInnerRadius, m_pulsarBeamOuterRadius, 32, 8);
+ // disable texturing
+ glDisable(GL_TEXTURE_2D);
+
+ glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
}
glPopMatrix();
- // second cone
+ // second cone (pointing towards from camera)
glPushMatrix();
{
glRotatef(180.0, 1.0, 0.0, 0.0);
@@ -428,15 +435,12 @@ void PulsarAnimationWidget::paintGL()
glTranslatef(0.0, 0.0, -m_pulsarBeamLength);
- glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient);
- glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse);
-
- // draw first cone's outer layer
+ // 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
- glColor3f(1.0f, 1.0f, 0.0f);
+ 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
@@ -453,22 +457,21 @@ void PulsarAnimationWidget::paintGL()
}
glEnd();
- // draw first cone's inner layer (do we need/want this?)
- glBegin(GL_TRIANGLE_FAN);
- {
- glColor3f(0.66f, 0.66f, 0.0f);
- glVertex3f(0.0f, 0.0f, m_pulsarBeamLength);
- for(angle = 0.0f; angle < (2.0f*PI); angle += (PI/32.0f)) {
- x = m_pulsarBeamInnerRadius * sin(angle);
- y = m_pulsarBeamInnerRadius * cos(angle);
- 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_quadricPulsarConeRim2, GL_TRUE);
+ glBindTexture(GL_TEXTURE_2D, m_beamTexture);
+ glEnable(GL_TEXTURE_2D);
+
+ gluDisk(m_quadricPulsarConeRim2, 0, m_pulsarBeamOuterRadius, 32, 1);
- // draw first cone's "rim" (disk topping gap between both cones)
- glColor3f(1.0f, 1.0f, 0.5f);
- gluDisk(m_quadricPulsarConeRim2, m_pulsarBeamInnerRadius, m_pulsarBeamOuterRadius, 32, 8);
+ // disable texturing
+ glDisable(GL_TEXTURE_2D);
+
+ glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
}
glPopMatrix();
}
@@ -499,7 +502,6 @@ void PulsarAnimationWidget::paintGL()
// draw backdrop (independent parallel projection)
glColor3f(1.0f, 1.0f, 1.0f);
- glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat_specular);
glTranslatef(0.0, 0.0, -501.0);
drawTexture(QPointF(0.0, 0.0), m_backgroundTexture);
diff --git a/src/pulsaranimationwidget.h b/src/pulsaranimationwidget.h
index b3e23d9e56f5678a6ac1c64205cd52d363c0a4c9..8149bd21d65ee7ceb6a05a08b846ab1770b3239a 100644
--- a/src/pulsaranimationwidget.h
+++ b/src/pulsaranimationwidget.h
@@ -88,6 +88,7 @@ private:
GLUquadricObj *m_quadricLineOfSightConeBase;
GLuint m_backgroundTexture;
+ GLuint m_beamTexture;
int m_framesPerSecond;
diff --git a/src/pulsatingscience.qrc b/src/pulsatingscience.qrc
index 983fcf3e063a9b5dfd570098a9fbc9bf973e4df4..0eaace8cc94dfd75dd7008bcf5de10001df671f7 100644
--- a/src/pulsatingscience.qrc
+++ b/src/pulsatingscience.qrc
@@ -16,5 +16,6 @@
resources/texture_background_carina.png
resources/texture_pulsar.png
+ resources/texture_beam.png
diff --git a/src/resources/texture_beam.png b/src/resources/texture_beam.png
new file mode 100644
index 0000000000000000000000000000000000000000..5e163ae79f5a8edd62341ee82f87bfa94f16874e
Binary files /dev/null and b/src/resources/texture_beam.png differ
diff --git a/src/resources/texture_beam.svg b/src/resources/texture_beam.svg
new file mode 100644
index 0000000000000000000000000000000000000000..331bea94f9741cfcf1c538a9fce2fab142d16bce
--- /dev/null
+++ b/src/resources/texture_beam.svg
@@ -0,0 +1,133 @@
+
+
+
+