Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pulsatingscience
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
einsteinathome
pulsatingscience
Commits
cfe9b979
Commit
cfe9b979
authored
Jan 23, 2009
by
Oliver Bock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Aligned and synchronized axes with inclinations and pulsar rotation (incl. texture)
parent
be74ad45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
30 deletions
+35
-30
src/pulsaranimationwidget.cpp
src/pulsaranimationwidget.cpp
+34
-28
src/pulsaranimationwidget.h
src/pulsaranimationwidget.h
+1
-2
No files found.
src/pulsaranimationwidget.cpp
View file @
cfe9b979
...
...
@@ -43,8 +43,7 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
m_quadricPulsarCone1
=
NULL
;
m_quadricPulsarCone2
=
NULL
;
m_quadricPulsarSpinAxis
=
NULL
;
m_quadricPulsarMagneticAxis1
=
NULL
;
m_quadricPulsarMagneticAxis2
=
NULL
;
m_quadricPulsarMagneticAxis
=
NULL
;
m_pulsarTexture
=
0
;
m_backgroundTexture
=
0
;
...
...
@@ -71,8 +70,7 @@ PulsarAnimationWidget::~PulsarAnimationWidget()
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_quadricPulsarMagneticAxis
)
gluDeleteQuadric
(
m_quadricPulsarMagneticAxis
);
if
(
m_pulsarTexture
)
deleteTexture
(
m_pulsarTexture
);
if
(
m_backgroundTexture
)
deleteTexture
(
m_backgroundTexture
);
...
...
@@ -114,16 +112,14 @@ void PulsarAnimationWidget::initializeGL()
m_quadricPulsarCone1
=
gluNewQuadric
();
m_quadricPulsarCone2
=
gluNewQuadric
();
m_quadricPulsarSpinAxis
=
gluNewQuadric
();
m_quadricPulsarMagneticAxis1
=
gluNewQuadric
();
m_quadricPulsarMagneticAxis2
=
gluNewQuadric
();
m_quadricPulsarMagneticAxis
=
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
);
gluQuadricNormals
(
m_quadricPulsarMagneticAxis
,
GLU_SMOOTH
);
// load textures
m_pulsarTexture
=
bindTexture
(
QImage
(
":/textures/resources/texture_pulsar.png"
),
GL_TEXTURE_2D
,
GL_RGBA
);
...
...
@@ -175,6 +171,7 @@ void PulsarAnimationWidget::paintGL()
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
low_shininess
);
glMaterialfv
(
GL_FRONT
,
GL_EMISSION
,
no_mat
);
// draw companion
glPushMatrix
();
glTranslatef
(
sin
((
m_orbitRotationAngle
+
180
)
*
deg2rad
)
*
m_companionOrbitRadius
,
0.0
f
,
...
...
@@ -182,36 +179,37 @@ void PulsarAnimationWidget::paintGL()
gluSphere
(
m_quadricPulsar
,
1.0
f
,
32
,
32
);
glPopMatrix
();
// draw pulsar
glPushMatrix
();
glTranslatef
(
sin
(
m_orbitRotationAngle
*
deg2rad
)
*
m_pulsarOrbitRadius
,
0.0
f
,
cos
(
m_orbitRotationAngle
*
deg2rad
)
*
m_pulsarOrbitRadius
);
glPushMatrix
();
// enable texture coordinates and bind texture
glEnable
(
GL_TEXTURE_GEN_S
);
glEnable
(
GL_TEXTURE_GEN_T
);
glBindTexture
(
GL_TEXTURE_2D
,
m_pulsarTexture
);
glRotatef
(
m_pulsarSpinAxisInclination
,
0.0
f
,
0.0
f
,
1.0
f
);
glRotatef
(
m_pulsarRotationAngle
,
0.0
f
,
1.0
f
,
0.0
f
);
// draw spin axis
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
);
glRotatef
(
90.0
f
,
1.0
f
,
0.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
();
}
glRotatef
(
m_pulsarRotationAngle
,
0.0
f
,
1.0
f
,
0.0
f
);
glRotatef
(
m_pulsarSpinAxisInclination
,
1.0
f
,
0.0
f
,
0.0
f
);
// 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
);
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 textur
e coordinates
// disable textur
ing
glDisable
(
GL_TEXTURE_GEN_S
);
glDisable
(
GL_TEXTURE_GEN_T
);
glDisable
(
GL_TEXTURE_2D
);
...
...
@@ -224,13 +222,21 @@ void PulsarAnimationWidget::paintGL()
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
coneSpecular
);
// first cone
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
);
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
);
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
)
{
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
gluCylinder
(
m_quadricPulsarMagneticAxis1
,
0.05
f
,
0.05
f
,
5.0
f
,
32
,
1
);
glPushMatrix
();
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
);
...
...
@@ -240,14 +246,13 @@ void PulsarAnimationWidget::paintGL()
gluCylinder
(
m_quadricPulsarCone1
,
0.5
f
,
0.0
f
,
3.0
f
,
32
,
32
);
glPopMatrix
();
// second cone
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
);
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
);
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
);
}
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
);
glTranslatef
(
0.0
f
,
0.0
f
,
-
4.0
f
);
...
...
@@ -257,6 +262,7 @@ void PulsarAnimationWidget::paintGL()
glPopMatrix
();
glPopMatrix
();
// draw orbital plane
if
(
m_cameraInteraction
)
{
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
...
...
src/pulsaranimationwidget.h
View file @
cfe9b979
...
...
@@ -71,8 +71,7 @@ protected:
GLUquadricObj
*
m_quadricPulsarCone1
;
GLUquadricObj
*
m_quadricPulsarCone2
;
GLUquadricObj
*
m_quadricPulsarSpinAxis
;
GLUquadricObj
*
m_quadricPulsarMagneticAxis1
;
GLUquadricObj
*
m_quadricPulsarMagneticAxis2
;
GLUquadricObj
*
m_quadricPulsarMagneticAxis
;
GLuint
m_pulsarTexture
;
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