Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
einsteinathome
pulsatingscience
Commits
9154cfc0
Commit
9154cfc0
authored
Jan 23, 2009
by
Oliver Bock
Browse files
Added visualizations for spin and magnetic axes
parent
99d8f06e
Changes
2
Show whitespace changes
Inline
Side-by-side
src/pulsaranimationwidget.cpp
View file @
9154cfc0
...
...
@@ -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.0
f
,
0.0
f
,
0.0
f
);
glRotatef
(
-
m_pulsarSpinAxisInclination
,
0.0
f
,
1.0
f
,
0.0
f
);
glTranslatef
(
0.0
f
,
0.0
f
,
-
5.0
f
);
gluCylinder
(
m_quadricPulsarSpinAxis
,
0.05
f
,
0.05
f
,
10.0
f
,
32
,
1
);
glPopMatrix
();
}
// FIXME: how to rotate texture?
glRotatef
(
m_pulsarRotationAngle
,
0.0
f
,
1.0
f
,
0.0
f
);
glRotatef
(
m_pulsarSpinAxisInclination
,
1.0
f
,
0.0
f
,
0.0
f
);
glEnable
(
GL_TEXTURE_2D
);
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT
,
no_mat
);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
mat_diffuse
);
gluSphere
(
m_quadricPulsar
,
1.0
f
,
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.0
f
,
0.0
f
,
1.0
f
,
0.0
f
);
glRotatef
(
-
m_pulsarMagneticAxisInclination
-
m_pulsarSpinAxisInclination
+
90.0
f
,
1.0
f
,
0.0
f
,
0.0
f
);
if
(
m_cameraInteraction
)
{
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
gluCylinder
(
m_quadricPulsarMagneticAxis1
,
0.05
f
,
0.05
f
,
5.0
f
,
32
,
1
);
}
glTranslatef
(
0.0
f
,
0.0
f
,
-
4.0
f
);
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT
,
coneAmbient
);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
coneDiffuse
);
gluCylinder
(
m_quadricPulsarCone1
,
0.5
f
,
0.0
f
,
3.0
f
,
32
,
32
);
glPopMatrix
();
glPushMatrix
();
glRotatef
(
m_pulsarRotationAngle
+
90.0
f
,
0.0
f
,
1.0
f
,
0.0
f
);
glRotatef
(
m_pulsarMagneticAxisInclination
+
m_pulsarSpinAxisInclination
-
90.0
f
,
1.0
f
,
0.0
f
,
0.0
f
);
if
(
m_cameraInteraction
)
{
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
gluCylinder
(
m_quadricPulsarMagneticAxis2
,
0.05
f
,
0.05
f
,
5.0
f
,
32
,
1
);
}
glTranslatef
(
0.0
f
,
0.0
f
,
-
4.0
f
);
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT
,
coneAmbient
);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
coneDiffuse
);
gluCylinder
(
m_quadricPulsarCone2
,
0.5
f
,
0.0
f
,
3.0
f
,
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.0
f
,
1.0
f
,
0.0
f
,
0.0
f
);
...
...
src/pulsaranimationwidget.h
View file @
9154cfc0
...
...
@@ -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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment