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
5d8927f0
Commit
5d8927f0
authored
Sep 09, 2011
by
Oliver Bock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enclosed glPushMatrix in blocks to help formatter
parent
3526540e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
99 deletions
+119
-99
src/pulsaranimationwidget.cpp
src/pulsaranimationwidget.cpp
+119
-99
No files found.
src/pulsaranimationwidget.cpp
View file @
5d8927f0
...
...
@@ -265,113 +265,129 @@ void PulsarAnimationWidget::paintGL()
// draw companion
glPushMatrix
();
glTranslatef
(
sin
((
m_orbitRotationAngle
+
180.0
)
*
deg2rad
)
*
m_companionSemiMajorAxis
,
0.0
,
cos
((
m_orbitRotationAngle
+
180.0
)
*
deg2rad
)
*
m_companionSemiMajorAxis
);
gluSphere
(
m_quadricCompanion
,
1.0
,
32
,
32
);
{
glTranslatef
(
sin
((
m_orbitRotationAngle
+
180.0
)
*
deg2rad
)
*
m_companionSemiMajorAxis
,
0.0
,
cos
((
m_orbitRotationAngle
+
180.0
)
*
deg2rad
)
*
m_companionSemiMajorAxis
);
gluSphere
(
m_quadricCompanion
,
1.0
,
32
,
32
);
}
glPopMatrix
();
// draw pulsar
glPushMatrix
();
glTranslatef
(
sin
(
m_orbitRotationAngle
*
deg2rad
)
*
m_pulsarSemiMajorAxis
,
0.0
,
cos
(
m_orbitRotationAngle
*
deg2rad
)
*
m_pulsarSemiMajorAxis
);
glPushMatrix
();
glRotatef
(
m_pulsarSpinAxisInclination
,
0.0
,
0.0
,
1.0
);
glRotatef
(
m_pulsarRotationAngle
,
0.0
,
1.0
,
0.0
);
{
glTranslatef
(
sin
(
m_orbitRotationAngle
*
deg2rad
)
*
m_pulsarSemiMajorAxis
,
0.0
,
cos
(
m_orbitRotationAngle
*
deg2rad
)
*
m_pulsarSemiMajorAxis
);
// 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
);
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
);
gluSphere
(
m_quadricPulsar
,
1.0
,
32
,
32
);
{
glRotatef
(
m_pulsarSpinAxisInclination
,
0.0
,
0.0
,
1.0
);
glRotatef
(
m_pulsarRotationAngle
,
0.0
,
1.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
);
}
glPopMatrix
();
}
// dis
able texturing
glDis
able
(
GL_TEXTURE_GEN_S
);
glDis
able
(
GL_TEXTURE_GEN_T
);
glDisable
(
GL_TEXTURE_2D
);
glPopMatrix
(
);
// create texture coordinates and en
able texturing
glEn
able
(
GL_TEXTURE_GEN_S
);
glEn
able
(
GL_TEXTURE_GEN_T
);
glBindTexture
(
GL_TEXTURE_2D
,
m_pulsarTexture
);
glEnable
(
GL_TEXTURE_2D
);
// 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_AMBIENT
,
no_mat
);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
mat_diffuse
);
gluSphere
(
m_quadricPulsar
,
1.0
,
32
,
32
);
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
coneSpecular
);
// first cone
glPushMatrix
(
);
glRotatef
(
90.0
,
1.0
,
0.0
,
0.0
);
glRotatef
(
m_pulsarSpinAxisInclination
,
0.0
,
1.0
,
0.0
);
// disable texturing
glDisable
(
GL_TEXTURE_GEN_S
);
glDisable
(
GL_TEXTURE_GEN_T
);
glDisable
(
GL_TEXTURE_2D
);
}
glPopMatrix
(
);
glRotatef
(
-
m_pulsarRotationAngle
-
90.0
,
0.0
,
0.0
,
1.0
);
glRotatef
(
-
m_pulsarMagneticAxisInclination
,
1.0
,
0.0
,
0.0
);
// 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
};
// draw magnetic axis (for both cones)
if
(
m_showRotationAxes
)
{
// first cone
glPushMatrix
();
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
glTranslatef
(
0.0
,
0.0
,
-
5.0
);
gluCylinder
(
m_quadricPulsarMagneticAxis
,
0.05
,
0.05
,
10.0
,
32
,
1
);
glPopMatrix
();
}
{
glRotatef
(
90.0
,
1.0
,
0.0
,
0.0
);
glRotatef
(
m_pulsarSpinAxisInclination
,
0.0
,
1.0
,
0.0
);
glRotatef
(
-
m_pulsarRotationAngle
-
90.0
,
0.0
,
0.0
,
1.0
);
glRotatef
(
-
m_pulsarMagneticAxisInclination
,
1.0
,
0.0
,
0.0
);
// draw magnetic axis (for both cones)
if
(
m_showRotationAxes
)
{
glPushMatrix
();
{
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
translucent
);
glTranslatef
(
0.0
,
0.0
,
-
5.0
);
gluCylinder
(
m_quadricPulsarMagneticAxis
,
0.05
,
0.05
,
10.0
,
32
,
1
);
}
glPopMatrix
();
}
glTranslatef
(
0.0
,
0.0
,
-
4.0
);
glTranslatef
(
0.0
,
0.0
,
-
4.0
);
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT
,
coneAmbient
);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
coneDiffuse
);
gluCylinder
(
m_quadricPulsarCone1
,
0.475
,
0.0
,
3.0
,
32
,
32
);
glPopMatrix
();
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT
,
coneAmbient
);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
coneDiffuse
);
gluCylinder
(
m_quadricPulsarCone1
,
0.475
,
0.0
,
3.0
,
32
,
32
);
}
glPopMatrix
();
// second cone
glPushMatrix
();
glRotatef
(
-
90.0
,
1.0
,
0.0
,
0.0
);
glRotatef
(
-
m_pulsarSpinAxisInclination
,
0.0
,
1.0
,
0.0
);
// second cone
glPushMatrix
();
{
glRotatef
(
-
90.0
,
1.0
,
0.0
,
0.0
);
glRotatef
(
-
m_pulsarSpinAxisInclination
,
0.0
,
1.0
,
0.0
);
glRotatef
(
m_pulsarRotationAngle
-
90.0
,
0.0
,
0.0
,
1.0
);
glRotatef
(
m_pulsarMagneticAxisInclination
,
1.0
,
0.0
,
0.0
);
glRotatef
(
m_pulsarRotationAngle
-
90.0
,
0.0
,
0.0
,
1.0
);
glRotatef
(
m_pulsarMagneticAxisInclination
,
1.0
,
0.0
,
0.0
);
glTranslatef
(
0.0
,
0.0
,
-
4.0
);
glTranslatef
(
0.0
,
0.0
,
-
4.0
);
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT
,
coneAmbient
);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
coneDiffuse
);
gluCylinder
(
m_quadricPulsarCone2
,
0.475
,
0.0
,
3.0
,
32
,
32
);
glPopMatrix
();
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT
,
coneAmbient
);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
coneDiffuse
);
gluCylinder
(
m_quadricPulsarCone2
,
0.475
,
0.0
,
3.0
,
32
,
32
);
}
glPopMatrix
();
}
glPopMatrix
();
// save current state
glMatrixMode
(
GL_PROJECTION
);
glPushMatrix
();
glLoadIdentity
();
glOrtho
(
0
,
width
(),
0
,
height
(),
0.1
,
501.0
);
glMatrixMode
(
GL_MODELVIEW
);
glPushMatrix
();
glLoadIdentity
();
{
glLoadIdentity
();
glOrtho
(
0
,
width
(),
0
,
height
(),
0.1
,
501.0
);
glMatrixMode
(
GL_MODELVIEW
);
glPushMatrix
();
{
glLoadIdentity
();
// draw backdrop (independent parallel projection)
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
mat_specular
);
glTranslatef
(
0.0
,
0.0
,
-
501.0
);
drawTexture
(
QPointF
(
0.0
,
0.0
),
m_backgroundTexture
);
// draw backdrop (independent parallel projection)
glMaterialfv
(
GL_FRONT
,
GL_AMBIENT_AND_DIFFUSE
,
mat_specular
);
glTranslatef
(
0.0
,
0.0
,
-
501.0
);
drawTexture
(
QPointF
(
0.0
,
0.0
),
m_backgroundTexture
);
// restore original state
glMatrixMode
(
GL_PROJECTION
);
glPopMatrix
();
glMatrixMode
(
GL_MODELVIEW
);
// restore original state
glMatrixMode
(
GL_PROJECTION
);
}
glPopMatrix
();
glMatrixMode
(
GL_MODELVIEW
);
}
glPopMatrix
();
// draw orbital planes
...
...
@@ -383,29 +399,33 @@ void PulsarAnimationWidget::paintGL()
// companion's plane (only if not identical with pulsar's)
if
(
m_companionSemiMajorAxis
!=
m_pulsarSemiMajorAxis
)
{
glPushMatrix
();
glRotatef
(
90.0
,
1.0
,
0.0
,
0.0
);
// separate them slightly in case of overlap
// based on ugly mass diff check (no collision detection)
// single known problematic pair: (m_c=1.4, m_p=1.5)
if
((
int
)(
10
*
(
m_pulsarMass
-
m_companionMass
)
+
0.5
)
==
1
){
glTranslatef
(
0.0
,
0.0
,
0.01
);
{
glRotatef
(
90.0
,
1.0
,
0.0
,
0.0
);
// separate them slightly in case of overlap
// based on ugly mass diff check (no collision detection)
// single known problematic pair: (m_c=1.4, m_p=1.5)
if
((
int
)(
10
*
(
m_pulsarMass
-
m_companionMass
)
+
0.5
)
==
1
){
glTranslatef
(
0.0
,
0.0
,
0.01
);
}
gluDisk
(
m_quadricCompanionOrbitPlane
,
m_companionSemiMajorAxis
-
sizeOffset
,
m_companionSemiMajorAxis
+
sizeOffset
,
64
,
1
);
}
gluDisk
(
m_quadricCompanionOrbitPlane
,
m_companionSemiMajorAxis
-
sizeOffset
,
m_companionSemiMajorAxis
+
sizeOffset
,
64
,
1
);
glPopMatrix
();
}
// pulsar's plane
glPushMatrix
();
glRotatef
(
90.0
,
1.0
,
0.0
,
0.0
);
gluDisk
(
m_quadricPulsarOrbitPlane
,
m_pulsarSemiMajorAxis
-
sizeOffset
,
m_pulsarSemiMajorAxis
+
sizeOffset
,
64
,
1
);
{
glRotatef
(
90.0
,
1.0
,
0.0
,
0.0
);
gluDisk
(
m_quadricPulsarOrbitPlane
,
m_pulsarSemiMajorAxis
-
sizeOffset
,
m_pulsarSemiMajorAxis
+
sizeOffset
,
64
,
1
);
}
glPopMatrix
();
}
}
...
...
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