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
63f28931
Commit
63f28931
authored
Feb 14, 2013
by
Thomas Jund
Browse files
new limace for tests
parent
35d362bc
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Debug/CMakeLists.txt
View file @
63f28931
...
...
@@ -9,11 +9,11 @@ ELSE (WIN32)
ENDIF
(
WIN32
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
${
CMAKE_CURRENT_SOURCE_DIR
}
../include
${
CGoGN_ROOT_DIR
}
/include
${
COMMON_INCLUDES
}
${
CMAKE_CURRENT_BINARY_DIR
}
)
file
(
...
...
Release/CMakeLists.txt
View file @
63f28931
...
...
@@ -10,10 +10,10 @@ ENDIF (WIN32)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
${
CMAKE_CURRENT_SOURCE_DIR
}
../include
${
CGoGN_ROOT_DIR
}
/include
${
COMMON_INCLUDES
}
${
CMAKE_CURRENT_SOURCE_DIR
}
)
file
(
...
...
meshRessources/Limace_2.mtl
0 → 100644
View file @
63f28931
# Blender MTL File: 'Limace.002.blend'
# Material Count: 1
newmtl _rect2987.png
Ns 0
Ka 0.000000 0.000000 0.000000
Kd 0.8 0.8 0.8
Ks 0.8 0.8 0.8
d 1
illum 2
map_Kd C:\Users\larue\Downloads\Limace.002.blend\limace.png
meshRessources/Limace_2.obj
0 → 100644
View file @
63f28931
This diff is collapsed.
Click to expand it.
src/agent.cpp
View file @
63f28931
...
...
@@ -246,37 +246,37 @@ void Agent::updateObstacleNeighbors()
for
(
std
::
vector
<
Obstacle
*>::
const_iterator
it
=
neighborObst
.
begin
()
;
it
!=
neighborObst
.
end
()
;
++
it
)
{
if
((
*
it
)
->
mo
==
NULL
)
{
float
distSq
=
distSqPointLineSegment
((
*
it
)
->
p1
,
(
*
it
)
->
p2
,
part_
.
getPosition
())
;
if
((
obstacleNeighbors_
.
size
()
<
maxNeighbors_
||
distSq
<
maxDistObst
)
&&
distSq
<
rangeSq_
)
{
if
(
Geom
::
testOrientation2D
(
part_
.
getPosition
(),
(
*
it
)
->
p1
,
(
*
it
)
->
p2
)
==
Geom
::
RIGHT
)
{
float
distSq
=
distSqPointLineSegment
((
*
it
)
->
p1
,
(
*
it
)
->
p2
,
part_
.
getPosition
())
;
if
((
obstacleNeighbors_
.
size
()
<
maxNeighbors_
||
distSq
<
maxDistObst
)
&&
distSq
<
rangeSq_
)
{
if
(
Geom
::
testOrientation2D
(
part_
.
getPosition
(),
(
*
it
)
->
p1
,
(
*
it
)
->
p2
)
==
Geom
::
RIGHT
)
{
if
(
distSq
>
maxDistObst
)
maxDistObst
=
distSq
;
obstacleNeighbors_
.
push_back
(
std
::
make_pair
(
distSq
,
*
it
))
;
}
if
(
distSq
>
maxDistObst
)
maxDistObst
=
distSq
;
obstacleNeighbors_
.
push_back
(
std
::
make_pair
(
distSq
,
*
it
))
;
}
}
else
{
float
distSq
=
distSqPointLineSegment
((
*
it
)
->
p1
,
(
*
it
)
->
p2
,
part_
.
getPosition
())
;
if
((
movingObstacleNeighbors_
.
size
()
<
maxNeighbors_
||
distSq
<
maxDistMovingObst
)
&&
distSq
<
rangeSq_
)
{
if
(
Geom
::
testOrientation2D
(
part_
.
getPosition
(),
(
*
it
)
->
p1
,
(
*
it
)
->
p2
)
==
Geom
::
RIGHT
)
{
if
(
distSq
>
maxDistMovingObst
)
maxDistMovingObst
=
distSq
;
movingObstacleNeighbors_
.
push_back
(
std
::
make_pair
(
distSq
,
*
it
))
;
}
}
else
{
float
distSq
=
distSqPointLineSegment
((
*
it
)
->
p1
,
(
*
it
)
->
p2
,
part_
.
getPosition
())
;
if
((
movingObstacleNeighbors_
.
size
()
<
maxNeighbors_
||
distSq
<
maxDistMovingObst
)
&&
distSq
<
rangeSq_
)
{
if
(
Geom
::
testOrientation2D
(
part_
.
getPosition
(),
(
*
it
)
->
p1
,
(
*
it
)
->
p2
)
==
Geom
::
RIGHT
)
{
}
if
(
distSq
>
maxDistMovingObst
)
maxDistMovingObst
=
distSq
;
movingObstacleNeighbors_
.
push_back
(
std
::
make_pair
(
distSq
,
*
it
))
;
}
}
}
}
}
// if (obstacleNeighbors_.size() > maxNeighbors_)
...
...
@@ -601,7 +601,7 @@ void Agent::computeNewVelocity()
int
obst_power
=
2
;
// the power to which elevate the agent-obstacle distance
Obstacle
*
obst
;
//
#define ARASH
#define ARASH
#ifdef ARASH
nb_mos
=
0
;
for
(
std
::
vector
<
std
::
pair
<
float
,
Obstacle
*>
>::
iterator
it
=
movingObstacleNeighbors_
.
begin
()
;
...
...
src/moving_mesh.cpp
View file @
63f28931
...
...
@@ -23,8 +23,15 @@ constrainedV(map)
// scale(2.5f);
// scale(0.5f);
// Geom::Matrix44f m;
// m.identity();
// VEC3 axis(1.0f,0.0f,0.0f);
// Geom::rotate(axis, float(M_PI/2.0f),m);
// transform(m);
VEC3
v
=
Algo
::
Surface
::
Geometry
::
faceCentroid
<
PFP
>
(
motherMap
,
d
,
motherPosition
)
;
translate
(
v
);
// translate(VEC3(0,0,5));
// TraversorV<PFP::MAP> tv(map);
// std::vector<Dart> obstDarts;
...
...
@@ -146,8 +153,11 @@ void MovingMesh::draw()
{
m_positionVBO
->
updateData
(
position
)
;
m_render
->
initPrimitives
<
PFP
>
(
map
,
allDarts
,
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
m_render
->
initPrimitives
<
PFP
>
(
map
,
allDarts
,
Algo
::
Render
::
GL2
::
LINES
)
;
m_simpleColorShader
->
setColor
(
Geom
::
Vec4f
(
1.0
,
0.627
,
0.0
,
0.
));
m_render
->
draw
(
m_simpleColorShader
,
Algo
::
Render
::
GL2
::
TRIANGLES
);
m_simpleColorShader
->
setColor
(
Geom
::
Vec4f
(
0.0
,
0.0
,
0.0
,
0.
));
m_render
->
draw
(
m_simpleColorShader
,
Algo
::
Render
::
GL2
::
LINES
);
}
std
::
vector
<
VEC3
>
MovingMesh
::
computeProjectedPointSet
(
float
maxHeight
)
...
...
src/moving_obstacle.cpp
View file @
63f28931
...
...
@@ -73,7 +73,6 @@ VEC3 rotate(VEC3 pos1, VEC3 center, float angle) // renvoie le déplacement nece
}
MovingObstacle
::
MovingObstacle
(
Simulator
*
sim
,
int
ind
,
std
::
vector
<
VEC3
>
pos
,
std
::
vector
<
VEC3
>
goals
,
bool
rigid
,
bool
spin
,
Dart
dInside
,
ArticulatedObstacle
*
art
,
int
indParent
)
:
nbVertices
(
pos
.
size
()),
center
(
0
),
...
...
@@ -137,7 +136,7 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
{
//extrude face to build a cage
// compute edgeLength for mass-spring
Algo
::
Surface
::
Modelisation
::
extrudeFace
<
PFP
>
(
map
,
position
,
groundFace
,
1
0
.0
f
)
;
Algo
::
Surface
::
Modelisation
::
extrudeFace
<
PFP
>
(
map
,
position
,
groundFace
,
1
5
.0
f
)
;
map
.
fillHole
(
groundFace
);
groundFace
=
map
.
phi2
(
groundFace
);
...
...
@@ -506,7 +505,7 @@ void MovingObstacle::update()
//stretch spring : /!\ max rigidity relative to the timestep used (unstable otherwise)
float
norm
=
v1
.
norm
();
float
rigidity
=
5
0.0
f
;
float
rigidity
=
7
0.0
f
;
float
stretch
=
rigidity
*
(
edgeLength
[
dd
]
-
v1
.
norm
());
VEC3
f
=
stretch
*
(
v1
/
norm
);
...
...
@@ -534,7 +533,7 @@ void MovingObstacle::update()
float
restAngle
=
vertexAngle
[
dd
];
if
(
restAngle
!=
0.0
f
)
{
float
angularRig
=
5
0.0
f
;
float
angularRig
=
7
0.0
f
;
float
curAngle
=
Algo
::
Surface
::
Geometry
::
angle
<
PFP
>
(
map
,
map
.
phi_1
(
dd
),
map
.
phi1
(
dd
),
position
);
float
angularStretch
=
angularRig
*
(
restAngle
-
curAngle
);
...
...
src/simulator.cpp
View file @
63f28931
...
...
@@ -665,7 +665,7 @@ void Simulator::addMovingObstacle(Dart d, unsigned int obstType)
{
std
::
vector
<
VEC3
>
vPos
;
VEC3
start
;
float
maxHeight
=
5
.0
f
;
float
maxHeight
=
2
.0
f
;
MovingMesh
*
mm
=
NULL
;
...
...
@@ -685,7 +685,7 @@ void Simulator::addMovingObstacle(Dart d, unsigned int obstType)
break
;
case
1
:
{
mm
=
new
MovingMesh
(
envMap_
,
d
,
"meshRessources/Limace
.ply
"
);
mm
=
new
MovingMesh
(
envMap_
,
d
,
"meshRessources/Limace
_2.obj
"
);
movingMeshes_
.
push_back
(
mm
);
vPos
=
mm
->
computeProjectedPointSet
(
maxHeight
);
}
...
...
src/viewer.cpp
View file @
63f28931
...
...
@@ -26,6 +26,7 @@
#include
"env_generator.h"
#include
<string>
#include
"glm/gtc/type_ptr.hpp"
#include
"Algo/Export/export.h"
SocialAgents
::
SocialAgents
(
unsigned
int
config
,
unsigned
int
minSize
,
unsigned
int
nbAgent
,
unsigned
int
nbObst
,
unsigned
int
iterations
)
:
m_renderStyle
(
0
),
...
...
@@ -287,11 +288,6 @@ void SocialAgents::initRendering()
m_Ground_Shader
->
setAttributePosition
(
m_Ground_VBO
);
registerShader
(
m_Ground_Shader
);
for
(
unsigned
int
i
=
0
;
i
<
simulator
.
movingMeshes_
.
size
()
;
++
i
)
registerShader
(
simulator
.
movingMeshes_
[
i
]
->
m_simpleColorShader
);
if
(
!
m_DeferedShader
.
loadShaders
(
"./shaders/Defered.vert"
,
"./shaders/Defered.frag"
)
)
std
::
cout
<<
__FUNCTION__
<<
": pas glop!"
<<
std
::
endl
;
...
...
@@ -299,6 +295,9 @@ void SocialAgents::initRendering()
std
::
cout
<<
__FUNCTION__
<<
": pas glop!"
<<
std
::
endl
;
#endif
for
(
unsigned
int
i
=
0
;
i
<
simulator
.
movingMeshes_
.
size
()
;
++
i
)
registerShader
(
simulator
.
movingMeshes_
[
i
]
->
m_simpleColorShader
);
}
void
SocialAgents
::
updateObstacleVBO
()
...
...
@@ -467,8 +466,7 @@ void SocialAgents::cb_redraw()
glClearColor
(
0.8
f
,
0.8
f
,
1.0
f
,
1.0
f
);
glClear
(
GL_COLOR_BUFFER_BIT
);
// glCullFace(GL_BACK);
glEnable
(
GL_CULL_FACE
);
// glEnable(GL_CULL_FACE);
glEnable
(
GL_MULTISAMPLE
);
glEnable
(
GL_LINE_SMOOTH
);
glHint
(
GL_LINE_SMOOTH_HINT
,
GL_NICEST
);
...
...
@@ -1477,6 +1475,12 @@ void SocialAgents::cb_keyPress(int keycode)
simulator
.
envMap_
.
buildingMark
,
filename
)
;
std
::
string
filename2
(
"myAgents.pos"
)
;
simulator
.
exportAgents
(
filename2
)
;
std
::
cout
<<
"exporting meshes"
<<
std
::
endl
;
std
::
string
filename3
(
"roadMap.ply"
)
;
std
::
string
filename4
(
"buildingMap.ply"
)
;
Algo
::
Surface
::
Export
::
exportPLY
<
PFP
>
(
simulator
.
envMap_
.
map
,
simulator
.
envMap_
.
position
,
filename3
.
c_str
(),
false
);
if
(
simulator
.
config
==
5
)
Algo
::
Surface
::
Export
::
exportPLY
<
PFP
>
(
simulator
.
envMap_
.
mapScenary
,
simulator
.
envMap_
.
positionScenary
,
filename4
.
c_str
(),
false
);
break
;
}
case
'p'
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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