Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Pitiot
SocialAgents3D
Commits
62edba1a
Commit
62edba1a
authored
Dec 12, 2012
by
David Cazier
Browse files
Merge cgogn:~jund/CGoGN_Apps/SA2
Conflicts: src/env_map.cpp src/viewer.cpp svg/mapBuild.svg
parents
60ec330d
ac85ddc2
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
include/env_generator.h
View file @
62edba1a
...
...
@@ -28,6 +28,9 @@ template <typename PFP>
Dart
extrudeFaceAndMark
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
Dart
d
,
CellMarker
<
FACE
>&
buildingMark
,
float
height
)
;
template
<
typename
PFP
>
Dart
extrudeBuilding
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
Dart
d
,
unsigned
int
buildingType
,
float
height
);
#ifndef SPATIAL_HASHING
template
<
typename
PFP
>
bool
animateCity
(
EnvMap
*
envMap
)
;
...
...
@@ -47,9 +50,15 @@ void generatePathToUpperStair(typename PFP::MAP& map, typename PFP::TVEC3& posit
/*******************************************************************************/
//template <typename PFP>
//void generatePlanet(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker<EDGE>& obstacleMark,
// CellMarker<FACE>& buildingMark, float radius, unsigned int nbSquares) ;
template
<
typename
PFP
>
void
generatePlanet
(
EnvMap
&
envMap
)
;
template
<
typename
PFP
>
void
generatePlanet
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
<
EDGE
>&
obstacleMark
,
CellMarker
<
FACE
>&
buildingMark
,
float
radius
,
unsigned
int
nbSquares
)
;
void
planetify
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
float
r
);
/*******************************************************************************/
...
...
include/env_generator.hpp
View file @
62edba1a
...
...
@@ -198,6 +198,71 @@ Dart extrudeFaceAndMark(typename PFP::MAP& map, typename PFP::TVEC3& position, D
return
dRoof
;
}
template
<
typename
PFP
>
Dart
extrudeBuilding
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
Dart
d
,
unsigned
int
buildingType
,
float
height
)
{
Dart
dRoof
;
VEC3
sky
(
0
,
0
,
1.0
f
);
dRoof
=
Algo
::
Modelisation
::
extrudeFace
<
PFP
>
(
map
,
position
,
d
,
sky
*
height
)
;
switch
(
buildingType
)
{
case
0
:
//basic
{
break
;
}
case
1
:
//with roof 1 slope
{
dRoof
=
Algo
::
Modelisation
::
extrudeFace
<
PFP
>
(
map
,
position
,
dRoof
,
sky
*
height
/
3.0
f
)
;
Dart
dNext
=
map
.
phi1
(
dRoof
)
;
Dart
dPrev
=
map
.
phi2
(
map
.
phi_1
(
dRoof
))
;
map
.
collapseEdge
(
dNext
)
;
map
.
collapseEdge
(
dPrev
)
;
break
;
}
case
2
:
//with roof 2 slopes
{
dRoof
=
Algo
::
Modelisation
::
extrudeFace
<
PFP
>
(
map
,
position
,
dRoof
,
sky
*
height
/
3.0
f
)
;
Dart
dNext
=
map
.
phi1
(
dRoof
)
;
Dart
dPrev
=
map
.
phi2
(
map
.
phi_1
(
dRoof
))
;
typename
PFP
::
VEC3
mid1
=
(
position
[
dNext
]
+
position
[
map
.
phi1
(
dNext
)])
/
2.0
f
;
typename
PFP
::
VEC3
mid2
=
(
position
[
dPrev
]
+
position
[
map
.
phi1
(
dPrev
)])
/
2.0
f
;
map
.
collapseEdge
(
dNext
)
;
map
.
collapseEdge
(
dPrev
)
;
position
[
dRoof
]
=
mid2
;
position
[
map
.
phi1
(
dRoof
)]
=
mid1
;
break
;
}
case
3
:
//with multiple stairs
{
unsigned
int
nbStairs
=
rand
()
%
5
;
for
(
unsigned
int
i
=
0
;
i
<
nbStairs
;
++
i
)
{
typename
PFP
::
VEC3
c
=
Algo
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
dRoof
,
position
)
;
Dart
dRoofSmall
=
Algo
::
Modelisation
::
extrudeFace
<
PFP
>
(
map
,
position
,
dRoof
,
0.0
f
)
;
Dart
dd
=
dRoofSmall
;
do
{
position
[
dd
]
=
position
[
dd
]
+
(
c
-
position
[
dd
])
/
3.0
f
;
dd
=
map
.
phi1
(
dd
)
;
}
while
(
dd
!=
dRoofSmall
)
;
dRoof
=
Algo
::
Modelisation
::
extrudeFace
<
PFP
>
(
map
,
position
,
dRoofSmall
,
sky
*
height
/
2.0
f
)
;
}
bool
spike
=
rand
()
%
2
;
if
(
spike
)
{
typename
PFP
::
VEC3
c
=
Algo
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
dRoof
,
position
)
;
c
[
2
]
+=
height
/
1.5
f
;
dRoof
=
Algo
::
Modelisation
::
trianguleFace
<
PFP
>
(
map
,
dRoof
)
;
position
[
dRoof
]
=
c
;
}
break
;
}
}
return
dRoof
;
}
#ifndef SPATIAL_HASHING
template
<
typename
PFP
>
bool
animateCity
(
EnvMap
*
envMap
)
...
...
@@ -354,58 +419,58 @@ Dart generateBuilding(EnvMap& envMap, Dart d, float height, unsigned int buildin
switch
(
buildingType
)
{
case
0
:
{
break
;
}
case
1
:
{
dRoof
=
extrudeFaceAndMark
<
PFP
>
(
map
,
position
,
dRoof
,
buildingMark
,
height
/
3
)
;
Dart
dNext
=
map
.
phi1
(
dRoof
)
;
Dart
dPrev
=
map
.
phi2
(
map
.
phi_1
(
dRoof
))
;
map
.
collapseEdge
(
dNext
)
;
map
.
collapseEdge
(
dPrev
)
;
break
;
}
case
2
:
{
dRoof
=
extrudeFaceAndMark
<
PFP
>
(
map
,
position
,
dRoof
,
buildingMark
,
height
/
3
)
;
Dart
dNext
=
map
.
phi1
(
dRoof
)
;
Dart
dPrev
=
map
.
phi2
(
map
.
phi_1
(
dRoof
))
;
typename
PFP
::
VEC3
mid1
=
(
position
[
dNext
]
+
position
[
map
.
phi1
(
dNext
)])
/
2.0
f
;
typename
PFP
::
VEC3
mid2
=
(
position
[
dPrev
]
+
position
[
map
.
phi1
(
dPrev
)])
/
2.0
f
;
map
.
collapseEdge
(
dNext
)
;
map
.
collapseEdge
(
dPrev
)
;
position
[
dRoof
]
=
mid2
;
position
[
map
.
phi1
(
dRoof
)]
=
mid1
;
break
;
}
case
3
:
{
unsigned
int
nbStairs
=
rand
()
%
5
;
for
(
unsigned
int
i
=
0
;
i
<
nbStairs
;
++
i
)
case
0
:
{
typename
PFP
::
VEC3
c
=
Algo
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
dRoof
,
position
)
;
Dart
dRoofSmall
=
extrudeFaceAndMark
<
PFP
>
(
map
,
position
,
dRoof
,
buildingMark
,
0.0
f
)
;
Dart
dd
=
dRoofSmall
;
do
{
position
[
dd
]
=
position
[
dd
]
+
(
c
-
position
[
dd
])
/
3.0
f
;
dd
=
map
.
phi1
(
dd
)
;
}
while
(
dd
!=
dRoofSmall
)
;
dRoof
=
extrudeFaceAndMark
<
PFP
>
(
map
,
position
,
dRoofSmall
,
buildingMark
,
height
/
2.0
f
)
;
break
;
}
bool
spike
=
rand
()
%
2
;
if
(
spike
)
case
1
:
{
typename
PFP
::
VEC3
c
=
Algo
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
dRoof
,
position
)
;
c
[
2
]
+=
height
/
1.5
f
;
dRoof
=
Algo
::
Modelisation
::
trianguleFace
<
PFP
>
(
map
,
dRoof
)
;
position
[
dRoof
]
=
c
;
dRoof
=
extrudeFaceAndMark
<
PFP
>
(
map
,
position
,
dRoof
,
buildingMark
,
height
/
3
)
;
Dart
dNext
=
map
.
phi1
(
dRoof
)
;
Dart
dPrev
=
map
.
phi2
(
map
.
phi_1
(
dRoof
))
;
map
.
collapseEdge
(
dNext
)
;
map
.
collapseEdge
(
dPrev
)
;
break
;
}
case
2
:
{
dRoof
=
extrudeFaceAndMark
<
PFP
>
(
map
,
position
,
dRoof
,
buildingMark
,
height
/
3
)
;
Dart
dNext
=
map
.
phi1
(
dRoof
)
;
Dart
dPrev
=
map
.
phi2
(
map
.
phi_1
(
dRoof
))
;
typename
PFP
::
VEC3
mid1
=
(
position
[
dNext
]
+
position
[
map
.
phi1
(
dNext
)])
/
2.0
f
;
typename
PFP
::
VEC3
mid2
=
(
position
[
dPrev
]
+
position
[
map
.
phi1
(
dPrev
)])
/
2.0
f
;
map
.
collapseEdge
(
dNext
)
;
map
.
collapseEdge
(
dPrev
)
;
position
[
dRoof
]
=
mid2
;
position
[
map
.
phi1
(
dRoof
)]
=
mid1
;
break
;
}
case
3
:
{
unsigned
int
nbStairs
=
rand
()
%
5
;
for
(
unsigned
int
i
=
0
;
i
<
nbStairs
;
++
i
)
{
typename
PFP
::
VEC3
c
=
Algo
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
dRoof
,
position
)
;
Dart
dRoofSmall
=
extrudeFaceAndMark
<
PFP
>
(
map
,
position
,
dRoof
,
buildingMark
,
0.0
f
)
;
Dart
dd
=
dRoofSmall
;
do
{
position
[
dd
]
=
position
[
dd
]
+
(
c
-
position
[
dd
])
/
3.0
f
;
dd
=
map
.
phi1
(
dd
)
;
}
while
(
dd
!=
dRoofSmall
)
;
dRoof
=
extrudeFaceAndMark
<
PFP
>
(
map
,
position
,
dRoofSmall
,
buildingMark
,
height
/
2.0
f
)
;
}
bool
spike
=
rand
()
%
2
;
if
(
spike
)
{
typename
PFP
::
VEC3
c
=
Algo
::
Geometry
::
faceCentroid
<
PFP
>
(
map
,
dRoof
,
position
)
;
c
[
2
]
+=
height
/
1.5
f
;
dRoof
=
Algo
::
Modelisation
::
trianguleFace
<
PFP
>
(
map
,
dRoof
)
;
position
[
dRoof
]
=
c
;
}
break
;
}
break
;
}
}
return
dRoof
;
...
...
@@ -548,6 +613,43 @@ void generatePlanet(EnvMap& envMap)
prim
.
embedSphere
((
xRadius
+
yRadius
)
/
2.0
f
)
;
}
template
<
typename
PFP
>
void
planetify
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
float
r
)
{
Geom
::
BoundingBox
<
typename
PFP
::
VEC3
>
bb
;
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
map
,
position
)
;
VEC3
diff
=
bb
.
max
()
-
bb
.
min
();
float
width
=
diff
[
0
];
float
height
=
diff
[
1
];
float
nR
=
std
::
max
(
width
,
height
);
typedef
typename
PFP
::
VEC3
VEC3
;
TraversorV
<
typename
PFP
::
MAP
>
tv
(
map
);
//apply inverted transformation to build a sphere from planar coordinates (not working)
for
(
Dart
d
=
tv
.
begin
()
;
d
!=
tv
.
end
()
;
d
=
tv
.
next
())
{
VEC3
p
=
position
[
d
];
// p -= bb.min();
p
-=
bb
.
center
();
// p /= (nR/2.0f);
p
.
normalize
();
// position[d] = VEC3(
// 2.0f*p[0]/(1.0f+(p[0]*p[0])+(p[1]*p[1])),
// 2.0f*p[1]/(1.0f+(p[0]*p[0])+(p[1]*p[1])),
// (-1.0f+(p[0]*p[0])+(p[1]*p[1]))/(1.0f+(p[0]*p[0])+(p[1]*p[1]))
// );
//inverted Lambert azimuthal equal-area projection (not working)
position
[
d
]
=
VEC3
(
sqrt
(
1.0
f
-
((
p
[
0
]
*
p
[
0
])
+
(
p
[
1
]
*
p
[
1
]))
/
4.0
f
*
p
[
0
]),
sqrt
(
1.0
f
-
((
p
[
0
]
*
p
[
0
])
+
(
p
[
1
]
*
p
[
1
]))
/
4.0
f
*
p
[
1
]),
-
1.0
f
+
((
p
[
0
]
*
p
[
0
])
+
(
p
[
1
]
*
p
[
1
]))
/
2.0
f
);
}
}
template
<
typename
PFP
>
void
simplifyFreeSpace
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
<
EDGE
>&
obstacleMark
,
CellMarker
<
FACE
>&
buildingMark
)
...
...
include/path_finder.hpp
View file @
62edba1a
...
...
@@ -21,12 +21,10 @@ std::vector<Dart> pathFindAStar(typename PFP::MAP& map, const typename PFP::TVEC
Dart
start
,
Dart
goal
,
CellMarker
<
FACE
>&
isObstacle
)
{
std
::
vector
<
Dart
>
path
;
std
::
multimap
<
float
,
Dart
>
facesToTry
;
FaceAutoAttribute
<
float
>
facePathCostToGoal
(
map
)
;
FaceAutoAttribute
<
Dart
>
faceNextFaceToGoal
(
map
)
;
std
::
multimap
<
float
,
Dart
>
facesToTry
;
CellMarker
<
FACE
>
faceIsTraversed
(
map
)
;
facePathCostToGoal
[
goal
]
=
0
;
...
...
src/env_map.cpp
View file @
62edba1a
...
...
@@ -8,6 +8,7 @@
#include
"Geometry/inclusion.h"
#include
"Algo/MovingObjects/particle_cell_2D_memo.h"
#include
"Algo/Modelisation/subdivision.h"
#include
"Algo/Modelisation/triangulation.h"
#include
"Algo/Geometry/normal.h"
#include
"Algo/Import/importSvg.h"
#include
"Algo/BooleanOperator/mergeVertices.h"
...
...
@@ -37,6 +38,7 @@ EnvMap::EnvMap() :
normal
=
map
.
addAttribute
<
VEC3
,
VERTEX
>
(
"normal"
)
;
positionScenary
=
mapScenary
.
addAttribute
<
VEC3
,
VERTEX
>
(
"position"
)
;
normalScenary
=
mapScenary
.
addAttribute
<
VEC3
,
VERTEX
>
(
"normal"
)
;
#ifndef SPATIAL_HASHING
agentvect
=
map
.
addAttribute
<
PFP
::
AGENTVECT
,
FACE
>
(
"agents"
)
;
...
...
@@ -88,21 +90,82 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
break
;
case
5
:
{
// std::string filename = "./svg/simpleCross.svg" ;
std
::
cout
<<
"?"
<<
std
::
endl
;
// std::string filename = "./svg/planet.svg" ;
std
::
string
filename
=
"./svg/mapRoads.svg"
;
// std::string filename = "./svg/
mapCleaned
.svg" ;
// std::string filename = "./svg/
simpleCross
.svg" ;
Algo
::
Import
::
importSVG
<
PFP
>
(
map
,
filename
,
position
,
obstacleMark
,
buildingMark
)
;
// CityGenerator::planetify<PFP>(map, position, 10.0f);
std
::
cout
<<
"test"
<<
std
::
endl
;
mapScenary
.
addAttribute
<
float
,
FACE
>
(
"agents"
)
;
std
::
string
filename2
=
"./svg/mapBuild.svg"
;
Algo
::
Import
::
importSVG
<
PFP
>
(
mapScenary
,
filename2
,
positionScenary
,
obstacleMarkS
,
buildingMarkS
)
;
// TraversorF<PFP::MAP> tF(mapScenary);
// for(Dart d = tF.begin() ; d != tF.end() ; d = tF.next())
// {
// CityGenerator::generateBuilding(mapScenary,d,5,1);
// }
TraversorF
<
PFP
::
MAP
>
tF
(
mapScenary
);
for
(
Dart
d
=
tF
.
begin
()
;
d
!=
tF
.
end
()
;
d
=
tF
.
next
())
{
//test if convex
bool
convex
=
true
;
Dart
dd
=
mapScenary
.
phi1
(
d
);
Dart
dN
=
mapScenary
.
phi1
(
dd
);
Dart
dNN
=
mapScenary
.
phi1
(
dN
);
VEC3
p1
,
p2
,
p3
,
v1
,
v2
;
p1
=
positionScenary
[
dd
];
p2
=
positionScenary
[
dN
];
p3
=
positionScenary
[
dNN
];
v1
=
VEC3
(
p2
-
p1
);
v2
=
VEC3
(
p3
-
p2
);
float
sign
=
(
v1
^
v2
)[
2
];
while
(
convex
&&
dd
!=
d
)
{
dd
=
dN
;
dN
=
dNN
;
dNN
=
mapScenary
.
phi1
(
dNN
);
p1
=
positionScenary
[
dd
];
p2
=
positionScenary
[
dN
];
p3
=
positionScenary
[
dNN
];
v1
=
VEC3
(
p2
-
p1
);
v2
=
VEC3
(
p3
-
p2
);
float
sign2
=
(
v1
^
v2
)[
2
];
if
((
sign
<
0
&&
sign2
>
0
)
||
(
sign
>
0
&&
sign2
<
0
))
convex
=
false
;
}
//make extrusion/roof/..
if
(
convex
)
{
if
(
Algo
::
Geometry
::
convexFaceArea
<
PFP
>
(
mapScenary
,
d
,
positionScenary
)
<
20.0
f
)
//if big enough create building with "stairs"
CityGenerator
::
extrudeBuilding
<
PFP
>
(
mapScenary
,
positionScenary
,
d
,
1
+
rand
()
%
2
,
10.0
f
*
(
1.0
f
+
rand
()
/
RAND_MAX
));
else
//create building with simple roof
CityGenerator
::
extrudeBuilding
<
PFP
>
(
mapScenary
,
positionScenary
,
d
,
3
,
10.0
f
*
(
1.0
f
+
rand
()
/
RAND_MAX
));
}
else
//building with no roof
{
CityGenerator
::
extrudeBuilding
<
PFP
>
(
mapScenary
,
positionScenary
,
d
,
0
,
5.0
f
+
5.0
f
*
(
1.0
f
+
2.0
f
*
rand
()
/
RAND_MAX
));
}
}
//triangulation for rendering
Algo
::
Modelisation
::
EarTriangulation
<
PFP
>
et
(
mapScenary
);
et
.
triangule
();
//subdivision to create footpath
// SelectorCellUnmarked<EDGE> nb(obstacleMark);
SelectorDartNoBoundary
<
PFP
::
MAP
>
nb
(
map
);
// SelectorTrue alldarts;
Algo
::
Modelisation
::
TwoNPlusOneSubdivision
<
PFP
,
PFP
::
TVEC3
,
VEC3
>
(
map
,
position
,
nb
);
markPedWay
();
// Algo::BooleanOperator::mergeVertices<PFP>(map, position) ;
// map.closeMap() ;
...
...
src/simulator.cpp
View file @
62edba1a
...
...
@@ -372,19 +372,19 @@ void Simulator::setupCorridorScenario(unsigned int config, unsigned int nbAgents
//for generating a random path
//
unsigned int dartDistForPath = 50 ;
//
mo4->goals_.clear() ;
//
Dart dStart = mo4->registering_part->d;
//
Dart dStop = dStart ;
//
for (unsigned int j = 0 ; envMap_.buildingMark.isMarked(dStop) || j < dartDistForPath + rand() * 20 || envMap_.map.sameFace(dStop, dStart) ; ++j)
//
{
//
envMap_.map.next(dStop) ;
//
if (dStop == envMap_.map.end())
//
dStop = envMap_.map.begin() ;
//
}
//
//
addPathToObstacle(mo4, dStart, dStop);
//
addPathToObstacle(mo4, dStop, dStart);
unsigned
int
dartDistForPath
=
50
;
mo4
->
goals_
.
clear
()
;
Dart
dStart
=
mo4
->
registering_part
->
d
;
Dart
dStop
=
dStart
;
for
(
unsigned
int
j
=
0
;
envMap_
.
buildingMark
.
isMarked
(
dStop
)
||
j
<
dartDistForPath
+
rand
()
*
20
||
envMap_
.
map
.
sameFace
(
dStop
,
dStart
)
;
++
j
)
{
envMap_
.
map
.
next
(
dStop
)
;
if
(
dStop
==
envMap_
.
map
.
end
())
dStop
=
envMap_
.
map
.
begin
()
;
}
addPathToObstacle
(
mo4
,
dStart
,
dStop
);
addPathToObstacle
(
mo4
,
dStop
,
dStart
);
movingObstacles_
.
push_back
(
mo4
);
}
...
...
src/viewer.cpp
View file @
62edba1a
...
...
@@ -148,15 +148,6 @@ void SocialAgents::cb_redraw()
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
)
;
renderAgent
(
simulator
.
envMap_
,
*
it
,
drawAgentsNeighborDist
,
drawAgentsObstacleDist
,
(
*
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)
// {
// glColor3f(0.0f, 1.0f, 1.0f) ;
// glLineWidth(10.0f) ;
// renderDart(sim.envMap_, obst->second) ;
// }
}
// CellMarker m(sim.envMap_.map, FACE) ;
...
...
@@ -217,30 +208,10 @@ void SocialAgents::cb_redraw()
{
for
(
std
::
vector
<
MovingObstacle
*>::
iterator
it
=
simulator
.
movingObstacles_
.
begin
()
;
it
!=
simulator
.
movingObstacles_
.
end
()
;
++
it
)
{
// MovingObstacle* mo = *it ;
//affiche les sommets des obstacles
// for (unsigned int i =0; i< (*it)->nbVertices;i++)
// {
// VEC3 pos = (*it)->obstacles_[i]->p1;
// 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();
// pos = (*it)->obstacles_[i]->p2;
// glColor3f(1.0f, 0.0f, 0.8f);
// 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
(
1.0
f
,
1.0
f
,
1.0
f
)
;
glLineWidth
(
1.0
f
)
;
// if((*it)->index==74)
// {
// glColor3f(1.0f, 0.0f, 0.5f) ;
// }
glBegin
(
GL_POLYGON
)
;
for
(
unsigned
int
i
=
0
;
i
<
((
*
it
)
->
nbVertices
)
;
++
i
)
...
...
@@ -413,6 +384,7 @@ void SocialAgents::cb_redraw()
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_LINE
)
;
Algo
::
Render
::
GL1
::
renderTriQuadPoly
<
PFP
>
(
simulator
.
envMap_
.
map
,
Algo
::
Render
::
GL1
::
LINE
,
1.0
,
simulator
.
envMap_
.
position
,
simulator
.
envMap_
.
normal
)
;
glColor3f
(
1
,
0
,
0
);
Algo
::
Render
::
GL1
::
renderTriQuadPoly
<
PFP
>
(
simulator
.
envMap_
.
mapScenary
,
Algo
::
Render
::
GL1
::
LINE
,
1.0
,
simulator
.
envMap_
.
positionScenary
,
simulator
.
envMap_
.
normalScenary
)
;
...
...
@@ -428,7 +400,7 @@ void SocialAgents::cb_redraw()
if
(
drawObstacles
)
{
Cell
Marker
<
FACE
>
dmo
(
simulator
.
envMap_
.
map
)
;
Dart
Marker
dmo
(
simulator
.
envMap_
.
map
)
;
for
(
Dart
d
=
simulator
.
envMap_
.
map
.
begin
()
;
d
!=
simulator
.
envMap_
.
map
.
end
()
;
simulator
.
envMap_
.
map
.
next
(
d
))
{
if
(
!
dmo
.
isMarked
(
d
))
...
...
@@ -437,35 +409,26 @@ void SocialAgents::cb_redraw()
glLineWidth
(
3.0
f
)
;
///show buildings
// if(sim.envMap_.buildingMark.isMarked(d))
// if(sim
ulator
.envMap_.buildingMark.isMarked(d))
// {
// renderFace(sim.envMap_,d);
// renderFace(sim
ulator
.envMap_,d);
// }
///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 ((simulator.envMap_.obstvect[d].size()) != 0)
// {
// renderFace(simulator.envMap_, d) ;
// }
dmo
.
mark
(
d
);
// if(simulator.envMap_.obstacleMark.isMarked(d))
// {
// renderDart(simulator.envMap_,d);
// }
if
(
(
simulator
.
envMap_
.
obstvect
[
d
].
size
())
!=
0
)
if
(
simulator
.
envMap_
.
map
.
isBoundaryMarked
(
d
)
)
{
renderFace
(
simulator
.
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)
// {
// VEC3 p1=(*it)->p1;
// VEC3 p2=(*it)->p2;
// glColor3f(1.0f, 0.0f, 0.0f);
// glLineWidth(5.0f);
// glBegin(GL_LINES);
// glVertex3f(p1[0],p1[1],p1[2]);
// glVertex3f(p2[0],p2[1],p2[2]);
// glEnd();
// }
renderDart
(
simulator
.
envMap_
,
d
);
}
}
}
...
...
@@ -510,15 +473,11 @@ void SocialAgents::cb_redraw()
glPolygonOffset
(
1.0
f
,
1.0
f
)
;
Algo
::
Render
::
GL1
::
renderTriQuadPoly
<
PFP
>
(
simulator
.
envMap_
.
map
,
Algo
::
Render
::
GL1
::
LINE
,
1.0
,
simulator
.
envMap_
.
position
,
simulator
.
envMap_
.
normal
)
;
// Algo::Render::GL1::renderTriQuadPoly<PFP>(sim.envMap_.mapScenary, Algo::Render::GL1::LINE,
// 1.0, sim.envMap_.positionScenary,
// sim.envMap_.normalScenary) ;
glColor3f
(
1.0
f
,
0.0
f
,
0.0
f
)
;
Algo
::
Render
::
GL1
::
renderTriQuadPoly
<
PFP
>
(
simulator
.
envMap_
.
mapScenary
,
Algo
::
Render
::
GL1
::
LINE
,
1.0
,
simulator
.
envMap_
.
positionScenary
,
simulator
.
envMap_
.
normalScenary
)
;
}
// glColor3f(1.0f, 1.0f, 0.0f);
// glLineWidth(5.0f);
// renderFace(sim.envMap_,88);
//
// renderDart(sim.envMap_,89);
// glPushMatrix() ;
// glBegin(GL_LINES) ;
...
...
@@ -576,38 +535,6 @@ void SocialAgents::cb_redraw()
// glEnd() ;
// glPopMatrix() ;
// glColor3f(0.0f, 1.0f, 0.0f) ;
// glLineWidth(5.0f) ;
// CellMarker dmb(sim.envMap_.map, FACE) ;
// for (Dart d = sim.envMap_.map.begin(); d != sim.envMap_.map.end(); sim.envMap_.map.next(d))
// {
// if (!dmb.isMarked(d))
// {
// dmb.mark(d) ;
// if (sim.envMap_.buildingMark.isMarked(d))
// {
// VEC3 c = Algo::Geometry::faceCentroid<PFP>(sim.envMap_.map, d, sim.envMap_.position);
// glBegin(GL_LINES) ;
// Dart dd = d ;
// do
// {
// VEC3 p1 = sim.envMap_.position[dd] ;
// VEC3 p2 = sim.envMap_.position[sim.envMap_.map.phi1(dd)] ;
// VEC3 vec = c - p1 ;
// p1 = p1 + vec * 0.25f ;
// vec = c - p2 ;
// p2 = p2 + vec * 0.25f ;
//
// glVertex3f(p1[0], p1[1], p1[2]) ;
// glVertex3f(p2[0], p2[1], p2[2]) ;
//
// dd = sim.envMap_.map.phi1(dd) ;
// } while (dd != d) ;
// glEnd() ;
// }
// }
// }
++
frames
;
struct
timespec
realTime
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
realTime
)
;
...
...
@@ -702,7 +629,7 @@ void SocialAgents::animate()
std
::
ostringstream
oss
;
std
::
ostringstream
tmpNb
;
tmpNb
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
4
)
<<
nbIterations
;
oss
<<
"./c
orridorTake2/take
Two"
<<
tmpNb
.
str
()
<<
".pov"
;
oss
<<
"./c
ity/talesOf
Two"
<<
tmpNb
.
str
()
<<
".pov"
;
std
::
string
chaine
=
oss
.
str
()
;
// VEC3 agPos = sim.agents_[0]->meanPos_ ;
// agPos[2] = agPos[1] ;
...
...
@@ -766,8 +693,13 @@ void SocialAgents::animate()
// VEC3 camLook(0, 0, 0) ;
//corridor take2
VEC3
camPos
(
-
350
,
200
,
0
)
;
VEC3
camLook
(
0
,
0
,
0
)
;
// VEC3 camPos(-350, 200, 0) ;
// VEC3 camLook(0, 0, 0) ;
//openStreetMap mapRoad & mapBuildings
VEC3
camPos
(
-
200
,
100
,
500
)
;
VEC3
camLook
(
1000
,
0
,
0
)
;
exportScenePov
(
simulator
.
envMap_
.
map
,
simulator
.
envMap_
.
position
,
chaine
,
camPos
,
camLook
,
VEC3
(
0.0
f
,
0
,
0
),
0
,
0
,
0
);
// exportScenePov(sim.envMap_.map,sim.envMap_.position,chaine,VEC3(43,762,65),VEC3(0,762,0),VEC3(1.0f,0,0),0,0,0);
...
...
@@ -838,12 +770,6 @@ void SocialAgents::exportInfoFace(std::ofstream& out, Dart d)
VEC3
col
=
Utils
::
color_map_BCGYR
(
float
(
j
)
/
float
(
simulator
.
agents_
.
size
()))
;
out
<<
"pigment { color <"
<<
col
[
0
]
<<
","
<<
col
[
1
]
<<
","
<<
col
[
2
]
<<
"> }"
<<
std
::
endl
;
// float col = float(j) / float(sim.agents_.size()) ;
// col = col * 16777215 ;
// out << "pigment { color <" << (int(col / 256 / 256) % 256) / 256.0f << ","
// << (int(col / 256) % 256) / 256.0f << "," << (int(col) % 256) / 256.0f << "> }"
// << std::endl ;
//