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

Show pulsar as wireframe model (without texture)

parent b5c71b20
Branches
Tags
No related merge requests found
......@@ -63,7 +63,6 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
m_quadricPulsarMagneticAxis = NULL;
// initialize texture pointers
m_pulsarTexture = 0;
m_backgroundTexture = 0;
// initial render timing settings
......@@ -115,7 +114,6 @@ PulsarAnimationWidget::~PulsarAnimationWidget()
if(m_quadricPulsarSpinAxis) gluDeleteQuadric(m_quadricPulsarSpinAxis);
if(m_quadricPulsarMagneticAxis) gluDeleteQuadric(m_quadricPulsarMagneticAxis);
if(m_pulsarTexture) deleteTexture(m_pulsarTexture);
if(m_backgroundTexture) deleteTexture(m_backgroundTexture);
}
......@@ -177,24 +175,6 @@ void PulsarAnimationWidget::initializeGL()
QString msgPower = tr("%1 texture dimensions not a power of 2!");
QString msgSize = tr("Maximum texture size exceeded! Scaling down %1 texture to %2x%3...");
// prepare and check pulsar texture
QImage pulsarTexture(":/textures/resources/texture_pulsar.png");
if(pulsarTexture.width() != pulsarTexture.height()) {
qWarning() << msgShape.arg(tr("Pulsar"));
}
else {
double integer = 0.0;
double fraction = 0.0;
fraction = modf(log(pulsarTexture.width()) / log(2.0), &integer);
if(fraction > 0.0) {
qWarning() << msgPower.arg(tr("Pulsar"));
}
}
if(pulsarTexture.width() > maxTextureSize) {
qWarning() << msgSize.arg(tr("pulsar").arg(maxTextureSize).arg(maxTextureSize));
pulsarTexture = pulsarTexture.scaled(maxTextureSize, maxTextureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
// prepare and check background texture
QImage backgroundTexture(":/textures/resources/texture_background_carina.png");
if(backgroundTexture.width() != backgroundTexture.height()) {
......@@ -214,7 +194,6 @@ void PulsarAnimationWidget::initializeGL()
}
// bind textures
m_pulsarTexture = bindTexture(pulsarTexture, GL_TEXTURE_2D, GL_RGBA);
m_backgroundTexture = bindTexture(backgroundTexture, GL_TEXTURE_2D, GL_RGBA);
// use mipmapped textures
......@@ -284,33 +263,27 @@ void PulsarAnimationWidget::paintGL()
{
glRotatef(m_pulsarSpinAxisInclination, 0.0, 0.0, 1.0);
glRotatef(m_pulsarRotationAngle, 0.0, 1.0, 0.0);
glRotatef(90, 0.0, 0.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);
glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
}
glPopMatrix();
}
// create texture coordinates and enable texturing
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glBindTexture(GL_TEXTURE_2D, m_pulsarTexture);
glEnable(GL_TEXTURE_2D);
glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
// enable wireframe mode
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
// draw pulsar
gluSphere(m_quadricPulsar, 1.0, 32, 32);
// disable texturing
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_2D);
// disable wireframe mode
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
}
glPopMatrix();
......
......@@ -89,7 +89,6 @@ private:
GLUquadricObj *m_quadricPulsarSpinAxis;
GLUquadricObj *m_quadricPulsarMagneticAxis;
GLuint m_pulsarTexture;
GLuint m_backgroundTexture;
int m_framesPerSecond;
......
<RCC>
<qresource prefix="icons" >
<qresource prefix="/icons">
<file>resources/control-pause.png</file>
<file>resources/control-quit.png</file>
<file>resources/control-run.png</file>
......@@ -9,11 +9,10 @@
<file>resources/help-website.png</file>
<file>resources/aei-icon48.png</file>
</qresource>
<qresource prefix="i18ns" >
<qresource prefix="/i18ns">
<file>resources/pulsatingscience_de.qm</file>
</qresource>
<qresource prefix="textures" >
<qresource prefix="/textures">
<file>resources/texture_background_carina.png</file>
<file>resources/texture_pulsar.png</file>
</qresource>
</RCC>
src/resources/texture_pulsar.png

279 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment