Commit 88e09374 authored by Thomas Jund's avatar Thomas Jund

on avance

parents 76f1ee4a 9734ba27
......@@ -11,7 +11,7 @@
//#define SECURED
//#define EXPORTING_AGENT
//#define EXPORTING_OBJ
#define EXPORTING_OBJ
#define ARASH
......
......@@ -92,7 +92,7 @@ void generateCity(EnvMap& envMap, unsigned int nbBuildings, float minArea, float
#ifndef TWO_AND_HALF_DIM
generateBuilding<PFP>(envMap, d, (1 + (rand() % 3)) * maxHeight, rand() % 4) ;
#else
generateBuilding<PFP>(envMap, d, (1 + (rand() % 3)) * maxHeight, rand() % 3) ;
generateBuilding<PFP>(envMap, d, (1 + (rand() % 3)) * maxHeight, rand() % 4) ;
#endif
--nbBuilding ;
......@@ -485,7 +485,9 @@ Dart generateBuilding(EnvMap& envMap, Dart d, float height, unsigned int buildin
dRoof = extrudeFaceAndMark<PFP>(map, position, dRoofSmall, buildingMark,
height / 2.0f) ;
}
#ifndef TWO_AND_HALF_DIM
bool spike = rand() % 2 ;
if (spike)
{
typename PFP::VEC3 c = Algo::Surface::Geometry::faceCentroid<PFP>(map, dRoof, position) ;
......@@ -493,6 +495,7 @@ Dart generateBuilding(EnvMap& envMap, Dart d, float height, unsigned int buildin
dRoof = Algo::Surface::Modelisation::trianguleFace<PFP>(map, dRoof) ;
position[dRoof] = c ;
}
#endif
break ;
}
}
......
......@@ -32,7 +32,7 @@ class ArticulatedObstacle;
#include "pfp.h"
//#define EXPORTING3
#define EXPORTING3
#define TWO_AND_HALF_DIM
......@@ -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) ;
......@@ -131,7 +133,7 @@ public:
void pushObstNeighborInCells(Obstacle* o, Dart d);
void popObstNeighborInCells(Obstacle* o, Dart d);
void find_next(Obstacle* o,Dart * d, CellMarkerMemo<FACE>& cms);
bool movingObstacleFree(Dart d);
#ifdef EXPORTING3
std::vector<PFP::MAP *> m_map_Export;
std::vector<Algo::Surface::Import::OBJModel<PFP2> *> m_obj_Export;
......
......@@ -18,7 +18,7 @@
using namespace std;
//#define EXPORTING2
#define EXPORTING2
float get_angle3D(VEC3 v1, VEC3 v2);
......
......@@ -19,7 +19,7 @@
#endif
#endif
#define EXPORTING_BOXES
// #define EXPORTING_BOXES
#ifdef EXPORTING_BOXES
#include "Algo/Render/GL2/mapRender.h"
......
......@@ -98,9 +98,9 @@ public:
void setupCityScenario(int nbLines, int nbRank) ;
void setupScenario(unsigned int nbMaxAgent, bool pedWay=false) ;
void setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstacles);
void setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstacles, unsigned int nbx = 2,unsigned int nby= 2, float areaMin = 100.0f);
void addMovingObstacles(unsigned int nb, unsigned int type, float areaMin = 1400);
void addMovingObstacles(unsigned int nb, unsigned int type, float areaMin = 1400, int randLimace=12);
void addMovingObstacle(Dart d, unsigned int obstType=0);
void addAgent(const VEC3& start,const VEC3& goals);
......
# 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: 'limace.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 LimBuilding.png
This diff is collapsed.
# Blender MTL File: 'limace.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 LimSol.png
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) ;
VEC3 axisRot = base ^ dir ;
int sign = axisRot[2] > 0 ? 1 : -1 ;
......@@ -525,17 +540,9 @@ void Agent::update()
float myRot =sign * acos(-dir[1]);
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);
// }
m_transfo.identity();
Geom::rotateZ(myRot,m_transfo);
#endif
const VEC3 displ = getPosition();
Geom::translate(displ[0],displ[1],displ[2],m_transfo);
m_transfo.transpose();
// previousPos = getPosition();
......
......@@ -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) ;
......@@ -200,7 +202,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,200, 1000.0f) ;
CityGenerator::generateCity<PFP>(*this,200, 1000.0f, 20.0f) ;
break;
case 7 :
......@@ -209,7 +211,7 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
// CityGenerator::importObj<PFP>(*this, "./meshRessources/knot3Centered.obj");
CityGenerator::importObj<PFP>(*this, "./meshRessources/testTaches.obj");
scale(150.0f);
CityGenerator::generateCity<PFP>(*this,200, 150.0f, 10.0f) ;
CityGenerator::generateCity<PFP>(*this,300, 150.0f, 15.0f) ;
break;
case 8 :
......@@ -218,12 +220,12 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
CityGenerator::importObj<PFP>(*this, "./meshRessources/knot3Centered.obj");
scale(150.0f);
CityGenerator::generateCity<PFP>(*this,200, 150.0f,5.0f) ;
CityGenerator::generateCity<PFP>(*this,500, 150.0f,5.0f) ;
break;
case 9 :
CityGenerator::importObj<PFP>(*this, "./meshRessources/simpleSlugSmoothTest.obj");
scale(150.0f);
CityGenerator::generateCity<PFP>(*this,200, 150.0f,30.0f) ;
CityGenerator::generateCity<PFP>(*this,200, 150.0f,15.0f) ;
break;
}
......@@ -260,9 +262,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)
......@@ -1503,6 +1508,27 @@ int EnvMap::testOrientation(VEC3 p, VEC3 p1, VEC3 p2, Dart d)
}
bool EnvMap::movingObstacleFree(Dart d)
{
std::vector<Obstacle*>& obst = obstvect[d];
for(std::vector<Obstacle*>::const_iterator it = obst.begin() ; it != obst.end() ; ++it)
{
if((*it)->mo!=NULL)
{
return false;
}
}
return true;
}
#ifdef SPATIAL_HASHING
Geom::Vec2ui EnvMap::agentPositionCell(Agent* a)
{
......
......@@ -175,13 +175,18 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
edgeLength = map.addAttribute<float, EDGE>("edgeLength") ;
vertexAngle = map.addAttribute<float, DART>("vertexAngle") ;
}
for (unsigned int i = 0; i < nbVertices; ++i)
{
center += pos[i];
}
center /= nbVertices;
for (unsigned int i = 0; i < nbVertices; ++i)
{
#ifdef TWO_AND_HALF_DIM
Dart d = dInside;
parts_[i] = new CGoGN::Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP>(sim_->envMap_.map, d, pos[i], sim_->envMap_.position);
parts_[i] = new CGoGN::Algo::Surface::MovingObjects::ParticleCell2DAndHalf<PFP>(sim_->envMap_.map, d, center, sim_->envMap_.position);
parts_[i]->move(pos[i]);
#else
Dart d = sim_->envMap_.getBelongingCell(pos[i]);
#ifdef SECURED
......@@ -191,15 +196,12 @@ 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
center += pos[i];
if(i==0)
dDir = d;
}
center /= nbVertices;
front=(pos[0] + pos[1]) / 2;
front=(parts_[0]->getPosition() + parts_[1]->getPosition()) / 2;
if(!rigid_)
{
#ifdef TWO_AND_HALF_DIM
......@@ -212,7 +214,51 @@ 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();
// 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_[nbVertices]->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);
for (unsigned int i = 0; i < nbVertices; ++i)
......@@ -1049,7 +1095,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
......@@ -1143,18 +1189,16 @@ void MovingObstacle::updateRegistration()
#ifdef TWO_AND_HALF_DIM
position[e] = parts_[i]->getPosition(); //recalage de l'obstacle sur ses particules (qui elles ont bien suivi la carte au sol)
#endif
PFP::VEC3 normal = CGoGN::Algo::Surface::Geometry::faceNormal<PFP>(sim_->envMap_.map, parts_[i]->d, sim_->envMap_.position);
normal *= height;
position[map.phi_1(map.phi<12>(d))] = position[e]+normal;
#endif
bary += position[e];
d=map.phi<21>(d);
}
center = bary / nbVertices;
parts_[nbVertices]->move(position[centerDart]);
......@@ -1167,22 +1211,15 @@ void MovingObstacle::updateRegistration()
{
for (unsigned int i = 0; i < nbVertices; ++i)
{
VEC3 pos = getDilatedPosition(i);
parts_[i]->move(pos);
#ifdef TWO_AND_HALF_DIM
parts_[i]->move(pos);
Dart d(i);
#ifdef TWO_AND_HALF_DIM
position[d] = parts_[i]->getPosition(); //recalage de l'obstacle sur ses particules (qui elles ont bien suivi la carte au sol)
#endif
PFP::VEC3 normal = CGoGN::Algo::Surface::Geometry::faceNormal<PFP>(sim_->envMap_.map, parts_[i]->d, sim_->envMap_.position);
normal *= height;
// std::cout << " phi11 d : " << map.phi<112>(d) <<" || d : "<<d<< std::endl;
normal *= height;
position[map.phi_1(d)] = position[d]+normal;
#endif
}
}
for (unsigned int i = 0; i < nbVertices; ++i)
......
......@@ -19,7 +19,7 @@ Simulator::Simulator(unsigned int config, unsigned int minS, unsigned int nbAgen
#ifdef TWO_AND_HALF_DIM
timeStep_(0.01f),
#else
timeStep_(0.25f),
timeStep_(config > 2 ? 0.01f : 0.25f),
#endif
// timeStep_(0.2f),
globalTime_(0.0f),
......@@ -91,35 +91,34 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
case 6:
envMap_.init(config,200.0,200.0, minSize, 400.0f);
setupPlanetScenario(nbAgent,nbObst);
addMovingObstacles(nbObst, 1);
addMovingObstacles(nbObst, 1, 600, 3);
setupPlanetScenario(nbAgent,nbObst, 3, 3);
addPathToObstacles(envMap_.buildingMark, true);
addPathsToAgents();
break;
case 7 : envMap_.init(config,200.0,200.0, minSize, 400.0f);
setupPlanetScenario(nbAgent,nbObst);
addMovingObstacles(nbObst, 1 , 100 );
addMovingObstacles(nbObst, 1 , 300 , 5 );
setupPlanetScenario(nbAgent,nbObst, 2 , 2);
addPathToObstacles(envMap_.buildingMark, true);
addPathsToAgents();
break;
case 8 : envMap_.init(config,200.0,200.0, minSize, 400.0f);
setupPlanetScenario(nbAgent,nbObst);
addMovingObstacles(nbObst, 1 , 100 );
addMovingObstacles(nbObst, 1 , 100 , 1);
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 , 100 );
addPathToObstacles(envMap_.buildingMark, true);
addPathsToAgents();
break;
#else
std::cout << "Agents not in 2.5D mode" << std::endl;
#endif
default:
std::cout << "Unknown scenario !" << std::endl ;
std::cout << "Unknown scenario ! or not in 2.5D mode" << std::endl ;
exit(1) ;
}
......@@ -752,7 +751,7 @@ void Simulator::setupScenario(unsigned int nbMaxAgent, bool pedWay)
swapAgentsGoals() ;
}
void Simulator::setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstacles)
void Simulator::setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstacles,unsigned int nbx,unsigned int nby, float areaMin)
{
/*
* Add agents, specifying their start position, and store their goals on the
......@@ -774,8 +773,6 @@ void Simulator::setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstac
d=envMap_.map.begin();
CellMarker<FACE> filled(envMap_.map);
unsigned int nbx =1;
unsigned int nby = 1;
unsigned int bMax = nbx * nby > 0 ? nbAgents / (nbx * nby) : nbAgents ;
......@@ -786,7 +783,8 @@ void Simulator::setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstac
Dart dCell;
while(!found && d != envMap_.map.end())
{
if(!filled.isMarked(d) && !envMap_.buildingMark.isMarked(d))
float area = Algo::Surface::Geometry::convexFaceArea<PFP>(envMap_.map, d, envMap_.position);
if(!filled.isMarked(d) && !envMap_.buildingMark.isMarked(d) && envMap_.movingObstacleFree(d)&& area >areaMin )
{
filled.mark(d);
pos = Algo::Surface::Geometry::faceCentroid<PFP>(envMap_.map, d, envMap_.position);
......@@ -825,7 +823,7 @@ void Simulator::setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstac
swapAgentsGoals();
}
void Simulator::addMovingObstacles(unsigned int nb, unsigned int type, float areaMin)
void Simulator::addMovingObstacles(unsigned int nb, unsigned int type, float areaMin, int randLimace)
{
TraversorF<PFP::MAP> tF(envMap_.map);
Dart d = tF.begin() ;
......@@ -836,11 +834,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_.pedWayMark.isMarked(d)
// && envMap_.obstvect[d].size() == 0
)
{
float area = Algo::Surface::Geometry::convexFaceArea<PFP>(envMap_.map, d, envMap_.position);
if(area>areaMin)
if(area>areaMin && (rand() % randLimace == 0))
{
dCell = d ;
found = true ;
......
......@@ -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();
}
......
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