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
b7f81b10
Commit
b7f81b10
authored
Feb 06, 2014
by
pitiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ok serpent
parent
2596423f
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
201 additions
and
145 deletions
+201
-145
cams/cam.out~
cams/cam.out~
+7
-6
include/agent.h
include/agent.h
+2
-2
include/articulated_obstacle.h
include/articulated_obstacle.h
+4
-0
include/moving_mesh.h
include/moving_mesh.h
+10
-1
include/moving_obstacle.h
include/moving_obstacle.h
+16
-3
include/obstacle.h
include/obstacle.h
+1
-1
include/viewer.h
include/viewer.h
+4
-2
src/agent.cpp
src/agent.cpp
+3
-3
src/articulated_obstacle.cpp
src/articulated_obstacle.cpp
+7
-2
src/env_map.cpp
src/env_map.cpp
+12
-8
src/moving_obstacle.cpp
src/moving_obstacle.cpp
+105
-95
src/simulator.cpp
src/simulator.cpp
+18
-12
src/viewer.cpp
src/viewer.cpp
+12
-10
No files found.
cams/cam.out~
View file @
b7f81b10
925 268.919 -599.764 174.022 229.193 -513.318 143.218 -0.154631 0.267809 0.950982
1420 114.119 -361.09 564.72 97.6865 -312.66 478.787 -0.25495 0.820722 0.511289
3115 -119.914 -198.458 186.027 -85.6747 -137.812 114.265 0.346014 0.628714 0.696415
4784 -179.491 -194.446 135.444 -125.036 -132.211 79.2166 0.368223 0.424929 0.826951
7798 -179.204 -102.848 442.481 -148.784 -85.0303 348.901 0.727103 0.591244 0.34893
12828 -125.14 -65.2268 467.511 -106.094 -55.2945 369.845 0.762254 0.611961 0.210886
123 -185.685 -467.24 348.076 -161.367 -389.597 289.936 0.0875394 0.57938 0.810343
123 -185.685 -467.24 348.076 -161.367 -389.597 289.936 0.0875394 0.57938 0.810343
499 -82.8172 -181.343 312.474 -70.7052 -131.43 226.672 0.136105 0.847868 0.512441
937 -7.18517 -11.3042 207.64 -10.3007 -0.634028 108.259 0.0767988 0.991602 0.104058
1563 -62.3674 -142.75 137.936 -37.9392 -68.8674 75.1295 0.201799 0.594775 0.778151
2352 20.072 -60.9946 203.32 25.6662 -15.5125 114.438 0.00685043 0.890023 0.455864
3027 -81.1169 -21.0707 779.242 -72.419 -15.6418 679.769 0.0251416 0.998076 0.0566697
include/agent.h
View file @
b7f81b10
...
...
@@ -9,9 +9,9 @@
// #define SECURED
//#define EXPORTING_AGENT
//#define EXPORTING_AGENT
// trainée derriere l'agent
//#define EXPORTING_OBJ
//#define EXPORTING_OBJ
// skin mexicain
#define ARASH
...
...
include/articulated_obstacle.h
View file @
b7f81b10
...
...
@@ -14,6 +14,10 @@ public:
int
nbBodyPart
;
std
::
vector
<
VEC3
>
goals
;
VEC3
curGoal
;
float
old_Factor
;
// pour modification de vitesses
PFP
::
VEC3
get_center
(
int
index
);
PFP
::
VEC3
get_front
(
int
index
);
};
#endif
include/moving_mesh.h
View file @
b7f81b10
...
...
@@ -18,7 +18,16 @@
using
namespace
std
;
//#define EXPORTING2
//#define EXPORTING2 // textures des limaces
#ifdef EXPORTING2
#include "Utils/Shaders/shaderPhongTexture.h"
#include "Utils/Shaders/shaderSimpleTexture.h"
#include "shaderCustomTex.h"
#include "Algo/Import/importObjTex.h"
#endif
float
get_angle3D
(
VEC3
v1
,
VEC3
v2
);
...
...
include/moving_obstacle.h
View file @
b7f81b10
...
...
@@ -7,7 +7,7 @@
#include "env_map.h"
#include <set>
#define LINEAR
// #define LINEAR //shapematching linéaire ou quadratic ?
// #define SECURED
...
...
@@ -28,7 +28,7 @@
#endif
#endif
#define EXPORTING_BOXES
#define EXPORTING_BOXES
// boites des obstacles
#ifdef EXPORTING_BOXES
#include "Algo/Render/GL2/mapRender.h"
...
...
@@ -44,7 +44,7 @@ using namespace std;
PFP
::
VEC3
rotate2D
(
PFP
::
VEC3
pos1
,
PFP
::
VEC3
center
,
float
angle
);
VEC3
computeForce
(
VEC3
p
,
VEC3
p1
,
VEC3
p2
,
float
obst_radius_infl
,
float
obst_power
,
float
obst_stiffness
,
VEC3
normFace
);
float
get_angle
(
PFP
::
VEC3
v1
,
PFP
::
VEC3
v2
);
PFP
::
VEC3
get_center
(
ArticulatedObstacle
*
art
,
int
index
);
class
Simulator
;
class
MovingMesh
;
...
...
@@ -173,6 +173,19 @@ public:
Agent
*
ag_
;
int
index_parent
;
float
gravity_dist
;
/// distance entre le centre du MO et son sommet le plus éloigné
double
stiff_agent
;
double
radius_agent
;
double
stiff_obst
;
double
radius_obst
;
double
long_radius_agent
;
double
long_radius_obst
;
VertexAttribute
<
NoMathIONameAttribute
<
std
::
vector
<
PFP
::
REAL
>
>
>
mvc_
;
/////// ShapeMatching
...
...
include/obstacle.h
View file @
b7f81b10
...
...
@@ -7,7 +7,7 @@ class Obstacle
{
public:
Obstacle
(
const
VEC3
point1
,
const
VEC3
point2
,
MovingObstacle
*
moving1
=
NULL
,
unsigned
int
ind
=
0
,
double
stiff_agent
=
20
,
double
stiff_obst
=
5
,
double
radius_agent
=
500
,
double
radius_obst
=
1
0
)
:
MovingObstacle
*
moving1
=
NULL
,
unsigned
int
ind
=
0
,
double
stiff_agent
=
20
,
double
stiff_obst
=
10
,
double
radius_agent
=
500
,
double
radius_obst
=
3
0
)
:
p1
(
point1
),
p2
(
point2
),
mo
(
moving1
),
index
(
ind
),
p3
(
0
,
0
,
0
),
obst_stiffness_agent
(
stiff_agent
),
obst_stiffness_obst
(
stiff_obst
),
obst_radius_infl_agent
(
radius_agent
),
obst_radius_infl_obst
(
radius_obst
)
{
...
...
include/viewer.h
View file @
b7f81b10
...
...
@@ -57,8 +57,10 @@
#include "shaderPhongTexCust.h"
#define DRAW_REGISTRATION //montre l'enregistrement des obstacles mobiles
//#define AFFICHE_MESH
//#define EXPORTING
#define AFFICHE_MESH
//#define EXPORTING // ne pas activer
#define ONERING
//#define SHADOWSHELL
...
...
src/agent.cpp
View file @
b7f81b10
...
...
@@ -15,7 +15,7 @@ VEC3 Agent::xyPlane = VEC3(0,0,1);
unsigned int Agent::maxNeighbors_ = 10 ;
unsigned int Agent::maxMovingObstacles_ = 20;
float Agent::averageMaxSpeed_ =
0.5
f ;
float Agent::averageMaxSpeed_ =
2.0
f ;
// float Agent::averageMaxSpeed_ = 20.0f ;
float Agent::neighborDist_ = 10.0f ;
//float Agent::neighborDist_ = 20.0f ;
...
...
@@ -763,7 +763,7 @@ void Agent::computeNewVelocity()
VEC3 normFace = VEC3 (0,0,1);
#endif
double collision_softening_factor;
float ag_ambient_damping = 10
00
.0;
float ag_ambient_damping = 10.0;
// double mass_var = 0.95;
// double average_mass = 1.0;
...
...
@@ -795,7 +795,7 @@ void Agent::computeNewVelocity()
//----- force due à l'attraction de l'objectif ----------
float goal_attraction_force =
2
00.0; // agent-goal interaction stiffness
float goal_attraction_force =
1
00.0; // agent-goal interaction stiffness
VEC3 p_goal = goals_[curGoal_];
VEC3 u_goal = p_goal - getPosition();
u_goal.normalize();
...
...
src/articulated_obstacle.cpp
View file @
b7f81b10
...
...
@@ -4,6 +4,7 @@ ArticulatedObstacle::ArticulatedObstacle(Simulator* sim, int index, int currentI
{
this
->
index
=
index
;
nbBodyPart
=
size
;
old_Factor
=
0
;
MovingObstacle
*
mo4
=
new
MovingObstacle
(
sim
,
currentIndex
+
1
,
pos
[
0
],
goals
,
true
,
true
,
curGoal
,
NIL
,
this
,
0
);
members
.
push_back
(
mo4
);
for
(
int
i
=
1
;
i
<
nbBodyPart
;
i
++
)
...
...
@@ -16,7 +17,11 @@ ArticulatedObstacle::ArticulatedObstacle(Simulator* sim, int index, int currentI
}
}
PFP
::
VEC3
get_center
(
ArticulatedObstacle
*
art
,
int
index
)
PFP
::
VEC3
ArticulatedObstacle
::
get_center
(
int
index
)
{
return
art
->
members
[
index
]
->
center
+
(
art
->
members
[
index
]
->
center
-
art
->
members
[
index
]
->
front
);
return
this
->
members
[
index
]
->
center
;
}
PFP
::
VEC3
ArticulatedObstacle
::
get_front
(
int
index
)
{
return
this
->
members
[
index
]
->
front
;
}
src/env_map.cpp
View file @
b7f81b10
...
...
@@ -79,24 +79,28 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
{
case 0 :
// CityGenerator::generateGrid<PFP>(*this) ;
CityGenerator
::
generateGrid
<
PFP
>
(
*
this
)
;
// CityGenerator::generateGrid<PFP>(*this) ;
CityGenerator::generateTrianGrid<PFP>(*this,obstacleMark, buildingMark);
CityGenerator::generateCity<PFP>(*this,0,500.0f) ;
break ;
case 1 :
CityGenerator
::
generateGrid
<
PFP
>
(
*
this
)
;
//
CityGenerator::generateTrianGrid<PFP>(*this,obstacleMark, buildingMark);
//
CityGenerator::generateGrid<PFP>(*this) ;
CityGenerator::generateTrianGrid<PFP>(*this,obstacleMark, buildingMark);
break ;
case 2 :
CityGenerator
::
generateGrid
<
PFP
>
(
*
this
)
;
//
CityGenerator::generateTrianGrid<PFP>(*this,obstacleMark, buildingMark);
//
CityGenerator::generateGrid<PFP>(*this) ;
CityGenerator::generateTrianGrid<PFP>(*this,obstacleMark, buildingMark);
// CityGenerator::generateMall<PFP>(map, position, obstacleMark, buildingMark, sideSize);
break ;
case 3 :
CityGenerator
::
generateGrid
<
PFP
>
(
*
this
)
;
// CityGenerator::generateGrid<PFP>(*this) ;
CityGenerator::generateTrianGrid<PFP>(*this,obstacleMark, buildingMark);
// CityGenerator::generateCity<PFP>(*this,10,500.0f) ;
break ;
case 4 :
CityGenerator
::
generateGrid
<
PFP
>
(
*
this
)
;
CityGenerator::generateTrianGrid<PFP>(*this,obstacleMark, buildingMark);
// CityGenerator::generateGrid<PFP>(*this) ;
break ;
case 5 :
{
...
...
@@ -201,7 +205,7 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
break;
case 6:
CityGenerator::generatePlanet<PFP>(*this);
CityGenerator
::
generateCity
<
PFP
>
(
*
this
,
20
0
,
1000.0
f
,
20.0
f
)
;
CityGenerator::generateCity<PFP>(*this,
3
0, 1000.0f, 20.0f) ;
break;
case 7 :
...
...
src/moving_obstacle.cpp
View file @
b7f81b10
#include "
moving
_obstacle.h"
#include "
articulated
_obstacle.h"
#include "obstacle.h"
#include "agent.h"
#include "simulator.h"
...
...
@@ -9,7 +9,7 @@
//float MovingObstacle::neighborDistSq_ = 5.0f * 5.0f;
float
MovingObstacle
::
maxSpeed_
=
0.9
f
;
float
MovingObstacle
::
maxSpeed_
=
2.0
f
;
// 8 pour limaces ?
float
MovingObstacle
::
neighborDist_
=
10.0
f
;
float
MovingObstacle
::
neighborDistSq_
=
neighborDist_
*
neighborDist_
;
float
MovingObstacle
::
timeHorizonObst_
=
10.0
f
;
...
...
@@ -149,33 +149,39 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
index
(
ind
),
goals_
(
goals
),
curGoal_
(
curGoal
),
velocity_factor
(
0.8
f
),
color1
(
1.0
f
),
velocity_factor
(
1.0
f
),
color1
(
1.0
f
),
// couleur de l'obstacle
color2
(
1.0
f
),
color3
(
1.0
f
),
seen
(
false
),
newVelocity_
(
0
),
sim_
(
sim
),
rigid_
(
rigid
),
spinning
(
spin
),
parent
(
art
),
mm_
(
NULL
),
ag_
(
NULL
),
index_parent
(
indParent
),
gravity_dist
(
0
),
beta
(
0.95
),
alpha
(
0.99
),
speed_detection_factor
(
100
)
seen
(
false
),
// l'obstacle est il vu par des agents
newVelocity_
(
0
),
// vitesse actuelle
sim_
(
sim
),
// lien vers le simulateur
rigid_
(
rigid
),
// rigide ou déformable ?
spinning
(
spin
),
// l'obstacle peut il effectuer des rotations ?
parent
(
art
),
// obstacle articulé parent
mm_
(
NULL
),
// moving mesh associé
ag_
(
NULL
),
// agent suivi ?
index_parent
(
indParent
),
// index de l'obstacle dans l'obstacle articulé
gravity_dist
(
0
),
// rayon de la boule englobante de l'obstacle
#ifdef LINEAR
beta
(
0.60
),
alpha
(
0.95
),
#else
beta
(
0.60
),
// params shpaematching
alpha
(
0.95
),
#endif
speed_detection_factor
(
10
)
// facteur qui détermine la taille du vecteur d'anticipation
{
double
stiff_agent
=
500
;
double
radius_agent
=
30
;
if
(
index_parent
>
0
)
velocity_factor
=
2.0
f
;
stiff_agent
=
10000
;
radius_agent
=
15
;
double
stiff_obst
=
0.01
;
double
radius_obst
=
12
;
stiff_obst
=
0.02
;
radius_obst
=
20
;
double
long_radius_agent
=
40
;
double
long_radius_obst
=
10
;
long_radius_agent
=
25
;
long_radius_obst
=
5
;
for
(
unsigned
int
i
=
0
;
i
<
nbVertices
;
++
i
)
{
...
...
@@ -186,7 +192,7 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
if
(
dInside
==
NIL
)
dInside
=
sim_
->
envMap_
.
getBelongingCell
(
pos
[
0
]);
if
(
rigid_
&&
index_parent
<
1
)
if
(
index_parent
<
1
)
{
pos
.
push_back
(
center
);
pos
.
push_back
(
center
);
...
...
@@ -206,7 +212,7 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
#endif
if
(
rigid_
&&
index_parent
<
1
)
if
(
index_parent
<
1
)
{
belonging_cells
=
new
std
::
vector
<
Dart
>
[
nbParticles
-
1
];
neighbor_cells
=
new
std
::
vector
<
Dart
>
[
nbParticles
-
1
];
...
...
@@ -259,43 +265,43 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
// width = (pos[1]-pos[2]).norm();
// sum_dist_foci_rest = 2*(length + width*(sqrt(2)-0.5));
if
(
parent
==
NULL
)
//départ face à la cible en cas d'obstacles pouvant effectuer des rotations
{
VEC3
axeZ
=
VEC3
(
0
,
0
,
1
);
#ifdef TWO_AND_HALF_DIM
VEC3
normale
=
Algo
::
Surface
::
Geometry
::
faceNormal
<
PFP
>
(
sim
->
envMap_
.
map
,
parts_
[
0
]
->
d
,
sim
->
envMap_
.
position
);
#else
VEC3
normale
=
axeZ
;
#endif
Geom
::
Matrix44f
rot
;
rot
.
identity
()
;
angle
=
Geom
::
angle
(
goals_
[
curGoal_
]
-
center
,
front
-
center
);
Geom
::
rotate
(
axeZ
,
angle
,
rot
);
float
angle1
=
Geom
::
angle
(
normale
,
VEC3
(
0
,
0
,
1
)
)
;
// CGoGNout<<"angle : "<<angle<<CGoGNendl;
VEC3
axis
=
VEC3
(
0
,
0
,
1
)
^
normale
;
// Geom::translate(center[0],center[1],center[2],rot);
Geom
::
rotate
(
axis
,
angle1
,
rot
)
;
// std::cout<<" angle : "<< angle;
for
(
unsigned
int
i
=
0
;
i
<
nbVertices
;
++
i
)
{
// std::cout<<" || pos[i] avant : "<< pos [i];
Geom
::
transform
(
pos
[
i
],
rot
);
// std::cout<<" || pos[i] APRES : "<< pos [i]<<std::endl;
parts_
[
i
]
->
move
(
pos
[
i
]);
}
angle
=
0
;
front
=
(
pos
[
0
]
+
pos
[
1
])
/
2
;
}
//
if ( parent==NULL) //départ face à la cible en cas d'obstacles pouvant effectuer des rotations
//
{
//
VEC3 axeZ=VEC3 (0,0,1);
//
#ifdef TWO_AND_HALF_DIM
//
//
VEC3 normale = Algo::Surface::Geometry::faceNormal<PFP>(sim->envMap_.map, parts_[0]->d, sim->envMap_.position);
//
#else
//
VEC3 normale =axeZ;
//
#endif
//
Geom::Matrix44f rot ;
//
rot.identity() ;
//
angle = Geom::angle(goals_[curGoal_] - center,front - center);
//
Geom::rotate(axeZ,angle,rot);
//
//
float angle1 = Geom::angle(normale, VEC3 (0,0,1) ) ;
//
// CGoGNout<<"angle : "<<angle<<CGoGNendl;
//
VEC3 axis = VEC3(0,0,1) ^ normale ;
//
//
// Geom::translate(center[0],center[1],center[2],rot);
//
Geom::rotate(axis, angle1, rot) ;
//
//
//
//
std::cout<<" angle : "<< angle;
//
//
for (unsigned int i = 0; i < nbVertices; ++i)
//
{
//
//
std::cout<<" || pos[i] avant : "<< pos [i];
//
Geom::transform(pos[i],rot);
//
//
std::cout<<" || pos[i] APRES : "<< pos [i]<<std::endl;
//
//
parts_[i]->move(pos[i]);
//
//
//
}
//
angle=0;
//
front=(pos[0] + pos[1]) / 2;
//
}
groundFace
=
map
.
newFace
(
nbVertices
);
...
...
@@ -404,7 +410,7 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
}
/////obstacles lointain
if
(
rigid_
&&
index_parent
<
1
)
if
(
index_parent
<
1
)
{
Obstacle
*
o
=
new
Obstacle
(
parts_
[
nbVertices
]
->
getPosition
(),
parts_
[
nbVertices
+
1
]
->
getPosition
(),
...
...
@@ -415,15 +421,6 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
// CGoGNout<<" obstacle :"<< i << " num : "<< o<<CGoGNendl;
sim_
->
envMap_
.
pushObstacleInCells
(
o
);
// Obstacle* o2 = new Obstacle(parts_[nbVertices+1]->getPosition(),
// parts_[nbVertices]->getPosition(),
// this, nbVertices+1,1000,100,2500,20);
//
// obstacles_.push_back(o2);
//
// // CGoGNout<<" obstacle :"<< i << " num : "<< o<<CGoGNendl;
// sim_->envMap_.pushObstacleInCells(o2);
/// fin ajout
}
...
...
@@ -471,7 +468,7 @@ void MovingObstacle::draw(bool showPath)
// // if(obstacleNeighbors_.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_shader
->
setColor
(
Geom
::
Vec4f
(
0
,
0.3
,
0
,
0
));
// vert
m_render
->
draw
(
m_shader
,
Algo
::
Render
::
GL2
::
TRIANGLES
);
m_shader
->
setColor
(
Geom
::
Vec4f
(
0.
,
0.
,
0.
,
0.
));
...
...
@@ -515,7 +512,7 @@ void MovingObstacle::draw(bool showPath)
m_ds
->
end
();
m_ds
->
endList
();
}
if
(
true
)
//
show particles
if
(
true
)
//
affichage anticipation
{
m_ds
->
newList
(
GL_COMPILE_AND_EXECUTE
);
...
...
@@ -1218,9 +1215,9 @@ void MovingObstacle::updateForces()
float
rotor
=
0
;
if
(
index_parent
==
0
)
rotor
=
abs_angle
*
angle
>
0.0
1
f
?
0.01
f
:
abs_angle
*
angle
;
rotor
=
abs_angle
*
angle
>
0.0
05
f
?
abs_angle
*
0.005
f
:
angle
;
else
rotor
=
abs_angle
*
angle
;
rotor
=
abs_angle
*
angle
>
0.02
f
?
abs_angle
*
0.005
f
:
angle
;
// CGoGNout << "Obstacle "<< index << CGoGNendl;
// CGoGNout << "vitesse : "<< velocity_ << CGoGNendl;
// on fait tourner l'obstacle
...
...
@@ -1242,7 +1239,7 @@ void MovingObstacle::updateForces()
velocity
[
d
]
+=
nouvpos
[
0
]
*
x
+
nouvpos
[
1
]
*
y
;
#else
position
[
d
]
+=
rotate2D
(
position
[
d
],
center
,
abs_angle
*
rotor
);
position
[
d
]
+=
rotate2D
(
position
[
d
],
center
,
rotor
);
#endif
position
[
d
]
+=
(
velocity_
*
sim_
->
timeStep_
);
velocity
[
d
]
=
position
[
d
]
-
oldPos
;
...
...
@@ -1251,7 +1248,7 @@ void MovingObstacle::updateForces()
#ifdef EXPORTING_BOXES
#ifndef TWO_AND_HALF_DIM
position
[
map
.
phi
<
211
>
(
d
)]
+=
rotate2D
(
position
[
map
.
phi
<
211
>
(
d
)],
center
,
abs_angle
*
rotor
);
position
[
map
.
phi
<
211
>
(
d
)]
+=
rotate2D
(
position
[
map
.
phi
<
211
>
(
d
)],
center
,
rotor
);
position
[
map
.
phi
<
211
>
(
d
)]
+=
(
velocity_
*
sim_
->
timeStep_
);
#endif
...
...
@@ -1266,10 +1263,9 @@ void MovingObstacle::updateForces()
}
front
=
(
position
[
0
]
+
position
[
1
])
/
2
;
if
(
angle
>
0
)
angle
-=
rotor
;
else
angle
+=
rotor
;
angle
-=
abs_angle
*
rotor
;
}
center
=
bary
/
nbVertices
;
...
...
@@ -1366,6 +1362,8 @@ void MovingObstacle::updateRegistration()
d
=
map
.
phi_1
(
d
);
}
center
=
bary
/
nbVertices
;
parts_
[
nbVertices
]
->
move
(
center
);
parts_
[
nbVertices
+
1
]
->
move
(
center
+
speed_detection_factor
*
velocity_
);
}
else
{
...
...
@@ -1419,13 +1417,16 @@ void MovingObstacle::updateRegistration()
// CGoGNout<< CGoGNendl;
// CGoGNout << "Apres une etape : Obstacle "<< i << CGoGNendl;
}
if
(
rigid_
&&
index_parent
<
1
)
if
(
index_parent
<
1
)
{
Obstacle
*
o
=
obstacles_
[
nbVertices
];
o
->
p1
=
parts_
[
nbVertices
]
->
getPosition
();
o
->
p2
=
parts_
[
nbVertices
+
1
]
->
getPosition
();
Dart
d1
=
parts_
[
nbVertices
]
->
d
;
Dart
d2
=
parts_
[
nbVertices
+
1
]
->
d
;
o
->
obst_radius_infl_agent
=
radius_agent
*
velocity_factor
;
o
->
obst_stiffness_agent
=
stiff_agent
*
velocity_factor
;
if
(
!
((
sim_
->
envMap_
.
map
.
sameFace
(
d1
,
d2
))
&&
(
parts_
[
nbVertices
]
->
crossCell
==
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
NO_CROSS
&&
parts_
[
nbVertices
+
1
]
->
crossCell
==
CGoGN
::
Algo
::
Surface
::
MovingObjects
::
NO_CROSS
)))
{
...
...
@@ -1624,17 +1625,25 @@ void MovingObstacle::computePrefVelocity() //calcul du vecteur optimal pour atte
{
goalVector
=
goals_
[
curGoal_
]
-
center
;
// goalVector = goals_[curGoal_] - position[groundFace] ;
VEC3
distVect
=
goals_
[
curGoal_
]
-
position
[
groundFace
]
;
float
goalDist2
=
distVect
.
norm2
()
;
float
goalDist2
=
goalVector
.
norm2
()
;
if
(
goalDist2
<
(
rigid_
?
5
:
1.4
)
*
(
gravity_dist
*
gravity_dist
)
)
if
(
goalDist2
<
(
gravity_dist
*
gravity_dist
)
)
{
curGoal_
=
(
curGoal_
+
1
)
%
goals_
.
size
()
;
velocity_factor
/=
1.3
;
if
(
parent
!=
NULL
)
// modification de vitesse des serpents
{
if
(
parent
->
old_Factor
>
velocity_factor
)
{
velocity_factor
=
parent
->
old_Factor
;
}
else
{
parent
->
old_Factor
=
velocity_factor
;
velocity_factor
/=
2
;
}
}
goalVector
=
goals_
[
curGoal_
]
-
center
;
// goalVector = goals_[curGoal_] - position[groundFace] ;
goalDist2
=
goalVector
.
norm2
()
;
...
...
@@ -1710,12 +1719,13 @@ void MovingObstacle::computePrefVelocity() //calcul du vecteur optimal pour atte
}
else
//articulated
{
VEC3
nextFront
=
get_center
(
parent
,
index_parent
-
1
);
goalVector
=
(
nextFront
-
center
);
float
distFront
=
(
center
-
front
).
norm
();
float
distCenter
=
goalVector
.
norm
();
VEC3
nextCenter
=
parent
->
get_center
(
index_parent
-
1
);
VEC3
nextFront
=
parent
->
get_front
(
index_parent
-
1
);
VEC3
nextBack
=
2
*
nextCenter
-
nextFront
;
goalVector
=
(
nextBack
-
center
);
float
goalDist
=
distCenter
-
distFront
;
float
goalDist
=
(
front
-
nextBack
).
norm
()
;
goalVector
.
normalize
()
;
goalVector
*=
goalDist
;
...
...
src/simulator.cpp
View file @
b7f81b10
...
...
@@ -17,10 +17,10 @@ timespec timespec_delta(const timespec& t1, const timespec& t2) {
Simulator::Simulator(unsigned int config, unsigned int minS, unsigned int nbAgent, unsigned int nbObst, bool resolution) :
#ifdef TWO_AND_HALF_DIM
timeStep_(0.
4
f),
timeStep_(0.
1
f),
#else
// timeStep_(config > 2 ? 0.01
f : 0.25f),
timeStep_(0.25
f),
timeStep_(config > 2 ? 0.02
f : 0.25f),
// timeStep_(0.1
f),
#endif
globalTime_(0.0f),
...
...
@@ -78,10 +78,10 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
//// setupCityScenario(-1.0f * (12 * (70.0f / 2.0f) - 10),
//// -1.0f * (12 * (70.0f / 2.0f) - 10), 20, 20);
break ;
case 4 :
setupCrowdedScenario(nbAgent,
nbObst
,1) ;
case 4 :
//scenario foule dense + train
setupCrowdedScenario(nbAgent,
8
,1) ;
break ;
case 5:
case 5:
//strasbourg
envMap_.init(config, 1600.0f, 1200.0f, minSize, 400.0f) ; //svg import
setupScenario(nbAgent, true) ;
// SelectorCellNotMarked<PFP::MAP> scnm(envMap_.pedWayMark);
...
...
@@ -94,7 +94,7 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
envMap_.init(config,200.0,200.0, minSize, 400.0f);
addMovingObstacles(nbObst, 1, 500,
1
);
addMovingObstacles(nbObst, 1, 500,
3
);
setupPlanetScenario(nbAgent,nbObst);
addPathToObstacles(envMap_.buildingMark, true);
addPathsToAgents();
...
...
@@ -440,7 +440,7 @@ void Simulator::setupCircleScenario(unsigned int nbAgents , unsigned int nbObsta
void Simulator::setupCrowdedScenario(unsigned int nbAgents , unsigned int nbObstacles, int snake)
{
if (multires)
envMap_.init(config,
1500.0f, 150
0.0f, minSize, 400.0f) ; //grosses cases
envMap_.init(config,
750.0f, 75
0.0f, minSize, 400.0f) ; //grosses cases
else
{
...
...
@@ -480,7 +480,9 @@ void Simulator::setupCrowdedScenario(unsigned int nbAgents , unsigned int nbObst
for (unsigned int cury = 0 ; cury < nby ; ++cury)
{
VEC3 posagent = posinit + VEC3(ecart * curx, ecart * cury, 0.0f) ;
addAgent(posagent, posagent, dCell) ;
VEC3 goal = posagent;
goal[0]*=-1;
addAgent(posagent, goal, dCell) ;
}
}
...
...
@@ -509,7 +511,8 @@ void Simulator::setupCrowdedScenario(unsigned int nbAgents , unsigned int nbObst
if(snake==1)
{
int snakeSize=10;
CGoGNout<<"IT'S A SNAKE"<<CGoGNendl;
int snakeSize=nbObstacles;
std::vector<PFP::VEC3> positions [snakeSize] ;
positions[0]=vPos;
goal=center;
...
...
@@ -549,9 +552,12 @@ else
goals.push_back(goal);
goals.push_back(start);
curGoal = 0;
mo4= new MovingObstacle(this, 0,vPos,goals, true, true,curGoal);
if (nbObstacles !=0)
{
mo4= new MovingObstacle(this, 0,vPos,goals, true, true,curGoal);
movingObstacles_.push_back(mo4);
movingObstacles_.push_back(mo4);
}
}