Commit 56ab8a8e authored by pitiot's avatar pitiot

ok

parents d3f5c92d 05dc0550
......@@ -8,10 +8,10 @@
#include "spatialHashing.h"
//#define SECURED
// #define SECURED
//#define EXPORTING_AGENT
//#define EXPORTING_OBJ
#define EXPORTING_OBJ
#define ARASH
......
......@@ -60,6 +60,8 @@ public:
REAL maxCellSize ;
REAL minCellSize ;
REAL obstacleDistance ;
unsigned int config;
EnvMap() ;
void init(unsigned int config, REAL width, REAL height, REAL minSize, REAL maxSize) ;
......@@ -132,6 +134,7 @@ public:
void popObstNeighborInCells(Obstacle* o, Dart d);
void find_next(Obstacle* o,Dart * d, CellMarkerMemo<FACE>& cms);
bool movingObstacleFree(Dart d);
bool movingObstacleNeighborFree(Dart d);
#ifdef EXPORTING3
std::vector<PFP::MAP *> m_map_Export;
std::vector<Algo::Surface::Import::OBJModel<PFP2> *> m_obj_Export;
......
......@@ -19,7 +19,7 @@
#endif
#endif
#define EXPORTING_BOXES
// #define EXPORTING_BOXES
#ifdef EXPORTING_BOXES
#include "Algo/Render/GL2/mapRender.h"
......@@ -74,10 +74,15 @@ public:
unsigned int nbVertices;
#ifdef TWO_AND_HALF_DIM
CGoGN::Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP>* * parts_;
#else
CGoGN::Algo::Surface::MovingObjects::ParticleCell2D<PFP>* * parts_;
#ifdef SECURED
CGoGN::Algo::Surface::MovingObjects::ParticleCell2DSecured<PFP> * * parts_ ;
#else
#ifdef TWO_AND_HALF_DIM
CGoGN::Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP> * * parts_ ;
#else
CGoGN::Algo::Surface::MovingObjects::ParticleCell2D<PFP>* * parts_ ;
#endif
#endif
PFP::MAP map;
......
This diff is collapsed.
# Blender MTL File: 'None'
# Material Count: 1
newmtl _untitled.001
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 .
This diff is collapsed.
# Blender MTL File: 'None'
# Material Count: 1
newmtl _untitled
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 .
This diff is collapsed.
# Blender MTL File: 'taches.blend'
# Material Count: 1
newmtl _untitled.001
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 .
This diff is collapsed.
# Blender MTL File: 'taches.blend'
# Material Count: 1
newmtl _untitled
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 .
This diff is collapsed.
# Blender MTL File: 'None'
# Material Count: 1
newmtl _untitled.001
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 torusBuilding.png
This diff is collapsed.
# Blender MTL File: 'None'
# Material Count: 1
newmtl _untitled
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 torusSol.png
This diff is collapsed.
# Blender MTL File: 'None'
# Material Count: 1
newmtl _untitled
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 LimSimple.png
This diff is collapsed.
This diff is collapsed.
......@@ -516,8 +516,23 @@ void Agent::update()
meanDirection_.normalize() ;
}
#ifdef EXPORTING_OBJ
m_transfo.identity();
VEC3 dir = meanDirection_ ;
#ifdef TWO_AND_HALF_DIM
VEC3 n = Algo::Surface::Geometry::faceNormal<PFP>(sim_->envMap_.map, part_.getCell(), sim_->envMap_.position);
float angle = Geom::angle(n, VEC3(0,0,1) );
VEC3 axis = VEC3(0,0,1) ^ n ;
Geom::rotate(axis, angle, m_transfo) ;
VEC3 base(0, -1, 0) ;
Geom::transform(base,m_transfo);
angle = Geom::angle(dir, base );
Geom::rotate(n, angle, m_transfo) ;
#else
VEC3 base(0, -1, 0) ;
// Geom::Plane3D<float> pl = Algo::Surface::Geometry::facePlane<PFP>(sim_->envMap_.map, part_.d, sim_->envMap_.position);
// pl.project(dir);
......@@ -525,30 +540,10 @@ void Agent::update()
const VEC3 displ = getPosition();
// TraversorV<PFP2::MAP> tV(map);
// for(Dart d = tV.begin() ; d != tV.end() ; d = tV.next())
// {
// position[d] += rotate(position[d], previousPos, -previousRot);
// position[d] = position[d]+displ;
// position[d] += rotate(position[d], getPosition(), myRot);
// }
VEC3 normale = Algo::Surface::Geometry::faceNormal<PFP>(sim_->envMap_.map, part_.d, sim_->envMap_.position);
m_transfo.identity();
float angle2 = Geom::angle(dir, base ) ;
VEC3 axis2=VEC3(0,0,1);
if(angle2 != 0)
{
// CGoGNout<<"mexicain :" << agentNo << "angle : "<< angle2 <<CGoGNendl;
Geom::rotate(axis2, angle2, m_transfo) ;
}
float angle = Geom::angle(normale, VEC3 (0,0,1) ) ;
VEC3 axis = VEC3(0,0,1) ^ normale ;
if(angle != 0)
{
Geom::rotate(axis, angle, m_transfo) ;
}
Geom::rotateZ(myRot,m_transfo);
#endif
const VEC3 displ = getPosition();
Geom::translate(displ[0],displ[1],displ[2],m_transfo);
m_transfo.transpose();
......
......@@ -60,6 +60,8 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
std::cout << "Init EnvMap" << std::endl ;
VEC3 bottomLeft(-width / 2, -height / 2, 0.0f) ;
VEC3 topRight(width / 2, height / 2, 0.0f) ;
this->config = config;
geometry.reset() ;
geometry.addPoint(bottomLeft) ;
......@@ -215,15 +217,16 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
// CityGenerator::importObj<PFP>(*this, "./meshRessources/simpleSlugSmoothTest.obj");
CityGenerator::importObj<PFP>(*this, "./meshRessources/knot3Centered.obj");
CityGenerator::importObj<PFP>(*this, "./meshRessources/knot3CenteredSubSmooth.obj");
scale(150.0f);
CityGenerator::generateCity<PFP>(*this,500, 150.0f,5.0f) ;
CityGenerator::generateCity<PFP>(*this,1000, 150.0f,5.0f) ;
break;
case 9 :
CityGenerator::importObj<PFP>(*this, "./meshRessources/simpleSlugSmoothTest.obj");
// CityGenerator::importObj<PFP>(*this, "./meshRessources/LimSol.obj");
scale(150.0f);
CityGenerator::generateCity<PFP>(*this,200, 150.0f,15.0f) ;
// CityGenerator::generateCity<PFP>(*this,200, 150.0f,15.0f) ;
break;
}
......@@ -260,9 +263,12 @@ void EnvMap::initGL()
#ifdef EXPORTING3
std::vector<std::string> filenames;
std::vector<std::string> texturenames;
std::string dir("./meshRessources/PlaneteRessource/");
std::ostringstream tmp;
tmp << "./meshRessources/scenario" << config << "/" ;
std::string dir = tmp.str();
DIR *dp;
struct dirent *dirp;
if((dp = opendir(dir.c_str())) == NULL)
......@@ -1521,6 +1527,26 @@ bool EnvMap::movingObstacleFree(Dart d)
}
bool EnvMap::movingObstacleNeighborFree(Dart d)
{
std::vector<Obstacle*>& obst = neighborObstvect[d];
for(std::vector<Obstacle*>::const_iterator it = obst.begin() ; it != obst.end() ; ++it)
{
if((*it)->mo!=NULL)
{
return false;
}
}
return true;
}
......
......@@ -184,6 +184,7 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
{
#ifdef TWO_AND_HALF_DIM
Dart d = dInside;
parts_[i] = new CGoGN::Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP>(sim_->envMap_.map, d, center, sim_->envMap_.position);
parts_[i]->move(pos[i]);
#else
......@@ -195,12 +196,9 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
parts_[i] = new CGoGN::Algo::Surface::MovingObjects::ParticleCell2D<PFP>(sim_->envMap_.map, d, pos[i], sim_->envMap_.position);
#endif
#endif
if(i==0)
dDir = d;
}
front=(parts_[0]->getPosition() + parts_[1]->getPosition()) / 2;
......@@ -216,6 +214,7 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
#endif
#endif
}
// M appartient à l'ellipse ssi MF1 + MF2 = sum_dist_foci est une constante
// où F1 et F2 sont les deux foyers.
// length = (pos[0]-pos[1]).norm();
......@@ -910,7 +909,7 @@ void MovingObstacle::updateForces()
//stretch spring : /!\ max rigidity relative to the timestep used (unstable otherwise)
float norm = v1.norm();
float rigidity = 50.0f;
float rigidity = 10.0f;
float stretch = rigidity*(edgeLength[e]-norm);//4
float angularStretch = 0, angularStretch2 = 0;
......@@ -1097,7 +1096,7 @@ void MovingObstacle::updateForces()
normale.normalize();
VEC3 y = normale ^x;
y.normalize();
VEC3 nouvpos = rotate2D(VEC3 (1,0,0),(0,0,0),angle);
VEC3 nouvpos = rotate2D(VEC3(1,0,0),VEC3(0,0,0),angle);
position[d] += nouvpos[0]*x+nouvpos[1]*y;
#else
......@@ -1201,22 +1200,18 @@ void MovingObstacle::updateRegistration()
d=map.phi<21>(d);
}
center = bary / nbVertices;
parts_[nbVertices]->move(position[centerDart]);
#ifdef TWO_AND_HALF_DIM
#ifdef TWO_AND_HALF_DIM
position[centerDart] = parts_[nbVertices]->getPosition(); //recalage de l'obstacle sur ses particules (qui elles ont bien suivi la carte au sol)
#endif
#endif
}
else
{
for (unsigned int i = 0; i < nbVertices; ++i)
{
VEC3 pos = getDilatedPosition(i);
parts_[i]->move(pos);
Dart d(i);
......@@ -1226,8 +1221,6 @@ void MovingObstacle::updateRegistration()
PFP::VEC3 normal = CGoGN::Algo::Surface::Geometry::faceNormal<PFP>(sim_->envMap_.map, parts_[i]->d, sim_->envMap_.position);
normal *= height;
position[map.phi_1(d)] = position[d]+normal;
}
}
for (unsigned int i = 0; i < nbVertices; ++i)
......
......@@ -91,6 +91,7 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
case 6:
envMap_.init(config,200.0,200.0, minSize, 400.0f);
addMovingObstacles(nbObst, 1, 500, 1);
setupPlanetScenario(nbAgent,nbObst);
addPathToObstacles(envMap_.buildingMark, true);
......@@ -98,20 +99,21 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
break;
case 7 : envMap_.init(config,200.0,200.0, minSize, 400.0f);
addMovingObstacles(nbObst, 1 , 300 , 1 );
setupPlanetScenario(nbAgent,nbObst, 1 , 1);
addPathToObstacles(envMap_.buildingMark, true);
addPathsToAgents();
break;
case 8 : envMap_.init(config,200.0,200.0, minSize, 400.0f);
addMovingObstacles(nbObst, 1 , 100 , 1);
addMovingObstacles(nbObst, 1 , 300 , 5);
setupPlanetScenario(nbAgent,nbObst,1,1);
addPathToObstacles(envMap_.buildingMark, true);
addPathsToAgents();
break;
case 9 : envMap_.init(config,200.0,200.0, minSize, 400.0f);
addMovingObstacles(nbObst, 1 , 400 , 1);
setupPlanetScenario(nbAgent,nbObst);
addMovingObstacles(nbObst, 1 , 400 , 6);
setupPlanetScenario(nbAgent,nbObst, 1, 1, 300);
addPathToObstacles(envMap_.buildingMark, true);
addPathsToAgents();
break;
......@@ -834,11 +836,12 @@ void Simulator::addMovingObstacles(unsigned int nb, unsigned int type, float are
while (!found && d != tF.end())
{
if (!envMap_.buildingMark.isMarked(d)
&& !envMap_.pedWayMark.isMarked(d) && envMap_.obstvect[d].size() == 0
&& !envMap_.pedWayMark.isMarked(d)
// && envMap_.obstvect[d].size() == 0
)
{
float area = Algo::Surface::Geometry::convexFaceArea<PFP>(envMap_.map, d, envMap_.position);
if(area>areaMin && (rand() % randLimace == 0))
if(area>areaMin && envMap_.movingObstacleNeighborFree(d) && (rand() % randLimace == 0))
{
dCell = d ;
found = true ;
......@@ -969,7 +972,7 @@ void Simulator::addPathToObstacles(CellMarker<FACE>& markForbid, bool goalCenter
(*it)->goals_.clear();
Dart dStart = (*it)->parts_[0]->d;
while(markForbid.isMarked(dStart))
{
if(!markForbid.isMarked(envMap_.map.phi2(dStart)))
......@@ -979,12 +982,12 @@ void Simulator::addPathToObstacles(CellMarker<FACE>& markForbid, bool goalCenter
}
Dart dStop = dStart;
for (unsigned int j = 0 ; envMap_.buildingMark.isMarked(dStop)
|| j < dartDistForPath + rand() * 20
|| envMap_.map.sameFace(dStop, dStart)
|| markForbid.isMarked(dStop)
|| !envMap_.map.sameVolume(dStop,dStart)
// || !envMap_.map.sameVolume(dStop,dStart)
; ++j)
{
envMap_.map.next(dStop) ;
......@@ -993,6 +996,8 @@ void Simulator::addPathToObstacles(CellMarker<FACE>& markForbid, bool goalCenter
}
addPathToObstacle(*it, dStart, dStop, markForbid, goalCenterCell);
std::cout << "path computed for obstacle " << (*it)->index << std::endl;
}
}
......@@ -1103,7 +1108,7 @@ void Simulator::addPathsToAgents()
|| j < dartDistForPath + rand() * 20
|| envMap_.map.sameFace(dStop, dStart)
|| envMap_.obstacleMark.isMarked(dStop)
|| !envMap_.map.sameVolume(dStop,dStart)
// || !envMap_.map.sameVolume(dStop,dStart)
; ++j)
{
envMap_.map.next(dStop) ;
......@@ -1143,7 +1148,7 @@ void Simulator::addPathsToAgents()
|| envMap_.map.sameFace(dStop, dStop2)
|| envMap_.map.sameFace(dStop2, dStart)
|| envMap_.obstacleMark.isMarked(dStop)
|| !envMap_.map.sameVolume(dStop,dStart)
// || !envMap_.map.sameVolume(dStop,dStart)
; ++j)
{
envMap_.map.next(dStop2) ;
......
......@@ -801,8 +801,8 @@ void SocialAgents::cb_redraw()
}
// 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();
}
......@@ -1041,8 +1041,9 @@ void SocialAgents::animate()
// if (CityGenerator::animateCity<PFP>(&simulator.envMap_)) simulator.addPathToCorner() ;
// simulator.addPathsToAgents() ;
//
// std::cout << "t : " << simulator.globalTime_ << std::endl ;
//
std::cout << "t : " << nbIterations << std::endl ;
//
//
// timeval startTime ;
// gettimeofday(&startTime, NULL) ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment