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
S
SocialAgents3D
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
Thomas Pitiot
SocialAgents3D
Commits
d03c2c80
Commit
d03c2c80
authored
Oct 23, 2012
by
David Cazier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nettoyage des scenarios
parent
1931a221
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
488 additions
and
715 deletions
+488
-715
include/env_map.h
include/env_map.h
+1
-1
include/simulator.h
include/simulator.h
+4
-2
include/viewer.h
include/viewer.h
+3
-7
src/env_map.cpp
src/env_map.cpp
+25
-0
src/moving_obstacle.cpp
src/moving_obstacle.cpp
+1
-1
src/simulator.cpp
src/simulator.cpp
+298
-545
src/viewer.cpp
src/viewer.cpp
+156
-159
No files found.
include/env_map.h
View file @
d03c2c80
...
...
@@ -254,7 +254,7 @@ inline void EnvMap::nbAgentsDecrease(Dart d)
inline
void
EnvMap
::
pushAgentInCells
(
Agent
*
agent
,
Dart
d
)
{
assert
(
map
.
getCurrentLevel
()
==
map
.
getMaxLevel
())
;
assert
(
std
::
find
(
agentvect
[
d
].
begin
(),
agentvect
[
d
].
end
(),
agent
)
==
agentvect
[
d
].
end
());
//
assert(std::find(agentvect[d].begin(), agentvect[d].end(), agent) == agentvect[d].end());
agentvect
[
d
].
push_back
(
agent
)
;
// nbAgentsIncrease(d);
...
...
include/simulator.h
View file @
d03c2c80
...
...
@@ -86,11 +86,13 @@ public:
~
Simulator
()
;
void
init
(
unsigned
int
config
,
int
minSize
,
float
dimension
,
bool
enablePathFinding
=
false
)
;
void
setupCircleScenario
(
unsigned
int
nb
MaxAgent
)
;
void
setupCorridorScenario
(
unsigned
int
nb
MaxAgent
)
;
void
setupCircleScenario
(
unsigned
int
nb
Agents
)
;
void
setupCorridorScenario
(
unsigned
int
nb
Agents
,
unsigned
int
nbObstacles
)
;
void
setupCityScenario
(
int
nbLines
,
int
nbRank
)
;
void
setupScenario
(
unsigned
int
nbMaxAgent
)
;
void
addAgent
(
const
VEC3
&
start
,
const
VEC3
&
goal
);
void
doStep
()
;
bool
reachedGoal
()
;
...
...
include/viewer.h
View file @
d03c2c80
...
...
@@ -76,13 +76,9 @@ public:
// Number of iterations before stopping the animation (0 if interactive animation)
int
maxIterations
;
// to count fps
clock_t
lastUpdate
;
bool
displayFps
;
float
fps
;
float
fpssum
;
float
fpsmoy
;
int
nb_count
;
int
frames
;
int
frames
;
clock_t
nextUpdate
;
Simulator
sim
;
SelectorTrue
allDarts
;
...
...
src/env_map.cpp
View file @
d03c2c80
...
...
@@ -905,6 +905,18 @@ void EnvMap::addAgentInGrid(Agent* a)
void
EnvMap
::
addAgentInGrid
(
Agent
*
a
,
Geom
::
Vec2ui
c
)
{
ht_agents
[
c
].
push_back
(
a
)
;
for
(
int
ii
=
-
1
;
ii
<=
1
;
++
ii
)
{
for
(
int
jj
=
-
1
;
jj
<=
1
;
++
jj
)
{
if
(
!
(
ii
==
0
&&
jj
==
0
))
{
Geom
::
Vec2ui
cc
=
c
+
Geom
::
Vec2ui
(
ii
,
jj
)
;
ht_neighbor_agents
[
cc
].
push_back
(
a
)
;
}
}
}
}
void
EnvMap
::
removeAgentFromGrid
(
Agent
*
a
)
...
...
@@ -917,6 +929,19 @@ void EnvMap::removeAgentFromGrid(Agent* a, Geom::Vec2ui c)
{
removeElementFromVector
<
Agent
*>
(
ht_agents
[
c
],
a
)
;
if
(
ht_agents
[
c
].
empty
())
ht_agents
.
erase
(
c
)
;
for
(
int
ii
=
-
1
;
ii
<=
1
;
++
ii
)
{
for
(
int
jj
=
-
1
;
jj
<=
1
;
++
jj
)
{
if
(
!
(
ii
==
0
&&
jj
==
0
))
{
Geom
::
Vec2ui
cc
=
c
+
Geom
::
Vec2ui
(
ii
,
jj
)
;
removeElementFromVector
<
Agent
*>
(
ht_neighbor_agents
[
cc
],
a
)
;
if
(
ht_neighbor_agents
[
c
].
empty
())
ht_neighbor_agents
.
erase
(
c
)
;
}
}
}
}
#endif
src/moving_obstacle.cpp
View file @
d03c2c80
...
...
@@ -34,7 +34,7 @@ bool MovingObstacle::is_inside(VEC3 p)
float
get_angle
(
VEC3
v1
,
VEC3
v2
)
{
float
flo
;
float
flo
=
0.0
f
;
float
nb
=
std
::
sqrt
(
v1
.
norm2
()
*
v2
.
norm2
());
if
(
nb
!=
0
)
...
...
src/simulator.cpp
View file @
d03c2c80
This diff is collapsed.
Click to expand it.
src/viewer.cpp
View file @
d03c2c80
...
...
@@ -26,7 +26,7 @@
#include "env_generator.h"
#include <string>
SocialAgents
::
SocialAgents
(
int
minSize
,
int
iterations
)
:
SocialAgents
::
SocialAgents
(
int
minSize
,
int
iterations
)
:
nbIterations
(
0
),
maxIterations
(
iterations
),
frames
(
0
),
...
...
@@ -46,30 +46,28 @@ SocialAgents::SocialAgents(int minSize,int iterations) :
timer
=
new
QTimer
(
this
)
;
connect
(
timer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
animate
()))
;
displayFps
=
true
;
fps
=
0
;
fpssum
=
0
;
fpsmoy
=
0
;
nb_count
=
0
;
glEnable
(
GL_POINT_SMOOTH
);
nextUpdate
=
clock
()
;
glEnable
(
GL_POINT_SMOOTH
)
;
}
void
SocialAgents
::
initGUI
()
{
setDock
(
&
dock
)
;
dock
.
check_drawEnvLines
->
setChecked
(
true
)
;
dock
.
check_drawEnvFaces
->
setChecked
(
true
)
;
dock
.
check_drawAgents
->
setChecked
(
true
)
;
dock
.
check_drawMovingObstacles
->
setChecked
(
true
)
;
dock
.
check_dart
->
setChecked
(
false
)
;
dock
.
check_drawEnvLines
->
setChecked
(
drawEnvLines
)
;
dock
.
check_drawEnvFaces
->
setChecked
(
drawEnvFaces
)
;
dock
.
check_drawAgents
->
setChecked
(
drawAgents
)
;
dock
.
check_drawMovingObstacles
->
setChecked
(
drawMovingObstacles
)
;
dock
.
check_dart
->
setChecked
(
draw_dart
)
;
setCallBack
(
dock
.
check_timer
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_timer
(
bool
)))
;
setCallBack
(
dock
.
check_drawEnvLines
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawEnvLines
(
bool
)))
;
setCallBack
(
dock
.
check_drawEnvFaces
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawEnvFaces
(
bool
)))
;
setCallBack
(
dock
.
check_drawEnvTopo
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawEnvTopo
(
bool
)))
;
setCallBack
(
dock
.
check_drawObstacles
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawObstacles
(
bool
)))
;
setCallBack
(
dock
.
check_drawMovingObstacles
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawMovingObstacles
(
bool
)))
;
setCallBack
(
dock
.
check_drawMovingObstacles
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawMovingObstacles
(
bool
)))
;
setCallBack
(
dock
.
check_drawAgents
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawAgents
(
bool
)))
;
setCallBack
(
dock
.
check_drawAgentsPredictionTri
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawAgentsPredictionTri
(
bool
)))
;
...
...
@@ -77,8 +75,8 @@ void SocialAgents::initGUI()
SLOT
(
slot_drawAgentsNeighborDist
(
bool
)))
;
setCallBack
(
dock
.
check_drawAgentsObstacleDist
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_drawAgentsObstacleDist
(
bool
)))
;
setCallBack
(
dock
.
check_dart
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_dart
(
bool
))
)
;
setCallBack
(
dock
.
check_slide
,
SIGNAL
(
valueChanged
(
int
)),
SLOT
(
slot_slide
(
int
)))
;
setCallBack
(
dock
.
check_dart
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_dart
(
bool
)))
;
setCallBack
(
dock
.
check_slide
,
SIGNAL
(
valueChanged
(
int
)),
SLOT
(
slot_slide
(
int
)))
;
}
void
SocialAgents
::
cb_initGL
()
...
...
@@ -98,11 +96,11 @@ void SocialAgents::cb_initGL()
void
SocialAgents
::
cb_redraw
()
{
dock
.
check_slide
->
setRange
(
0
,
sim
.
envMap_
.
map
.
end
().
index
)
;
dock
.
check_slide
->
setRange
(
0
,
sim
.
envMap_
.
map
.
end
().
index
)
;
glDisable
(
GL_LIGHTING
)
;
glColor3f
(
0.
0
f
,
0.0
f
,
0.0
f
)
;
glColor3f
(
0.
3
f
,
0.3
f
,
0.3
f
)
;
glBegin
(
GL_LINES
)
;
glVertex3f
(
0.0
f
,
0.0
f
,
0.0
f
)
;
glVertex3f
(
1.0
f
,
0.0
f
,
0.0
f
)
;
...
...
@@ -114,45 +112,43 @@ void SocialAgents::cb_redraw()
glVertex3f
(
0.0
f
,
0.0
f
,
1.0
f
)
;
glEnd
()
;
#ifdef SPATIAL_HASHING
glPointSize
(
1.0
f
)
;
glBegin
(
GL_POINTS
)
;
VEC3
p
=
sim
.
envMap_
.
origin
;
p
*=
-
1.0
f
;
p
[
1
]
-=
15.0
f
;
for
(
unsigned
int
i
=
0
;
i
<
sim
.
envMap_
.
ht_agents
.
size
();
++
i
)
{
HashTable2D
<
std
::
vector
<
Agent
*>
>::
cell_type
&
c
=
sim
.
envMap_
.
ht_agents
.
cell
(
i
)
;
unsigned
int
nbelem
=
c
.
size
()
;
for
(
unsigned
int
k
=
0
;
k
<
nbelem
;
++
k
)
{
VEC3
pp
=
p
;
pp
[
0
]
+=
(
float
(
i
)
/
float
(
sim
.
envMap_
.
ht_agents
.
size
())
)
*
70
*
24
;
pp
[
1
]
+=
k
;
glVertex3fv
(
pp
.
data
())
;
}
}
glEnd
()
;
#endif
//
#ifdef SPATIAL_HASHING
//
glPointSize(1.0f) ;
//
glBegin(GL_POINTS) ;
//
VEC3 p = sim.envMap_.origin ;
//
p *= -1.0f ;
//
p[1] -= 15.0f ;
//
for(unsigned int i = 0; i < sim.envMap_.ht_agents.size(); ++i)
//
{
//
HashTable2D<std::vector<Agent*> >::cell_type& c = sim.envMap_.ht_agents.cell(i) ;
//
unsigned int nbelem = c.size() ;
//
for(unsigned int k = 0; k < nbelem; ++k)
//
{
//
VEC3 pp = p ;
//
pp[0] += ( float(i) / float(sim.envMap_.ht_agents.size()) ) * 70 * 24 ;
//
pp[1] += k ;
//
glVertex3fv(pp.data()) ;
//
}
//
}
//
glEnd() ;
//
#endif
if
(
draw_dart
)
{
if
(
dartSlider
<
(
sim
.
envMap_
.
map
.
end
().
index
))
{
glColor3f
(
1.0
f
,
0.0
f
,
0.0
f
);
glLineWidth
(
5.0
f
);
renderDart
(
sim
.
envMap_
,
dartSlider
);
glColor3f
(
1.0
f
,
0.0
f
,
0.0
f
)
;
glLineWidth
(
5.0
f
)
;
renderDart
(
sim
.
envMap_
,
dartSlider
)
;
}
}
if
(
drawAgents
)
{
for
(
std
::
vector
<
Agent
*>::
iterator
it
=
sim
.
agents_
.
begin
()
;
it
!=
sim
.
agents_
.
end
()
;
++
it
)
for
(
std
::
vector
<
Agent
*>::
iterator
it
=
sim
.
agents_
.
begin
()
;
it
!=
sim
.
agents_
.
end
()
;
++
it
)
{
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
);
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
)
;
renderAgent
(
sim
.
envMap_
,
*
it
,
drawAgentsNeighborDist
,
drawAgentsObstacleDist
,
(
*
it
)
->
color1
,(
*
it
)
->
color2
,(
*
it
)
->
color3
)
;
(
*
it
)
->
color1
,
(
*
it
)
->
color2
,
(
*
it
)
->
color3
)
;
// for (std::vector<std::pair<float, Dart> >::iterator obst = (*it)->obstacleNeighbors_.begin();
// obst != (*it)->obstacleNeighbors_.end() && obst->first < (*it)->rangeSq_; ++obst)
...
...
@@ -162,7 +158,6 @@ void SocialAgents::cb_redraw()
// renderDart(sim.envMap_, obst->second) ;
// }
}
// CellMarker m(sim.envMap_.map, FACE) ;
...
...
@@ -223,33 +218,32 @@ void SocialAgents::cb_redraw()
// }
}
if
(
drawMovingObstacles
)
{
if
(
drawMovingObstacles
)
{
MovingObstacle
*
mo
;
for
(
std
::
vector
<
MovingObstacle
*
>::
iterator
it
=
sim
.
movingObstacles_
.
begin
()
;
it
!=
sim
.
movingObstacles_
.
end
()
;
++
it
)
for
(
std
::
vector
<
MovingObstacle
*>::
iterator
it
=
sim
.
movingObstacles_
.
begin
()
;
it
!=
sim
.
movingObstacles_
.
end
()
;
++
it
)
{
mo
=
*
it
;
mo
=
*
it
;
// VEC3 pos = (*it)->finalGoal;
// glColor3f(1.0f, 0.8f, 0.0f);
// glBegin(GL_POLYGON);
// for(unsigned int i = 0; i < 5; ++i)
// glVertex3f(pos[0] + (cosT[i] * 1.5f), pos[1] + (sinT[i] * 1.5f), pos[2]+0.01f);
// glEnd();
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
);
glColor3f
(
0.0
f
,
0.0
f
,
1.0
f
)
;
glLineWidth
(
1.0
f
)
;
glBegin
(
GL_POLYGON
);
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
)
;
glColor3f
(
0.0
f
,
0.0
f
,
1.0
f
)
;
glLineWidth
(
1.0
f
)
;
glBegin
(
GL_POLYGON
)
;
for
(
unsigned
int
i
=
0
;
i
<
((
*
it
)
->
nbVertices
)
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
((
*
it
)
->
nbVertices
)
;
++
i
)
{
float
*
p
=
(
*
it
)
->
obstacles_
[
i
]
->
p1
.
data
()
;
p
[
2
]
=
0.01
f
;
glVertex3fv
(
p
);
float
*
p
=
(
*
it
)
->
obstacles_
[
i
]
->
p1
.
data
()
;
p
[
2
]
=
0.01
f
;
glVertex3fv
(
p
)
;
}
glEnd
();
glEnd
()
;
//display collision avoidance circle
// glColor3f(1.0f, 0.8f, 0.0f);
// VEC3 pos =mo->center;
...
...
@@ -260,9 +254,7 @@ void SocialAgents::cb_redraw()
// glEnd();
//
//////
//////
// for(unsigned int i = 0; i < ((*it)->nbVertices); ++i)
// {
//
...
...
@@ -279,7 +271,7 @@ void SocialAgents::cb_redraw()
//
// }
//affiche les cases ou se sont enregistrés les obstacles
//affiche les cases ou se sont enregistrés les obstacles
//
// glColor3f(1.0f, 0.5f, 0.5f);
// glLineWidth(5.0f);
...
...
@@ -294,7 +286,7 @@ void SocialAgents::cb_redraw()
// glLineWidth(1.0f);
}
// affiche les cases de la map qui ont des obstacles
// affiche les cases de la map qui ont des obstacles
// glColor3f(1.0f, 0.5f, 0.5f);
// glLineWidth(5.0f);
// int nb =0;
...
...
@@ -312,16 +304,16 @@ void SocialAgents::cb_redraw()
// }
// }
}
}
#ifndef SPATIAL_HASHING
if
(
drawAgentsPredictionTri
)
{
for
(
std
::
vector
<
Agent
*>::
iterator
it
=
sim
.
agents_
.
begin
()
;
it
!=
sim
.
agents_
.
end
()
;
++
it
)
for
(
std
::
vector
<
Agent
*>::
iterator
it
=
sim
.
agents_
.
begin
()
;
it
!=
sim
.
agents_
.
end
()
;
++
it
)
{
glColor3f
((
*
it
)
->
part_
.
getState
()
/
3.0
f
,
(
*
it
)
->
part_
.
getState
()
%
2
,
0.0
f
)
;
glLineWidth
(
1.0
f
);
renderPredictionTriangle
(
sim
.
envMap_
,
(
*
it
)
->
part_
.
d
,
(
*
it
)
->
getPosition
());
glLineWidth
(
1.0
f
)
;
renderPredictionTriangle
(
sim
.
envMap_
,
(
*
it
)
->
part_
.
d
,
(
*
it
)
->
getPosition
())
;
}
}
#endif
...
...
@@ -329,9 +321,9 @@ void SocialAgents::cb_redraw()
//draw the environment
if
(
drawEnvLines
)
{
glDisable
(
GL_LIGHTING
);
glColor3f
(
0.
0
f
,
0.0
f
,
0.0
f
);
glLineWidth
(
1.0
f
);
glDisable
(
GL_LIGHTING
)
;
glColor3f
(
0.
8
f
,
0.8
f
,
0.8
f
);
glLineWidth
(
1.0
f
)
;
#ifdef SPATIAL_HASHING
glBegin
(
GL_LINES
)
;
...
...
@@ -371,7 +363,7 @@ void SocialAgents::cb_redraw()
// 1.0, sim.envMap_.positionScenary,
// sim.envMap_.normalScenary) ;
#endif
}
}
if
(
drawEnvTopo
)
{
...
...
@@ -383,13 +375,13 @@ void SocialAgents::cb_redraw()
if
(
drawObstacles
)
{
CellMarker
<
FACE
>
dmo
(
sim
.
envMap_
.
map
);
for
(
Dart
d
=
sim
.
envMap_
.
map
.
begin
();
d
!=
sim
.
envMap_
.
map
.
end
()
;
sim
.
envMap_
.
map
.
next
(
d
))
CellMarker
<
FACE
>
dmo
(
sim
.
envMap_
.
map
)
;
for
(
Dart
d
=
sim
.
envMap_
.
map
.
begin
()
;
d
!=
sim
.
envMap_
.
map
.
end
()
;
sim
.
envMap_
.
map
.
next
(
d
))
{
if
(
!
dmo
.
isMarked
(
d
))
{
glColor3f
(
0.0
f
,
0.0
f
,
1.0
f
);
glLineWidth
(
3.0
f
);
glColor3f
(
0.0
f
,
0.0
f
,
1.0
f
)
;
glLineWidth
(
3.0
f
)
;
///show buildings
// if(sim.envMap_.buildingMark.isMarked(d))
...
...
@@ -397,16 +389,16 @@ void SocialAgents::cb_redraw()
// renderFace(sim.envMap_,d);
// }
///count neighbor obst
///count neighbor obst
// if (sim.envMap_.neighborObstvect[d].size()!=0)
// CGoGNout<<"Cellule : "<<d<<" obstacles voisins : "<< sim.envMap_.neighborObstvect[d].size()<<CGoGNendl;
dmo
.
mark
(
d
);
if
((
sim
.
envMap_
.
obstvect
[
d
].
size
())
!=
0
)
if
((
sim
.
envMap_
.
obstvect
[
d
].
size
())
!=
0
)
{
renderFace
(
sim
.
envMap_
,
d
)
;
renderFace
(
sim
.
envMap_
,
d
)
;
// CGoGNout<<"Dart : "<< d << " contient "<<sim.envMap_.obstvect[d].size()<< "obstacles"<<CGoGNendl;
// for(std::vector<Obstacle*>::iterator it =sim.envMap_.obstvect[d].begin(); it!= sim.envMap_.obstvect[d].end(); ++it)
...
...
@@ -456,20 +448,27 @@ void SocialAgents::cb_redraw()
#endif
}
if
(
drawEnvFaces
)
{
glEnable
(
GL_LIGHTING
)
;
glColor3f
(
1.0
f
,
1.0
f
,
1.0
f
)
;
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
)
;
glEnable
(
GL_POLYGON_OFFSET_FILL
)
;
glPolygonOffset
(
1.0
f
,
1.0
f
)
;
Algo
::
Render
::
GL1
::
renderTriQuadPoly
<
PFP
>
(
sim
.
envMap_
.
map
,
Algo
::
Render
::
GL1
::
LINE
,
1.0
,
sim
.
envMap_
.
position
,
sim
.
envMap_
.
normal
)
;
if
(
drawEnvFaces
)
{
glEnable
(
GL_LIGHTING
)
;
glColor3f
(
1.0
f
,
1.0
f
,
0.5
f
)
;
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
)
;
glEnable
(
GL_POLYGON_OFFSET_FILL
)
;
glPolygonOffset
(
1.0
f
,
1.0
f
)
;
Algo
::
Render
::
GL1
::
renderTriQuadPoly
<
PFP
>
(
sim
.
envMap_
.
map
,
Algo
::
Render
::
GL1
::
LINE
,
1.0
,
sim
.
envMap_
.
position
,
sim
.
envMap_
.
normal
)
;
// Algo::Render::GL1::renderTriQuadPoly<PFP>(sim.envMap_.mapScenary, Algo::Render::GL1::LINE,
// 1.0, sim.envMap_.positionScenary,
// sim.envMap_.normalScenary) ;
}
}
// renderDart(sim.envMap_, 264) ;
//
// glPushMatrix() ;
// glBegin(GL_LINES) ;
// unsigned int iter = 100 ;
// for (int i = 0; i < 700; i = i + iter)
// {
// VEC3 camPos(-800, -800, 10) ;
// camPos = camPos + VEC3(-10 - 0.3 * i, 400.0f * log(1.0f + i / 700.0f), 30 + 0.3 * i) ;
...
...
@@ -561,27 +560,24 @@ if (drawEnvFaces)
++
frames
;
clock_t
time
=
clock
()
;
if
(
frames
>
100
)
if
(
time
>
nextUpdate
)
{
clock_t
elapsedTime
=
time
-
lastUpdate
;
lastUpdate
=
time
;
// Sortie des stats pour analyse externe
int
fps
=
frames
*
CLOCKS_PER_SEC
/
elapsedTime
;
std
::
cout
<<
1000
*
elapsedTime
/
CLOCKS_PER_SEC
<<
";"
<<
fps
<<
std
::
endl
;
std
::
cout
<<
time
/
CLOCKS_PER_SEC
<<
";"
<<
frames
<<
";"
<<
sim
.
nbUpdates
<<
";"
<<
sim
.
totalNeighbors
<<
";"
<<
sim
.
nearNeighbors
<<
";"
<<
sim
.
nbSorts
<<
";"
<<
sim
.
nbRefineCandidate
<<
";"
<<
sim
.
nbCoarsenCandidate
<<
std
::
endl
;
// Affichage des stats dans la barre d'état
std
::
ostringstream
oss
;
oss
<<
"Elapsed time : "
<<
time
/
CLOCKS_PER_SEC
;
oss
<<
" | "
<<
f
p
s
<<
" fps"
;
oss
<<
" | "
<<
f
rame
s
<<
" fps"
;
oss
<<
" | Iterations "
<<
nbIterations
;
oss
<<
" | Neighbors "
<<
sim
.
totalNeighbors
<<
" ["
<<
sim
.
totalNeighbors
/
sim
.
nbUpdates
<<
"]"
;
oss
<<
" | Near Neighbors "
<<
sim
.
nearNeighbors
<<
" ["
<<
sim
.
nearNeighbors
/
sim
.
nbUpdates
<<
"]"
;
oss
<<
" | Sorts "
<<
sim
.
nbSorts
<<
" ["
<<
100
*
sim
.
nbSorts
/
sim
.
nbUpdates
<<
"%]"
;
#ifndef SPATIAL_HASHING_H
oss
<<
" | To Refine "
<<
sim
.
nbRefineCandidate
;
oss
<<
" | To Coarsen "
<<
sim
.
nbCoarsenCandidate
;
#endif
sim
.
nbUpdates
=
0
;
sim
.
totalNeighbors
=
0
;
sim
.
nearNeighbors
=
0
;
...
...
@@ -591,7 +587,7 @@ if (drawEnvFaces)
glColor3f
(
1.0
f
,
1.0
f
,
1.0
f
)
;
statusMsg
(
oss
.
str
().
c_str
())
;
frames
=
0
;
nextUpdate
=
time
+
CLOCKS_PER_SEC
;
}
}
...
...
@@ -755,12 +751,12 @@ void SocialAgents::exportInfoFace(std::ofstream& out, Dart d)
//draw vectors
//contains
for
(
unsigned
int
i
=
0
;
i
<
sim
.
envMap_
.
agentvect
[
d
].
size
()
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
sim
.
envMap_
.
agentvect
[
d
].
size
()
;
++
i
)
{
Agent
*
ag
=
sim
.
envMap_
.
agentvect
[
d
][
i
]
;
int
j
=
0
;
for
(
unsigned
int
iA
=
0
;
iA
<
sim
.
agents_
.
size
()
;
++
iA
)
for
(
unsigned
int
iA
=
0
;
iA
<
sim
.
agents_
.
size
()
;
++
iA
)
{
if
(
sim
.
agents_
[
iA
]
==
ag
)
{
...
...
@@ -817,12 +813,12 @@ void SocialAgents::exportInfoFace(std::ofstream& out, Dart d)
}
//neighbours
for
(
unsigned
int
i
=
0
;
i
<
sim
.
envMap_
.
neighborAgentvect
[
d
].
size
()
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
sim
.
envMap_
.
neighborAgentvect
[
d
].
size
()
;
++
i
)
{
Agent
*
ag
=
sim
.
envMap_
.
neighborAgentvect
[
d
][
i
]
;
int
j
=
0
;
for
(
unsigned
int
iA
=
0
;
iA
<
sim
.
agents_
.
size
()
;
++
iA
)
for
(
unsigned
int
iA
=
0
;
iA
<
sim
.
agents_
.
size
()
;
++
iA
)
{
if
(
sim
.
agents_
[
iA
]
==
ag
)
{
...
...
@@ -1000,7 +996,7 @@ bool SocialAgents::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std
// out << "}" << std::endl ;
// }
for
(
unsigned
int
i
=
0
;
i
<
sim
.
agents_
.
size
()
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
sim
.
agents_
.
size
()
;
++
i
)
{
int
typeOfAgent
=
0
;
if
(
draft
)
...
...
@@ -1088,7 +1084,7 @@ bool SocialAgents::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std
{
out
<<
"sphere_sweep { cubic_spline"
<<
std
::
endl
;
out
<<
sim
.
agents_
[
i
]
->
goals_
.
size
()
<<
","
<<
std
::
endl
;
for
(
unsigned
int
j
=
0
;
j
<
sim
.
agents_
[
i
]
->
goals_
.
size
()
;
++
j
)
for
(
unsigned
int
j
=
0
;
j
<
sim
.
agents_
[
i
]
->
goals_
.
size
()
;
++
j
)
{
out
<<
"<"
<<
sim
.
agents_
[
i
]
->
goals_
[
j
][
0
]
<<
","
<<
sim
.
agents_
[
i
]
->
goals_
[
j
][
2
]
<<
","
<<
sim
.
agents_
[
i
]
->
goals_
[
j
][
1
]
<<
">, 4"
<<
std
::
endl
;
...
...
@@ -1103,8 +1099,8 @@ bool SocialAgents::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std
if
(
infoFaces
)
{
CellMarker
<
FACE
>
m
(
sim
.
envMap_
.
map
);
for
(
Dart
d
=
sim
.
envMap_
.
map
.
begin
()
;
d
!=
sim
.
envMap_
.
map
.
end
()
;
sim
.
envMap_
.
map
.
next
(
d
))
CellMarker
<
FACE
>
m
(
sim
.
envMap_
.
map
)
;
for
(
Dart
d
=
sim
.
envMap_
.
map
.
begin
()
;
d
!=
sim
.
envMap_
.
map
.
end
()
;
sim
.
envMap_
.
map
.
next
(
d
))
{
if
(
!
m
.
isMarked
(
d
))
{
...
...
@@ -1121,7 +1117,7 @@ bool SocialAgents::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std
//find the cells to highlight
DartMarkerStore
highlight
(
map
)
;
Agent
*
ag
=
sim
.
agents_
[
highlightAgentNo
]
;
for
(
Dart
d
=
map
.
begin
()
;
d
!=
map
.
end
()
;
map
.
next
(
d
))
for
(
Dart
d
=
map
.
begin
()
;
d
!=
map
.
end
()
;
map
.
next
(
d
))
{
if
(
!
highlight
.
isMarked
(
d
))
{
...
...
@@ -1223,76 +1219,76 @@ void SocialAgents::cb_keyPress(int keycode)
{
case
'a'
:
{
if
(
timer
->
isActive
())
timer
->
stop
()
;
else
timer
->
start
()
;
dock
.
check_timer
->
setChecked
(
timer
->
isActive
())
;
break
;
}
if
(
timer
->
isActive
())
timer
->
stop
()
;
else
timer
->
start
()
;
dock
.
check_timer
->
setChecked
(
timer
->
isActive
())
;
break
;
}
case
'c'
:
{
sim
.
envMap_
.
map
.
check
()
;
break
;
}
sim
.
envMap_
.
map
.
check
()
;
break
;
}
case
'e'
:
{
std
::
cout
<<
"exporting obstacle to file myScene.obst"
<<
std
::
endl
;
std
::
string
filename
(
"myScene.obst"
)
;
CGoGN
::
ExportScene
::
exportSceneToFile
<
PFP
>
(
sim
.
envMap_
.
map
,
sim
.
envMap_
.
position
,
sim
.
envMap_
.
obstacleMark
,
sim
.
envMap_
.
buildingMark
,
filename
)
;
std
::
string
filename2
(
"myAgents.pos"
)
;
sim
.
exportAgents
(
filename2
)
;
break
;
}
std
::
cout
<<
"exporting obstacle to file myScene.obst"
<<
std
::
endl
;
std
::
string
filename
(
"myScene.obst"
)
;
CGoGN
::
ExportScene
::
exportSceneToFile
<
PFP
>
(
sim
.
envMap_
.
map
,
sim
.
envMap_
.
position
,
sim
.
envMap_
.
obstacleMark
,
sim
.
envMap_
.
buildingMark
,
filename
)
;
std
::
string
filename2
(
"myAgents.pos"
)
;
sim
.
exportAgents
(
filename2
)
;
break
;
}
case
'p'
:
{
std
::
cout
<<
sim
.
globalTime_
<<
std
::
endl
;
break
;
}
std
::
cout
<<
sim
.
globalTime_
<<
std
::
endl
;
break
;
}
#ifndef SPATIAL_HASHING
case
'r'
:
{
exportScenePov
(
sim
.
envMap_
.
map
,
sim
.
envMap_
.
position
,
"planSerre/exportSceneOle0000.pov"
,
VEC3
(
10
,
3
,
10
),
VEC3
(
0
,
0
,
0
),
VEC3
(
1.0
f
,
0
,
0
),
0
,
0
,
0
)
;
exportScenePov
(
sim
.
envMap_
.
map
,
sim
.
envMap_
.
position
,
"planSerre/exportSceneOle0000.pov"
,
VEC3
(
10
,
3
,
10
),
VEC3
(
0
,
0
,
0
),
VEC3
(
1.0
f
,
0
,
0
),
0
,
0
,
0
)
;
// exportScenePov(sim.envMap_.map, sim.envMap_.position, "exportScene0002.pov",