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
cfe9b979
Commit
cfe9b979
authored
Jan 23, 2009
by
Oliver Bock
Browse files
Aligned and synchronized axes with inclinations and pulsar rotation (incl. texture)
parent
be74ad45
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/pulsaranimationwidget.cpp
View file @
cfe9b979
...
@@ -43,8 +43,7 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
...
@@ -43,8 +43,7 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
m_quadricPulsarCone1
=
NULL
;
m_quadricPulsarCone1
=
NULL
;
m_quadricPulsarCone2
=
NULL
;
m_quadricPulsarCone2
=
NULL
;
m_quadricPulsarSpinAxis
=
NULL
;
m_quadricPulsarSpinAxis
=
NULL
;
m_quadricPulsarMagneticAxis1
=
NULL
;
m_quadricPulsarMagneticAxis
=
NULL
;
m_quadricPulsarMagneticAxis2
=
NULL
;
m_pulsarTexture
=
0
;
m_pulsarTexture
=
0
;
m_backgroundTexture
=
0
;
m_backgroundTexture
=
0
;
...
@@ -71,8 +70,7 @@ PulsarAnimationWidget::~PulsarAnimationWidget()
...
@@ -71,8 +70,7 @@ PulsarAnimationWidget::~PulsarAnimationWidget()
if
(
m_quadricPulsarCone1
)
gluDeleteQuadric
(
m_quadricPulsarCone1
);
if
(
m_quadricPulsarCone1
)
gluDeleteQuadric
(
m_quadricPulsarCone1
);
if
(
m_quadricPulsarCone2
)
gluDeleteQuadric
(
m_quadricPulsarCone2
);
if
(
m_quadricPulsarCone2
)
gluDeleteQuadric
(
m_quadricPulsarCone2
);
if
(
m_quadricPulsarSpinAxis
)
gluDeleteQuadric
(
m_quadricPulsarSpinAxis
);
if
(
m_quadricPulsarSpinAxis
)
gluDeleteQuadric
(
m_quadricPulsarSpinAxis
);
if
(
m_quadricPulsarMagneticAxis1
)
gluDeleteQuadric
(
m_quadricPulsarMagneticAxis1
);
if
(
m_quadricPulsarMagneticAxis
)
gluDeleteQuadric
(
m_quadricPulsarMagneticAxis
);
if
(
m_quadricPulsarMagneticAxis2
)
gluDeleteQuadric
(
m_quadricPulsarMagneticAxis2
);
if
(
m_pulsarTexture
)
deleteTexture
(
m_pulsarTexture
);
if
(
m_pulsarTexture
)
deleteTexture
(
m_pulsarTexture
);
if
(
m_backgroundTexture
)
deleteTexture
(
m_backgroundTexture
);
if
(
m_backgroundTexture
)
deleteTexture
(
m_backgroundTexture
);
...
@@ -114,16 +112,14 @@ void PulsarAnimationWidget::initializeGL()
...
@@ -114,16 +112,14 @@ void PulsarAnimationWidget::initializeGL()
m_quadricPulsarCone1
=
gluNewQuadric
();
m_quadricPulsarCone1
=
gluNewQuadric
();
m_quadricPulsarCone2
=
gluNewQuadric
();
m_quadricPulsarCone2
=
gluNewQuadric
();
m_quadricPulsarSpinAxis
=
gluNewQuadric
();
m_quadricPulsarSpinAxis
=
gluNewQuadric
();
m_quadricPulsarMagneticAxis1
=
gluNewQuadric
();
m_quadricPulsarMagneticAxis
=
gluNewQuadric
();
m_quadricPulsarMagneticAxis2
=
gluNewQuadric
();
gluQuadricNormals
(
m_quadricPulsarOrbitPlane
,
GLU_SMOOTH
);
gluQuadricNormals
(
m_quadricPulsarOrbitPlane
,
GLU_SMOOTH
);
gluQuadricNormals
(
m_quadricPulsar
,
GLU_SMOOTH
);
gluQuadricNormals
(
m_quadricPulsar
,
GLU_SMOOTH
);
gluQuadricNormals
(
m_quadricPulsarCone1
,
GLU_SMOOTH
);
gluQuadricNormals
(
m_quadricPulsarCone1
,
GLU_SMOOTH
);
gluQuadricNormals
(
m_quadricPulsarCone2
,
GLU_SMOOTH
);
gluQuadricNormals
(
m_quadricPulsarCone2
,
GLU_SMOOTH
);
gluQuadricNormals
(
m_quadricPulsarSpinAxis
,
GLU_SMOOTH
);
gluQuadricNormals
(
m_quadricPulsarSpinAxis
,
GLU_SMOOTH
);
gluQuadricNormals
(
m_quadricPulsarMagneticAxis1
,
GLU_SMOOTH
);
gluQuadricNormals
(
m_quadricPulsarMagneticAxis
,
GLU_SMOOTH
);
gluQuadricNormals
(
m_quadricPulsarMagneticAxis2
,
GLU_SMOOTH
);
// load textures
// load textures
m_pulsarTexture
=
bindTexture
(
QImage
(
":/textures/resources/texture_pulsar.png"
),
GL_TEXTURE_2D
,
GL_RGBA
);
m_pulsarTexture
=
bindTexture
(
QImage
(
":/textures/resources/texture_pulsar.png"
),
GL_TEXTURE_2D
,
GL_RGBA
);
...
@@ -175,6 +171,7 @@ void PulsarAnimationWidget::paintGL()
...
@@ -175,6 +171,7 @@ void PulsarAnimationWidget::paintGL()
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
low_shininess
);
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
low_shininess
);
glMaterialfv
(
GL_FRONT
,
GL_EMISSION
,
no_mat
);
glMaterialfv
(
GL_FRONT
,
GL_EMISSION
,
no_mat
);
// draw companion
glPushMatrix
();
glPushMatrix
();
glTranslatef
(
sin
((
m_orbitRotationAngle
+
180
)
*
deg2rad
)
*
m_companionOrbitRadius
,
glTranslatef
(
sin
((
m_orbitRotationAngle
+
180
)
*
deg2rad
)
*
m_companionOrbitRadius
,
0.0
f
,
0.0
f
,
...
@@ -182,36 +179,37 @@ void PulsarAnimationWidget::paintGL()
...
@@ -182,36 +179,37 @@ void PulsarAnimationWidget::paintGL()
gluSphere
(
m_quadricPulsar
,
1.0
f
,
32
,
32
);
gluSphere
(
m_quadricPulsar
,
1.0
f
,
32
,
32
);
glPopMatrix
();
glPopMatrix
();
// draw pulsar
glPushMatrix
();
glPushMatrix
();
glTranslatef
(
sin
(
m_orbitRotationAngle
*
deg2rad
)
*
m_pulsarOrbitRadius
,
glTranslatef
(
sin
(
m_orbitRotationAngle
*
deg2rad
)
*
m_pulsarOrbitRadius
,
0.0
f
,
0.0
f
,
cos
(
m_orbitRotationAngle
*
deg2rad
)
*
m_pulsarOrbitRadius
);
cos
(
m_orbitRotationAngle
*
deg2rad
)
*
m_pulsarOrbitRadius
);
glPushMatrix
();
glPushMatrix
();
// enable texture coordinates and bind texture
glRotatef
(
m_pulsarSpinAxisInclination
,
0.0
f
,
0.0
f
,
1.0
f
);
glEnable
(
GL_TEXTURE_GEN_S
);
glRotatef
(
m_pulsarRotationAngle
,
0.0
f
,
1.0
f
,
0.0
f
);
glEnable
(
GL_TEXTURE_GEN_T
);
glBindTexture
(
GL_TEXTURE_2D
,
m_pulsarTexture
);
// draw spin axis
if
(
m_cameraInteraction
)
{
if
(
m_cameraInteraction
)
{
glPushMatrix
();
glPushMatrix
();
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
glRotatef
(
90.0
,
1.0
f
,
0.0
f
,
0.0
f
);
glRotatef
(
90.0
f
,
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
);
glTranslatef
(
0.0
f
,
0.0
f
,
-
5.0
f
);
gluCylinder
(
m_quadricPulsarSpinAxis
,
0.05
f
,
0.05
f
,
10.0
f
,
32
,
1
);
gluCylinder
(
m_quadricPulsarSpinAxis
,
0.05
f
,
0.05
f
,
10.0
f
,
32
,
1
);
glPopMatrix
();
glPopMatrix
();
}
}
glRotatef
(
m_pulsarRotationAngle
,
0.0
f
,
1.0
f
,
0.0
f
);
// create texture coordinates and enable texturing
glRotatef
(
m_pulsarSpinAxisInclination
,
1.0
f
,
0.0
f
,
0.0
f
);
glEnable
(
GL_TEXTURE_GEN_S
);
glEnable
(
GL_TEXTURE_GEN_T
);
glBindTexture
(
GL_TEXTURE_2D
,
m_pulsarTexture
);
glEnable
(
GL_TEXTURE_2D
);
glEnable
(
GL_TEXTURE_2D
);
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT
,
no_mat
);
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT
,
no_mat
);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
mat_diffuse
);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
mat_diffuse
);
gluSphere
(
m_quadricPulsar
,
1.0
f
,
32
,
32
);
gluSphere
(
m_quadricPulsar
,
1.0
f
,
32
,
32
);
// disable textur
e coordinates
// disable textur
ing
glDisable
(
GL_TEXTURE_GEN_S
);
glDisable
(
GL_TEXTURE_GEN_S
);
glDisable
(
GL_TEXTURE_GEN_T
);
glDisable
(
GL_TEXTURE_GEN_T
);
glDisable
(
GL_TEXTURE_2D
);
glDisable
(
GL_TEXTURE_2D
);
...
@@ -224,13 +222,21 @@ void PulsarAnimationWidget::paintGL()
...
@@ -224,13 +222,21 @@ void PulsarAnimationWidget::paintGL()
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
coneSpecular
);
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
coneSpecular
);
// first cone
glPushMatrix
();
glPushMatrix
();
glRotatef
(
m_pulsarRotationAngle
-
90.0
f
,
0.0
f
,
1.0
f
,
0.0
f
);
glRotatef
(
90.0
f
,
1.0
f
,
0.0
f
,
0.0
f
);
glRotatef
(
-
m_pulsarMagneticAxisInclination
-
m_pulsarSpinAxisInclination
+
90.0
f
,
1.0
f
,
0.0
f
,
0.0
f
);
glRotatef
(
m_pulsarSpinAxisInclination
,
0.0
f
,
1.0
f
,
0.0
f
);
glRotatef
(
-
m_pulsarRotationAngle
-
90.0
f
,
0.0
f
,
0.0
f
,
1.0
f
);
glRotatef
(
-
m_pulsarMagneticAxisInclination
,
1.0
f
,
0.0
f
,
0.0
f
);
// draw magnetic axis (for both cones)
if
(
m_cameraInteraction
)
{
if
(
m_cameraInteraction
)
{
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
glPushMatrix
();
gluCylinder
(
m_quadricPulsarMagneticAxis1
,
0.05
f
,
0.05
f
,
5.0
f
,
32
,
1
);
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
glTranslatef
(
0.0
f
,
0.0
f
,
-
5.0
f
);
gluCylinder
(
m_quadricPulsarMagneticAxis
,
0.05
f
,
0.05
f
,
10.0
f
,
32
,
1
);
glPopMatrix
();
}
}
glTranslatef
(
0.0
f
,
0.0
f
,
-
4.0
f
);
glTranslatef
(
0.0
f
,
0.0
f
,
-
4.0
f
);
...
@@ -240,14 +246,13 @@ void PulsarAnimationWidget::paintGL()
...
@@ -240,14 +246,13 @@ void PulsarAnimationWidget::paintGL()
gluCylinder
(
m_quadricPulsarCone1
,
0.5
f
,
0.0
f
,
3.0
f
,
32
,
32
);
gluCylinder
(
m_quadricPulsarCone1
,
0.5
f
,
0.0
f
,
3.0
f
,
32
,
32
);
glPopMatrix
();
glPopMatrix
();
// second cone
glPushMatrix
();
glPushMatrix
();
glRotatef
(
m_pulsarRotationAngle
+
90.0
f
,
0
.0
f
,
1
.0
f
,
0.0
f
);
glRotatef
(
-
90.0
f
,
1
.0
f
,
0
.0
f
,
0.0
f
);
glRotatef
(
m_pulsarMagneticAxisInclination
+
m_pulsarSpinAxisInclination
-
9
0.0
f
,
1.0
f
,
0.0
f
,
0.0
f
);
glRotatef
(
-
m_pulsarSpinAxisInclination
,
0.0
f
,
1.0
f
,
0.0
f
);
if
(
m_cameraInteraction
)
{
glRotatef
(
m_pulsarRotationAngle
-
90.0
f
,
0.0
f
,
0.0
f
,
1.0
f
);
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
glRotatef
(
m_pulsarMagneticAxisInclination
,
1.0
f
,
0.0
f
,
0.0
f
);
gluCylinder
(
m_quadricPulsarMagneticAxis2
,
0.05
f
,
0.05
f
,
5.0
f
,
32
,
1
);
}
glTranslatef
(
0.0
f
,
0.0
f
,
-
4.0
f
);
glTranslatef
(
0.0
f
,
0.0
f
,
-
4.0
f
);
...
@@ -257,6 +262,7 @@ void PulsarAnimationWidget::paintGL()
...
@@ -257,6 +262,7 @@ void PulsarAnimationWidget::paintGL()
glPopMatrix
();
glPopMatrix
();
glPopMatrix
();
glPopMatrix
();
// draw orbital plane
if
(
m_cameraInteraction
)
{
if
(
m_cameraInteraction
)
{
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
...
...
src/pulsaranimationwidget.h
View file @
cfe9b979
...
@@ -71,8 +71,7 @@ protected:
...
@@ -71,8 +71,7 @@ protected:
GLUquadricObj
*
m_quadricPulsarCone1
;
GLUquadricObj
*
m_quadricPulsarCone1
;
GLUquadricObj
*
m_quadricPulsarCone2
;
GLUquadricObj
*
m_quadricPulsarCone2
;
GLUquadricObj
*
m_quadricPulsarSpinAxis
;
GLUquadricObj
*
m_quadricPulsarSpinAxis
;
GLUquadricObj
*
m_quadricPulsarMagneticAxis1
;
GLUquadricObj
*
m_quadricPulsarMagneticAxis
;
GLUquadricObj
*
m_quadricPulsarMagneticAxis2
;
GLuint
m_pulsarTexture
;
GLuint
m_pulsarTexture
;
GLuint
m_backgroundTexture
;
GLuint
m_backgroundTexture
;
...
...
Write
Preview
Markdown
is supported
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