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
e9c23882
Commit
e9c23882
authored
Mar 30, 2015
by
Thomas Pitiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change objectif
parent
ab0782c2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
120 additions
and
32 deletions
+120
-32
.qglviewer.xml
.qglviewer.xml
+3
-3
include/SocialAgents3D.ui
include/SocialAgents3D.ui
+7
-0
include/agent.h
include/agent.h
+2
-0
include/viewer.h
include/viewer.h
+8
-2
src/agent.cpp
src/agent.cpp
+26
-4
src/simulator.cpp
src/simulator.cpp
+6
-8
src/viewer.cpp
src/viewer.cpp
+68
-15
No files found.
.qglviewer.xml
View file @
e9c23882
...
...
@@ -5,15 +5,15 @@
<backgroundColor
red=
"51"
blue=
"51"
green=
"51"
/>
</State>
<Display
axisIsDrawn=
"false"
gridIsDrawn=
"false"
FPSIsDisplayed=
"false"
cameraIsEdited=
"false"
/>
<Geometry
fullScreen=
"false"
width=
"1
200"
posX=
"0"
height=
"701
"
posY=
"0"
/>
<Geometry
fullScreen=
"false"
width=
"1
198"
posX=
"0"
height=
"800
"
posY=
"0"
/>
<Camera>
<Parameters
fieldOfView=
"0.785398"
sceneRadius=
"8.66025"
Type=
"PERSPECTIVE"
zNearCoefficient=
"0.005"
orthoCoef=
"0.414214"
zClippingCoefficient=
"1.73205"
>
<SceneCenter
x=
"0"
y=
"0"
z=
"0"
/>
</Parameters>
<Stereo
focusDistance=
"20.9077"
physScreenWidth=
"0.5"
IODist=
"0.062"
/>
<ManipulatedCameraFrame>
<position
x=
"
2.30521"
y=
"8.11195"
z=
"6.35901
"
/>
<orientation
q0=
"-0.
373252"
q1=
"-0.244231"
q2=
"-0.676103"
q3=
"0.586446
"
/>
<position
x=
"
0.676359"
y=
"7.84622"
z=
"21.2158
"
/>
<orientation
q0=
"-0.
176647"
q1=
"0.006936"
q2=
"-0.0459918"
q3=
"0.983175
"
/>
<ManipulatedParameters
transSens=
"1"
zoomSens=
"1"
rotSens=
"1"
wheelSens=
"1"
spinSens=
"0.3"
/>
<ManipulatedCameraParameters
zoomsOnPivotPoint=
"false"
flySpeed=
"0.0866025"
rotatesAroundUpVector=
"false"
>
<sceneUpVector
x=
"0"
y=
"1"
z=
"0"
/>
...
...
include/SocialAgents3D.ui
View file @
e9c23882
...
...
@@ -53,6 +53,13 @@
</property>
<item
row=
"0"
column=
"0"
>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<widget
class=
"QCheckBox"
name=
"check_timer"
>
<property
name=
"text"
>
<string>
Animate
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"checkBox_volumes"
>
<property
name=
"text"
>
...
...
include/agent.h
View file @
e9c23882
...
...
@@ -32,6 +32,8 @@ public:
//particule
Particule
*
part_
;
static
float
radius
;
// taille de l'agent
// objectif(s)
unsigned
int
curGoal_
;
std
::
vector
<
VEC3
>
goals_
;
...
...
include/viewer.h
View file @
e9c23882
...
...
@@ -137,6 +137,7 @@ public:
Geom
::
Vec3f
m_PosObj
;
Simulator
simul
;
Utils
::
QT
::
uiDockInterface
dock
;
QTimer
*
timer
;
public:
Volusion
()
:
...
...
@@ -159,7 +160,10 @@ public:
m_explode_render
(
NULL
),
dartSlider
(
0
)
{}
{
}
void
displayMO
();
void
displayObj
();
...
...
@@ -173,9 +177,11 @@ protected:
void
cb_keyPress
(
int
code
);
void
cb_Open
();
void
animate
()
;
// slots locaux
public
slots
:
void
animate
()
;
void
slot_timer
(
bool
b
);
void
volumes_onoff
(
bool
x
);
void
edges_onoff
(
bool
x
);
void
topo_onoff
(
bool
x
);
...
...
src/agent.cpp
View file @
e9c23882
#include "simulator.h"
float
Agent
::
radius
=
0.05
;
// initialisation Agent
void
Agent
::
init
(
Simulator
*
sim
,
VEC3
startingPoint
,
std
::
vector
<
VEC3
>
goals
,
Dart
d
)
{
...
...
@@ -17,7 +19,6 @@ void Agent::init(Simulator * sim ,VEC3 startingPoint,std::vector<VEC3> goals,Dar
maxVelocity_
=
3.0
f
;
//lien simulateur
agentNo
=
sim_
->
agents
.
size
()
;
alive
=
true
;
sim_
->
agents
.
push_back
(
this
);
}
...
...
@@ -69,8 +70,30 @@ void Agent::updateNeighbors()
}
void
Agent
::
computePrefVelocity
()
{
prefVelocity_
=
goals_
[
curGoal_
]
-
part_
->
getPosition
();
if
(
prefVelocity_
.
norm
()
>
maxVelocity_
)
VEC3
goalVector
=
goals_
[
curGoal_
]
-
part_
->
getPosition
()
;
float
goalDist2
=
goalVector
.
norm2
()
;
// Si l'agent arrive à proximité de l'objectif,
// alors il passe à l'objectif suivant
// CGoGNout<<"goalDist :"<<goalDist2<<" et radius :" <<radius *radius<<CGoGNendl;
if
(
goalDist2
<
0.1
)
{
// CGoGNout<<"obj atteint"<<CGoGNendl;
curGoal_
=
(
curGoal_
+
1
)
%
goals_
.
size
()
;
goalVector
=
goals_
[
curGoal_
]
-
part_
->
getPosition
()
;
goalDist2
=
goalVector
.
norm2
()
;
}
// goadDist2 est le vecteur reliant l'agent à l'objectif.
// Tant que ce vecteur a une norme supérieure à maxSpeed_
// (i.e. tant qu'il est encore assez loin de l'objectif)
// la vitesse sera de maxSpeed_. Sinon, s'il est plus
// proche, la vitesse diminue.
prefVelocity_
=
goalVector
;
if
(
prefVelocity_
.
norm2
()
>
maxVelocity_
*
maxVelocity_
)
{
prefVelocity_
.
normalize
();
prefVelocity_
*=
maxVelocity_
;
...
...
@@ -79,7 +102,6 @@ void Agent::computePrefVelocity()
void
Agent
::
computeAvoidanceVelocity
()
{
avoidanceVelocity_
;
if
(
avoidanceVelocity_
.
norm
()
>
maxVelocity_
)
{
avoidanceVelocity_
.
normalize
();
...
...
src/simulator.cpp
View file @
e9c23882
...
...
@@ -5,7 +5,7 @@
Simulator
::
Simulator
()
{
aiguille
=
NULL
;
}
...
...
@@ -33,6 +33,8 @@ void Simulator::init(int argc, char **argv)
// initEmptyMovingObject();
}
void
Simulator
::
doStep
()
{
for
(
Agent
*
ag
:
agents
)
...
...
@@ -50,11 +52,6 @@ void Simulator::doStep()
}
++
nbSteps_
;
}
...
...
@@ -83,10 +80,11 @@ void Simulator::initAgents(int nbAgents)
std
::
vector
<
VEC3
>
goals
;
goals
.
push_back
(
goal
);
goals
.
push_back
(
start
);
Agent
*
ag
=
new
Agent
(
this
,
start
,
goals
);
CGoGNout
<<
"agent initialisé : "
<<
ag
->
agentNo
<<
CGoGNendl
;
new
Agent
(
this
,
start
,
goals
);
// CGoGNout<<"agent n°" << agents_[i]->agentNo << " : "<< agents_[i]<<CGoGNendl;
}
CGoGNout
<<
"agent initialisé : "
<<
nbAgents
<<
CGoGNendl
;
}
void
Simulator
::
initSurfaces
()
...
...
src/viewer.cpp
View file @
e9c23882
...
...
@@ -24,6 +24,13 @@
#include "viewer.h"
void
Volusion
::
slot_timer
(
bool
b
)
{
b
?
timer
->
start
()
:
timer
->
stop
()
;
// clock_gettime(CLOCK_MONOTONIC, &startTime) ;
// display_times =b;
}
void
Volusion
::
dart_onoff
(
bool
x
)
{
draw_dart
=
x
;
...
...
@@ -168,25 +175,40 @@ void Volusion::cb_keyPress(int code)
{
switch
(
code
)
{
case
'r'
:
{
#ifndef IHMap
// simul.envMap_.popSegment(simul.objects[0]->Segments_[0]);
case
'r'
:
{
#ifndef IHMap
// simul.envMap_.popSegment(simul.objects[0]->Segments_[0]);
// simul.envMap_.resetPartSubdiv(simul.objects[0]->Segments_[0]);
// simul.envMap_.resetPartSubdiv
(simul.objects[0]->Segments_[0]);
// simul.envMap_.FirstRegistrationSegment
(simul.objects[0]->Segments_[0]);
// simul.envMap_.FirstRegistrationSegment(simul.objects[0]->Segments_[0]);
#else
#else
simul
.
aiguille
->
refine
();
m_MovingObjectVBO
->
updateData
(
simul
.
envMap_
.
position
);
simul
.
aiguille
->
refine
()
;
m_MovingObjectVBO
->
updateData
(
simul
.
envMap_
.
position
);
updateGL
()
;
#endif
updateGL
()
;
#endif
break
;
}
case
'a'
:
if
(
timer
->
isActive
())
{
timer
->
stop
();
dock
.
check_timer
->
setChecked
(
false
);
}
else
{
timer
->
start
();
dock
.
check_timer
->
setChecked
(
true
);
}
break
;
}
case
'm'
:
animate
();
break
;
default
:
break
;
}
...
...
@@ -212,7 +234,8 @@ void Volusion::cb_Open()
void
Volusion
::
cb_initGL
()
{
timer
=
new
QTimer
(
this
);
connect
(
timer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
animate
()))
;
// choose to use GL version 2
Utils
::
GLSLShader
::
setCurrentOGLVersion
(
2
);
...
...
@@ -279,7 +302,7 @@ void Volusion::cb_initGL()
m_agentSprite
=
new
Utils
::
PointSprite
();
m_agentSprite
->
setAttributePosition
(
m_agentsPosVBO
);
m_agentSprite
->
setAttributeColor
(
m_agentsColorVBO
);
m_agentSprite
->
setSize
(
0.05
f
);
m_agentSprite
->
setSize
(
Agent
::
radius
);
registerShader
(
m_agentSprite
);
...
...
@@ -774,6 +797,27 @@ void Volusion::cb_redraw()
// m_frame->draw();
// m_PlanePick->draw();
// }
// Affichage des stats dans la barre d'état
std
::
ostringstream
oss
;
// oss << "Elapsed time : " << elapsedTime/(1000000000.0f*refresh);
// oss << " | " << ((float)frames)/refresh << " fps" ;
oss
<<
" | Iterations "
<<
simul
.
nbSteps_
;
// oss << " | Neighbors " << simulator.totalNeighbors
// << " [" << (simulator.nbUpdates == 0 ? 0 : simulator.totalNeighbors / simulator.nbUpdates) << "]" ;
// oss << " | Near Neighbors " << simulator.nearNeighbors
// << " [" << (simulator.nbUpdates == 0 ? 0 : simulator.nearNeighbors / simulator.nbUpdates) << "]" ;
// oss << " | Sorts " << simulator.nbSorts
// << " [" << (simulator.nbUpdates == 0 ? 0 : 100 * simulator.nbSorts / simulator.nbUpdates) << "%]" ;
// oss << " | To Refine " << simulator.nbRefineCandidate ;
// oss << " | To Coarsen " << simulator.nbCoarsenCandidate ;
// if(simulator.detect_agent_collision)
// {
// oss << " | agents morts : "<<simulator.nb_dead;
// }
glColor3f
(
1.0
f
,
1.0
f
,
1.0
f
)
;
statusMsg
(
oss
.
str
().
c_str
())
;
}
...
...
@@ -925,7 +969,7 @@ void setupQtWidgets(char **argv, int argc,Volusion& sqt)
// envoit info BB a l'interface
sqt
.
setParamObject
(
sqt
.
m_WidthObj
,
sqt
.
m_PosObj
.
data
());
sqt
.
setCallBack
(
sqt
.
dock
.
check_timer
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
slot_timer
(
bool
)))
;
sqt
.
setCallBack
(
sqt
.
dock
.
checkBox_volumes
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
volumes_onoff
(
bool
))
);
sqt
.
setCallBack
(
sqt
.
dock
.
checkBox_edges
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
edges_onoff
(
bool
))
);
sqt
.
setCallBack
(
sqt
.
dock
.
checkBox_topo
,
SIGNAL
(
toggled
(
bool
)),
SLOT
(
topo_onoff
(
bool
))
);
...
...
@@ -953,6 +997,7 @@ void setupQtWidgets(char **argv, int argc,Volusion& sqt)
// sqt.clipping_onoff(false);
sqt
.
topo_onoff
(
false
);
sqt
.
edges_onoff
(
true
);
sqt
.
dock
.
check_timer
->
setChecked
(
false
);
sqt
.
dock
.
checkBox_MovingObject
->
setChecked
(
true
);
sqt
.
dock
.
checkBox_displayobjects
->
setChecked
(
true
);
sqt
.
dock
.
checkBox_ObjBelong
->
setChecked
(
false
);
...
...
@@ -976,6 +1021,14 @@ void setupQtWidgets(char **argv, int argc,Volusion& sqt)
sqt
.
dock
.
comboBoxEdge
->
addItem
(
s
,
2
);
}
}
}
void
Volusion
::
animate
()
{
// CGoGNout<<"animate"<<CGoGNendl;
simul
.
doStep
();
updateGL
();
}
int
main
(
int
argc
,
char
**
argv
)
...
...
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