Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ISBI2016-filaSimu-TM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vladimír Ulman
ISBI2016-filaSimu-TM
Commits
0d97e306
There was an error fetching the commit references. Please try again later.
Commit
0d97e306
authored
8 years ago
by
Vladimír Ulman
Browse files
Options
Downloads
Patches
Plain Diff
Added FOG, added 'display help', added bounding box.
parent
35f71027
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/graphics.cpp
+130
-22
130 additions, 22 deletions
src/graphics.cpp
src/main.cpp
+3
-3
3 additions, 3 deletions
src/main.cpp
with
133 additions
and
25 deletions
src/graphics.cpp
+
130
−
22
View file @
0d97e306
...
...
@@ -46,6 +46,10 @@ float zoom = 1.0;
bool
MouseActive
=
false
;
int
last_x
=
0
,
last_y
=
0
;
bool
showAxes
=
true
;
bool
showFrame
=
false
;
bool
showBox
=
true
;
bool
showWholeMesh
=
true
;
bool
showVertexSurface
=
false
;
bool
showQuadricSurface
=
false
;
...
...
@@ -76,7 +80,7 @@ void step(int count)
}
///draws
the
frame around the playground
///draws
a flat
frame around the playground
void
displayFrame
(
void
)
{
glColor3f
(
params
.
sceneBorderColour
.
r
,
...
...
@@ -91,6 +95,45 @@ void displayFrame(void)
glEnd
();
}
///draws a frame box around the playground
void
displayBox
(
void
)
{
glColor3f
(
params
.
sceneBorderColour
.
r
,
params
.
sceneBorderColour
.
g
,
params
.
sceneBorderColour
.
b
);
glLineWidth
(
1
);
//front square/plane
glBegin
(
GL_LINE_LOOP
);
glVertex3f
(
params
.
sceneOffset
.
x
,
params
.
sceneOffset
.
y
,
params
.
sceneOffset
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
+
params
.
sceneSize
.
x
,
params
.
sceneOffset
.
y
,
params
.
sceneOffset
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
+
params
.
sceneSize
.
x
,
params
.
sceneOffset
.
y
+
params
.
sceneSize
.
y
,
params
.
sceneOffset
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
,
params
.
sceneOffset
.
y
+
params
.
sceneSize
.
y
,
params
.
sceneOffset
.
z
);
glEnd
();
//rear square/plane
glBegin
(
GL_LINE_LOOP
);
glVertex3f
(
params
.
sceneOffset
.
x
,
params
.
sceneOffset
.
y
,
params
.
sceneOffset
.
z
+
params
.
sceneSize
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
+
params
.
sceneSize
.
x
,
params
.
sceneOffset
.
y
,
params
.
sceneOffset
.
z
+
params
.
sceneSize
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
+
params
.
sceneSize
.
x
,
params
.
sceneOffset
.
y
+
params
.
sceneSize
.
y
,
params
.
sceneOffset
.
z
+
params
.
sceneSize
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
,
params
.
sceneOffset
.
y
+
params
.
sceneSize
.
y
,
params
.
sceneOffset
.
z
+
params
.
sceneSize
.
z
);
glEnd
();
//sideways "connectors"
glBegin
(
GL_LINES
);
glVertex3f
(
params
.
sceneOffset
.
x
,
params
.
sceneOffset
.
y
,
params
.
sceneOffset
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
,
params
.
sceneOffset
.
y
,
params
.
sceneOffset
.
z
+
params
.
sceneSize
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
+
params
.
sceneSize
.
x
,
params
.
sceneOffset
.
y
,
params
.
sceneOffset
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
+
params
.
sceneSize
.
x
,
params
.
sceneOffset
.
y
,
params
.
sceneOffset
.
z
+
params
.
sceneSize
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
+
params
.
sceneSize
.
x
,
params
.
sceneOffset
.
y
+
params
.
sceneSize
.
y
,
params
.
sceneOffset
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
+
params
.
sceneSize
.
x
,
params
.
sceneOffset
.
y
+
params
.
sceneSize
.
y
,
params
.
sceneOffset
.
z
+
params
.
sceneSize
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
,
params
.
sceneOffset
.
y
+
params
.
sceneSize
.
y
,
params
.
sceneOffset
.
z
);
glVertex3f
(
params
.
sceneOffset
.
x
,
params
.
sceneOffset
.
y
+
params
.
sceneSize
.
y
,
params
.
sceneOffset
.
z
+
params
.
sceneSize
.
z
);
glEnd
();
}
void
displayAxes
(
void
)
{
glLineWidth
(
2
);
...
...
@@ -326,8 +369,11 @@ void display(void)
//0.0, cosf(-uhel_y), sinf(-uhel_y)); // up
0.0
,
1.0
,
0.0
);
// up
displayFrame
();
displayAxes
();
glEnable
(
GL_FOG
);
if
(
showBox
)
displayBox
();
if
(
showFrame
)
displayFrame
();
if
(
showAxes
)
displayAxes
();
glDisable
(
GL_FOG
);
if
(
showWholeMesh
)
mesh
.
displayMesh
();
if
(
showVertexSurface
)
mesh
.
displayVertexAndNeigs
();
...
...
@@ -382,7 +428,22 @@ void GetSceneViewSize(const int w,const int h,
void
printKeysHelp
(
void
)
{
std
::
cout
<<
"
\n
Keys:
\n
"
;
std
::
cout
<<
"ESC or 'q': quit
\n
"
;
std
::
cout
<<
"ESC or 'q': quit ENTER: enters empty line on a console
\n
"
;
std
::
cout
<<
"' ','n','z': simulation goes/stop at various steps
\n
"
;
std
::
cout
<<
"'r': resets the view
\n
"
;
std
::
cout
<<
"'o','O': zoom in,out
\n
"
;
std
::
cout
<<
"'h': displays this help
\n
"
;
std
::
cout
<<
"'d': displays enabled features,displays status
\n
"
;
std
::
cout
<<
"'m': toggle display of the mesh
\n
"
;
std
::
cout
<<
"'v': toggle display of the vertex supporting region
\n
"
;
std
::
cout
<<
"'V': chooses another vertex
\n
"
;
std
::
cout
<<
"'s': toggle display of the fitted quadratic surface
\n
"
;
std
::
cout
<<
"'t': toggle display of the test/debug function
\n
"
;
std
::
cout
<<
"'a': toggle display of the R,G,B <-> x,y,z axes
\n
"
;
std
::
cout
<<
"'f': toggle display of the frame/plane az z=0
\n
"
;
std
::
cout
<<
"'b': toggle display of the bounding box
\n
"
;
std
::
cout
<<
"'x','X': controls for some testing
\n
"
;
std
::
cout
<<
"'i': not used
\n
"
;
}
...
...
@@ -413,6 +474,9 @@ void keyboard(unsigned char key, int mx, int my)
case
'q'
:
//quit
exit
(
EXIT_SUCCESS
);
break
;
case
13
:
//Enter key -- just empty lines
std
::
cout
<<
std
::
endl
;
break
;
//control execution of the simulation
case
' '
:
//pause/unpause, refresh every 10 cycles
...
...
@@ -436,7 +500,7 @@ void keyboard(unsigned char key, int mx, int my)
step
(
1
);
break
;
//
etc stuff...
//
view params
case
'r'
:
//set scale 1:1
uhel_x
=
0.0
;
uhel_y
=
0.0
;
...
...
@@ -444,12 +508,6 @@ void keyboard(unsigned char key, int mx, int my)
glutReshapeWindow
(
int
(
params
.
imgSizeX
),
int
(
params
.
imgSizeY
));
glutPostRedisplay
();
break
;
case
'h'
:
//print help
printKeysHelp
();
break
;
case
'd'
:
//print what is displayed
printDispayedFeauters
();
break
;
case
'o'
:
zoom
-=
0.2
f
;
if
(
zoom
<
0.2
f
)
zoom
=
0.2
f
;
...
...
@@ -460,28 +518,61 @@ void keyboard(unsigned char key, int mx, int my)
glutPostRedisplay
();
break
;
case
'v'
:
++
VertexID
;
glutPostRedisplay
();
//control hints/help
case
'h'
:
//print help
printKeysHelp
();
break
;
case
'd'
:
//print what is displayed
printDispayedFeauters
();
break
;
case
'M'
:
//display objects
case
'm'
:
showWholeMesh
^=
true
;
glutPostRedisplay
();
break
;
case
'
V
'
:
case
'
v
'
:
showVertexSurface
^=
true
;
glutPostRedisplay
();
break
;
case
'Q'
:
case
'V'
:
++
VertexID
;
glutPostRedisplay
();
break
;
case
's'
:
showQuadricSurface
^=
true
;
glutPostRedisplay
();
break
;
case
'
T
'
:
case
'
t
'
:
showTEST
^=
true
;
glutPostRedisplay
();
break
;
//annotation controls
case
'a'
:
showAxes
^=
true
;
glutPostRedisplay
();
break
;
case
'f'
:
showFrame
^=
true
;
glutPostRedisplay
();
break
;
case
'b'
:
showBox
^=
true
;
glutPostRedisplay
();
break
;
//some testing controls
case
'x'
:
glEnable
(
GL_FOG
);
glutPostRedisplay
();
break
;
case
'X'
:
glDisable
(
GL_FOG
);
glutPostRedisplay
();
break
;
case
'i'
:
//inspect a cell
GetSceneViewSize
(
windowSizeX
,
windowSizeY
,
xVisF
,
xVisT
,
yVisF
,
yVisT
);
sx
=
(
float
)
mx
/
(
float
)
windowSizeX
*
(
xVisT
-
xVisF
)
+
xVisF
;
...
...
@@ -499,9 +590,6 @@ void keyboard(unsigned char key, int mx, int my)
}
*/
break
;
case
13
:
//Enter key -- just empty lines
std
::
cout
<<
std
::
endl
;
break
;
}
}
...
...
@@ -607,6 +695,7 @@ void initializeGL(void)
glutInit
(
&
Argc
,
Argv
);
glutInitDisplayMode
(
GLUT_DOUBLE
|
GLUT_RGBA
);
//glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize
(
800
,
800
);
glutInitWindowPosition
(
600
,
100
);
glutCreateWindow
(
Argv
[
0
]);
...
...
@@ -620,10 +709,29 @@ void initializeGL(void)
glutMotionFunc
(
MouseMotion
);
glClearColor
(
0.0
,
0.0
,
0.0
,
0.0
);
//enables alfa-blending for every object/drawing
glEnable
(
GL_BLEND
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
glEnable
(
GL_POINT_SMOOTH
);
glEnable
(
GL_CULL_FACE
);
//glEnable(GL_CULL_FACE);
//glEnable(GL_DEPTH_TEST);
//enable fog:
//glEnable(GL_FOG);
glFogi
(
GL_FOG_MODE
,
GL_LINEAR
);
GLfloat
fogColor
[
4
]
=
{
0.4
f
*
params
.
sceneBorderColour
.
r
,
0.4
f
*
params
.
sceneBorderColour
.
g
,
0.4
f
*
params
.
sceneBorderColour
.
b
,
1.0
f
};
//has no effect
glFogfv
(
GL_FOG_COLOR
,
fogColor
);
//density is not required in linear mode
//glFogf(GL_FOG_DENSITY,0.3f);
//glHint(GL_FOG_HINT,GL_NICEST); //TODO adjust later
glFogf
(
GL_FOG_START
,
params
.
sceneOffset
.
z
);
glFogf
(
GL_FOG_END
,
params
.
sceneOffset
.
z
+
params
.
sceneSize
.
z
);
}
void
loopGL
(
void
)
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
+
3
−
3
View file @
0d97e306
...
...
@@ -73,9 +73,9 @@ void ParamsSetup(void)
params
.
sceneCentre
+=
params
.
sceneOffset
;
params
.
sceneOuterBorder
=
Vector3d
<
float
>
(
2.
f
);
params
.
sceneBorderColour
.
r
=
0.
5
f
;
params
.
sceneBorderColour
.
g
=
0.
5
f
;
params
.
sceneBorderColour
.
b
=
0.
5
f
;
params
.
sceneBorderColour
.
r
=
0.
7
f
;
params
.
sceneBorderColour
.
g
=
0.
7
f
;
params
.
sceneBorderColour
.
b
=
0.
0
f
;
params
.
inputCellsFilename
=
"cells/cell%d.txt"
;
params
.
numberOfAgents
=
2
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment