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
434230a2
Commit
434230a2
authored
Mar 28, 2013
by
Arash HABIBI
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unidir OK. Manque obstacles fixes
parent
c8fab466
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
31 deletions
+68
-31
include/moving_obstacle.h
include/moving_obstacle.h
+2
-1
src/moving_obstacle.cpp
src/moving_obstacle.cpp
+55
-25
src/simulator.cpp
src/simulator.cpp
+8
-1
src/viewer.cpp
src/viewer.cpp
+3
-4
No files found.
include/moving_obstacle.h
View file @
434230a2
...
...
@@ -51,7 +51,8 @@ public:
VEC3
getDilatedPosition
(
unsigned
int
ind
);
//vertex position with velocity dilatation
VEC3
getPosition
(
unsigned
int
ind
);
// vertex position
void
initForces
();
void
update
();
void
updateForces
();
void
applyForces
();
PFP
::
REAL
computeMVC
(
PFP
::
VEC3
p
,
Dart
vertex
);
void
computePointMVC
(
PFP
::
VEC3
point
,
std
::
vector
<
PFP
::
REAL
>&
coordinates
);
...
...
src/moving_obstacle.cpp
View file @
434230a2
...
...
@@ -3,6 +3,7 @@
#include "agent.h"
#include "simulator.h"
#include "moving_mesh.h"
#include "Utils/colorMaps.h"
#include "Algo/Modelisation/triangulation.h"
...
...
@@ -310,7 +311,11 @@ void MovingObstacle::draw()
// m_render->initPrimitives<PFP>(map, Algo::Render::GL2::TRIANGLES,false) ;
m_positionVBO
->
updateData
(
position
);
// m_shader->setColor(Geom::Vec4f(movingObstacleNeighbors_.size()==0 ? 1.0f : 0,0.,0.,0.));
m_shader
->
setColor
(
Geom
::
Vec4f
(
1.0
f
,
0.
,
0.
,
0.0
));
VEC3
col
=
Utils
::
color_map_BCGYR
(
float
(
index
)
/
float
(
sim_
->
movingObstacles_
.
size
()));
if
(
movingObstacleNeighbors_
.
size
()
==
0
)
m_shader
->
setColor
(
Geom
::
Vec4f
(
col
[
0
],
col
[
1
],
col
[
2
],
0
));
else
m_shader
->
setColor
(
Geom
::
Vec4f
(
0.5
,
0.5
,
0.5
,
0
));
m_render
->
draw
(
m_shader
,
Algo
::
Render
::
GL2
::
TRIANGLES
);
m_shader
->
setColor
(
Geom
::
Vec4f
(
0.
,
0.
,
0.
,
0.
));
m_render
->
draw
(
m_shader
,
Algo
::
Render
::
GL2
::
LINES
);
...
...
@@ -698,19 +703,19 @@ void getResponse2(VEC3 f, VEC3 p, VEC3 p1, VEC3 p2, VEC3 *f1, VEC3 *f2)
void
MovingObstacle
::
initForces
()
{
Dart
dd
=
groundFace
;
if
(
!
rigid_
)
for
(
unsigned
int
i
=
1
;
i
<
nbVertices
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
nbVertices
;
++
i
)
{
//initialisation of forces
forces
[
dd
]
=
VEC3
(
0.0
);
map
.
next
(
dd
);
}
}
//-------------------------------------------------------------
void
MovingObstacle
::
update
()
void
MovingObstacle
::
update
Forces
()
{
assert
(
sim_
->
envMap_
.
map
.
getCurrentLevel
()
==
sim_
->
envMap_
.
map
.
getMaxLevel
())
;
...
...
@@ -748,10 +753,10 @@ void MovingObstacle::update()
if
(
!
rigid_
)
{
Dart
d
=
groundFace
;
map
.
next
(
d
);
//
map.next(d);
Dart
dd
=
d
;
for
(
unsigned
int
i
=
1
;
i
<
nbVertices
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
nbVertices
;
++
i
)
{
//initialisation of forces with viscosity
forces
[
dd
]
+=
-
0.2
f
*
velocity
[
dd
];
...
...
@@ -763,7 +768,7 @@ void MovingObstacle::update()
CellMarkerStore
<
VERTEX
>
cmV
(
map
);
DartMarkerStore
dm
(
map
);
// ARASH : On parcourt les sommets de la grande face
for
(
unsigned
int
i
=
1
;
i
<
nbVertices
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
nbVertices
;
++
i
)
{
Dart
dd
=
d
;
...
...
@@ -899,12 +904,13 @@ void MovingObstacle::update()
// obst->mo->forces[obst->index+1%obst->mo->nbVertices]
VEC3
force_vector1
,
force_vector2
;
getResponse1
(
force_vector
,
p
,
p1
,
p2
,
&
force_vector1
,
&
force_vector2
);
int
indice1
=
obst
->
index
;
int
indice2
=
(
obst
->
index
+
1
)
%
(
obst
->
mo
->
nbVertices
);
// obst->mo->forces[indice1] += force_vector1;
// obst->mo->forces[indice2] += force_vector2;
VEC3
p11
=
obst
->
mo
->
position
[
indice1
];
VEC3
p22
=
obst
->
mo
->
position
[
indice2
];
Dart
d1
=
obst
->
d1
;
Dart
d2
=
obst
->
d2
;
// obst->mo->forces[d1] += force_vector1;
// obst->mo->forces[d2] += force_vector2;
// VEC3 p11 = obst->mo->position[d1];
// VEC3 p22 = obst->mo->position[d2];
// cerr << "p1=" << p1 << " p11=" << p11 << " p2=" << p2 << " p22=" << p22 << endl;
}
}
...
...
@@ -916,10 +922,11 @@ void MovingObstacle::update()
}
//guiding vertex = first vertex (set the displacement)
forces
[
groundFace
]
=
VEC3
(
0
);
//
forces[groundFace] = VEC3(0);
velocity
[
groundFace
]
=
velocity_
;
//apply force to each vertex
/*
d = groundFace;
for (unsigned int i = 0; i < nbVertices; ++i)
{
...
...
@@ -929,6 +936,7 @@ void MovingObstacle::update()
bary += position[d];
map.next(d);
}
*/
}
else
{
...
...
@@ -950,15 +958,7 @@ void MovingObstacle::update()
bary
+=
position
[
d
];
#ifdef TWO_AND_HALF_DIM
std
::
cout
<<
" dist supp "
<<
(
getDilatedPosition
(
i
)
-
parts_
[
i
]
->
getPosition
()).
norm
()
<<
std
::
endl
;
#endif
parts_
[
i
]
->
move
(
getDilatedPosition
(
i
));
#ifdef TWO_AND_HALF_DIM
std
::
cout
<<
" dist "
<<
parts_
[
i
]
->
getDistance
()
<<
std
::
endl
;
position
[
d
]
=
parts_
[
i
]
->
getPosition
();
#endif
map
.
next
(
d
);
}
...
...
@@ -987,10 +987,40 @@ void MovingObstacle::update()
// if(!rigid_)
// center = position[groundFace];
}
//-------------------------------------------------------------------------
// MAJ des obstacles
void
MovingObstacle
::
applyForces
()
{
PFP
::
VEC3
bary
(
0
);
if
(
!
rigid_
)
{
Dart
d
=
groundFace
;
for
(
unsigned
int
i
=
0
;
i
<
nbVertices
;
++
i
)
{
velocity
[
d
]
+=
forces
[
d
]
*
sim_
->
timeStep_
;
position
[
d
]
+=
(
velocity
[
d
]
*
sim_
->
timeStep_
);
position
[
map
.
phi
<
211
>
(
d
)]
+=
(
velocity
[
d
]
*
sim_
->
timeStep_
);
bary
+=
position
[
d
];
map
.
next
(
d
);
}
center
=
bary
/
nbVertices
;
}
// MAJ des obstacles
for
(
unsigned
int
i
=
0
;
i
<
nbVertices
;
++
i
)
{
#ifdef TWO_AND_HALF_DIM
std
::
cout
<<
" dist supp "
<<
(
getDilatedPosition
(
i
)
-
parts_
[
i
]
->
getPosition
()).
norm
()
<<
std
::
endl
;
#endif
parts_
[
i
]
->
move
(
getDilatedPosition
(
i
));
#ifdef TWO_AND_HALF_DIM
std
::
cout
<<
" dist "
<<
parts_
[
i
]
->
getDistance
()
<<
std
::
endl
;
position
[
d
]
=
parts_
[
i
]
->
getPosition
();
#endif
// CGoGNout << "avant une etape : Obstacle "<< i << CGoGNendl;
Obstacle
*
o
=
obstacles_
[
i
];
o
->
p1
=
getDilatedPosition
(
i
);
...
...
@@ -1049,9 +1079,9 @@ void MovingObstacle::update()
}
}
}
//-------------------------------------------------------------------------
std
::
vector
<
Dart
>
MovingObstacle
::
getMemoCross
(
const
VEC3
&
pos
,
const
VEC3
&
dest
,
Dart
&
d1
,
Dart
&
d2
)
{
...
...
@@ -1209,7 +1239,7 @@ void MovingObstacle::computePrefVelocity() //calcul du vecteur optimal pour atte
{
goalVector
=
(
get_center
(
parent
,
index_parent
-
1
)
-
center
);
float
goalDist2
=
goalVector
.
norm2
()
;
if
(
goalDist2
>
maxSpeed_
)
if
(
goalDist2
>
100
*
maxSpeed_
)
{
goalVector
.
normalize
()
;
goalVector
*=
maxSpeed_
;
...
...
src/simulator.cpp
View file @
434230a2
...
...
@@ -132,11 +132,18 @@ void Simulator::doStep()
movingObstacles_
[
i
]
->
initForces
();
}
for
(
unsigned
int
i
=
0
;
i
<
movingObstacles_
.
size
()
;
++
i
)
movingObstacles_
[
i
]
->
updateForces
()
;
for
(
unsigned
int
i
=
0
;
i
<
movingObstacles_
.
size
()
;
++
i
)
{
movingObstacles_
[
i
]
->
update
()
;
movingObstacles_
[
i
]
->
applyForces
()
;
movingObstacles_
[
i
]
->
updateMesh
()
;
}
endTime
=
clock
()
;
time_obstacle
+=
endTime
-
begTime
;
begTime
=
clock
()
;
...
...
src/viewer.cpp
View file @
434230a2
...
...
@@ -33,7 +33,7 @@ SocialAgents::SocialAgents(unsigned int config, unsigned int minSize, unsigned i
#ifdef EXPORTING_OBJ
m_objAgent(mapAgent),
#endif
m_renderStyle(0),
m_renderStyle(0),
nbIterations(0),
maxIterations(iterations),
nbGeneratedPov(0),
...
...
@@ -726,10 +726,9 @@ void SocialAgents::cb_redraw()
simulator.movingObstacles_[i]->draw();
#endif
}
// Commente par Arash
for (std::vector<MovingMesh*>::iterator it = simulator.movingMeshes_.begin() ; it != simulator.movingMeshes_.end() ; ++it)
(*it)->draw();
//
for (std::vector<MovingMesh*>::iterator it = simulator.movingMeshes_.begin() ; it != simulator.movingMeshes_.end() ; ++it)
//
(*it)->draw();
}
...
...
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