Commit 3f25bf9d authored by Thomas's avatar Thomas
Browse files

modify the social agents environments

parent 48b7797e
...@@ -65,7 +65,6 @@ class Simulator; ...@@ -65,7 +65,6 @@ class Simulator;
// std::vector<Dart> includingFaces; // std::vector<Dart> includingFaces;
CGoGN::Algo::MovingObjects::ParticleCell2D<PFP> * part; CGoGN::Algo::MovingObjects::ParticleCell2D<PFP> * part;
float rangeSq; float rangeSq;
bool newCells;
bool treated; bool treated;
}; };
......
...@@ -10,6 +10,9 @@ namespace CityGenerator ...@@ -10,6 +10,9 @@ namespace CityGenerator
template <typename PFP> template <typename PFP>
void generateAbsolutSpiralOfDeath(typename PFP::MAP& map,typename PFP::TVEC3& position, DartMarker& closeMark, unsigned int side, float rMin, float rMax,float nbTurns); void generateAbsolutSpiralOfDeath(typename PFP::MAP& map,typename PFP::TVEC3& position, DartMarker& closeMark, unsigned int side, float rMin, float rMax,float nbTurns);
template <typename PFP>
void generateToboggan(typename PFP::MAP& map,typename PFP::TVEC3& position, DartMarker& closeMark, unsigned int side, float rMin, float rMax,float nbTurns);
template <typename PFP, typename EMBV> template <typename PFP, typename EMBV>
void generateSmallCity(typename PFP::MAP& map, EMBV& position, DartMarker& closeMark, float sideSize); void generateSmallCity(typename PFP::MAP& map, EMBV& position, DartMarker& closeMark, float sideSize);
......
...@@ -27,6 +27,120 @@ void generateAbsolutSpiralOfDeath(typename PFP::MAP& map,typename PFP::TVEC3& po ...@@ -27,6 +27,120 @@ void generateAbsolutSpiralOfDeath(typename PFP::MAP& map,typename PFP::TVEC3& po
map.initOrbitEmbedding(FACE_ORBIT); map.initOrbitEmbedding(FACE_ORBIT);
} }
template <typename PFP>
void generateToboggan(typename PFP::MAP& map,typename PFP::TVEC3& position, DartMarker& closeMark, unsigned int side, float rMin, float rMax,float nbTurns)
{
//the stairs
Algo::Modelisation::Polyhedron<PFP> prim(map,position);
prim.grid_topo(side,3);
//the slide
Algo::Modelisation::Polyhedron<PFP> prim2(map,position);
prim2.grid_topo(side/4,3);
float height=150;
prim2.embedHelicoid(rMin*4,rMax,-1*height,0.5f,-1);
// typename PFP::VEC3 transl(0,2*rMax,height);
typename PFP::VEC3 transl(-rMax/2,0,height);
CellMarker m(map, VERTEX_CELL) ;
for(Dart d=map.begin();d!=map.end();map.next(d)) {
if(!m.isMarked(d)) {
m.mark(d);
position[d] += transl;
position[d][0] *= 2.0f;
}
}
prim.embedHelicoid(rMin,rMax,height,nbTurns-0.5f);
Dart dStairsDown = map.phi_1(prim.getDart());
Dart dStairsUp = dStairsDown;
do {
closeMark.markOrbit(FACE_ORBIT,dStairsUp);
closeMark.markOrbit(FACE_ORBIT,map.phi2(map.phi1(map.phi1(map.phi2(map.phi_1(dStairsUp))))));
dStairsUp= map.phi2(map.phi1(map.phi1(dStairsUp)));
} while(map.phi2(dStairsUp)!=dStairsUp);
Dart dSlideUp = map.phi_1(prim2.getDart());
Dart dSlideDown = dSlideUp;
do {
closeMark.markOrbit(FACE_ORBIT,dSlideDown);
closeMark.markOrbit(FACE_ORBIT,map.phi2(map.phi1(map.phi1(map.phi2(map.phi_1(dSlideDown))))));
dSlideDown= map.phi2(map.phi1(map.phi1(dSlideDown)));
} while(map.phi2(dSlideDown)!=dSlideDown);
Algo::Modelisation::Polyhedron<PFP> primPathUp(map,position);
primPathUp.grid_topo(1,3);
Dart dPathUp = map.phi_1(primPathUp.getDart());
Algo::Modelisation::Polyhedron<PFP> primPathDown(map,position);
primPathDown.grid_topo(1,3);
Dart dPathDown = map.phi_1(primPathDown.getDart());
closeMark.markOrbit(FACE_ORBIT,dPathUp);
closeMark.markOrbit(FACE_ORBIT,dPathDown);
map.sewFaces(dStairsUp,dPathUp);
map.sewFaces(dSlideUp,map.phi1(map.phi1(dPathUp)));
map.sewFaces(dSlideDown,dPathDown);
map.sewFaces(dStairsDown,map.phi1(map.phi1(dPathDown)));
dPathUp = map.phi_1(map.alpha1(dPathUp));
dPathDown = map.phi_1(map.alpha1(dPathDown));
dSlideUp = map.phi_1(map.alpha1(dSlideUp));
dSlideDown =map.alpha_1(map.phi1(dSlideDown));
dStairsUp = map.alpha_1(map.phi1(dStairsUp));
dStairsDown = map.phi_1(map.alpha1(dStairsDown));
// Dart dPathUp = map.newOrientedFace(4);
// Dart dPathDown = map.newOrientedFace(4);
map.sewFaces(dStairsUp,dPathUp);
map.sewFaces(dSlideUp,map.phi1(map.phi1(dPathUp)));
map.sewFaces(dSlideDown,dPathDown);
map.sewFaces(dStairsDown,map.phi1(map.phi1(dPathDown)));
dPathUp = map.phi_1(map.alpha1(dPathUp));
dPathDown = map.phi_1(map.alpha1(dPathDown));
dSlideUp = map.phi_1(map.alpha1(dSlideUp));
dStairsUp = map.alpha_1(map.phi1(dStairsUp));
dSlideDown =map.alpha_1(map.phi1(dSlideDown));
dStairsDown = map.phi_1(map.alpha1(dStairsDown));
closeMark.markOrbit(FACE_ORBIT,dPathUp);
closeMark.markOrbit(FACE_ORBIT,dPathDown);
map.sewFaces(dStairsUp,dPathUp);
map.sewFaces(dSlideUp,map.phi1(map.phi1(dPathUp)));
map.sewFaces(dSlideDown,dPathDown);
map.sewFaces(dStairsDown,map.phi1(map.phi1(dPathDown)));
// map.sewFaces(dStairsDown,dPathDown);
// map.sewFaces(dSlideDown,map.phi1(map.phi1(dPathDown)));
// map.sewFaces(dStairs,dSlide);
map.closeMap(closeMark) ;
CellMarker traite(map,FACE_CELL);
for(Dart d = map.begin(); d!=map.end() ; map.next(d)) {
if(!traite.isMarked(d)) {
traite.mark(d);
map.splitFace(d,map.phi1(map.phi1(d)));
}
}
for(Dart d = map.begin(); d!=map.end() ; map.next(d)) {
if(closeMark.isMarked(d)) {
closeMark.markOrbit(FACE_ORBIT,d);
}
}
map.initOrbitEmbedding(FACE_ORBIT);
}
template <typename PFP, typename EMBV> template <typename PFP, typename EMBV>
void generateSmallCity(typename PFP::MAP& map, EMBV& position, DartMarker& closeMark, float sideSize) void generateSmallCity(typename PFP::MAP& map, EMBV& position, DartMarker& closeMark, float sideSize)
{ {
......
...@@ -53,6 +53,8 @@ class Simulator ...@@ -53,6 +53,8 @@ class Simulator
std::vector<PFP::VEC3 > socialAgents; std::vector<PFP::VEC3 > socialAgents;
void setPreferredNextCellVelocities();
// std::vector<Dart> path; // std::vector<Dart> path;
/** Added function */ /** Added function */
......
#include "agent.h" #include "agent.h"
#include "simulator.h" #include "simulator.h"
Agent::Agent(Simulator* sim, size_t agentNo) : agentNeighbors_(), maxNeighbors_(0), maxSpeed_(0.0f), neighborDist_(0.0f), newVelocity_(), obstacleNeighbors_(), orcaLines_(), position_(), prefVelocity_(), radius_(0.0f), sim_(sim), timeHorizon_(0.0f), timeHorizonObst_(0.0f), velocity_(), agentNo_(agentNo), goalNo_(agentNo), newCells(false), treated(false) Agent::Agent(Simulator* sim, size_t agentNo) : agentNeighbors_(), maxNeighbors_(0), maxSpeed_(0.0f), neighborDist_(0.0f), newVelocity_(), obstacleNeighbors_(), orcaLines_(), position_(), prefVelocity_(), radius_(0.0f), sim_(sim), timeHorizon_(0.0f), timeHorizonObst_(0.0f), velocity_(), agentNo_(agentNo), goalNo_(agentNo), treated(false)
{ {
rangeSq = sqr(timeHorizonObst_ * maxSpeed_ + radius_); rangeSq = sqr(timeHorizonObst_ * maxSpeed_ + radius_);
} }
Agent::Agent(Simulator* sim, const VEC_A& position, size_t agentNo) : agentNeighbors_(), maxNeighbors_(sim->defaultAgent_->maxNeighbors_), maxSpeed_(sim->defaultAgent_->maxSpeed_), neighborDist_(sim->defaultAgent_->neighborDist_), newVelocity_(sim->defaultAgent_->velocity_), obstacleNeighbors_(), orcaLines_(), position_(position), prefVelocity_(), radius_(sim->defaultAgent_->radius_), sim_(sim), timeHorizon_(sim->defaultAgent_->timeHorizon_), timeHorizonObst_(sim->defaultAgent_->timeHorizonObst_), velocity_(sim->defaultAgent_->velocity_), agentNo_(agentNo), goalNo_(agentNo), newCells(false), treated(false) Agent::Agent(Simulator* sim, const VEC_A& position, size_t agentNo) : agentNeighbors_(), maxNeighbors_(sim->defaultAgent_->maxNeighbors_), maxSpeed_(sim->defaultAgent_->maxSpeed_), neighborDist_(sim->defaultAgent_->neighborDist_), newVelocity_(sim->defaultAgent_->velocity_), obstacleNeighbors_(), orcaLines_(), position_(position), prefVelocity_(), radius_(sim->defaultAgent_->radius_), sim_(sim), timeHorizon_(sim->defaultAgent_->timeHorizon_), timeHorizonObst_(sim->defaultAgent_->timeHorizonObst_), velocity_(sim->defaultAgent_->velocity_), agentNo_(agentNo), goalNo_(agentNo), treated(false)
{ {
nearestDart = sim->envMap.getBelongingCell(VEC3(position[0],position[1],0)); nearestDart = sim->envMap.getBelongingCell(VEC3(position[0],position[1],0));
part = new Algo::MovingObjects::ParticleCell2D<PFP>(sim->envMap.map,nearestDart,position,sim->envMap.position,sim->envMap.closeMark); part = new Algo::MovingObjects::ParticleCell2D<PFP>(sim->envMap.map,nearestDart,position,sim->envMap.position,sim->envMap.closeMark);
rangeSq = sqr(timeHorizonObst_ * maxSpeed_ + radius_); rangeSq = sqr(timeHorizonObst_ * maxSpeed_ + radius_);
} }
Agent::Agent(Simulator* sim, const VEC_A& position, size_t agentNo, Dart d) : agentNeighbors_(), maxNeighbors_(sim->defaultAgent_->maxNeighbors_), maxSpeed_(sim->defaultAgent_->maxSpeed_), neighborDist_(sim->defaultAgent_->neighborDist_), newVelocity_(sim->defaultAgent_->velocity_), obstacleNeighbors_(), orcaLines_(), position_(position), prefVelocity_(), radius_(sim->defaultAgent_->radius_), sim_(sim), timeHorizon_(sim->defaultAgent_->timeHorizon_), timeHorizonObst_(sim->defaultAgent_->timeHorizonObst_), velocity_(sim->defaultAgent_->velocity_), agentNo_(agentNo), goalNo_(agentNo), newCells(false), treated(false) Agent::Agent(Simulator* sim, const VEC_A& position, size_t agentNo, Dart d) : agentNeighbors_(), maxNeighbors_(sim->defaultAgent_->maxNeighbors_), maxSpeed_(sim->defaultAgent_->maxSpeed_), neighborDist_(sim->defaultAgent_->neighborDist_), newVelocity_(sim->defaultAgent_->velocity_), obstacleNeighbors_(), orcaLines_(), position_(position), prefVelocity_(), radius_(sim->defaultAgent_->radius_), sim_(sim), timeHorizon_(sim->defaultAgent_->timeHorizon_), timeHorizonObst_(sim->defaultAgent_->timeHorizonObst_), velocity_(sim->defaultAgent_->velocity_), agentNo_(agentNo), goalNo_(agentNo), treated(false)
{ {
nearestDart = d; nearestDart = d;
part = new Algo::MovingObjects::ParticleCell2D<PFP>(sim->envMap.map,nearestDart,position,sim->envMap.position,sim->envMap.closeMark); part = new Algo::MovingObjects::ParticleCell2D<PFP>(sim->envMap.map,nearestDart,position,sim->envMap.position,sim->envMap.closeMark);
rangeSq = sqr(timeHorizonObst_ * maxSpeed_ + radius_); rangeSq = sqr(timeHorizonObst_ * maxSpeed_ + radius_);
} }
Agent::Agent(Simulator* sim, const VEC_A& position, float neighborDist, size_t maxNeighbors, float timeHorizon, float timeHorizonObst, float radius, const VEC_A& velocity, float maxSpeed, size_t agentNo) : agentNeighbors_(), maxNeighbors_(maxNeighbors), maxSpeed_(maxSpeed), neighborDist_(neighborDist), newVelocity_(velocity), obstacleNeighbors_(), orcaLines_(), position_(position), prefVelocity_(), radius_(radius), sim_(sim), timeHorizon_(timeHorizon), timeHorizonObst_(timeHorizonObst), velocity_(velocity), agentNo_(agentNo), goalNo_(agentNo), newCells(false), treated(false) Agent::Agent(Simulator* sim, const VEC_A& position, float neighborDist, size_t maxNeighbors, float timeHorizon, float timeHorizonObst, float radius, const VEC_A& velocity, float maxSpeed, size_t agentNo) : agentNeighbors_(), maxNeighbors_(maxNeighbors), maxSpeed_(maxSpeed), neighborDist_(neighborDist), newVelocity_(velocity), obstacleNeighbors_(), orcaLines_(), position_(position), prefVelocity_(), radius_(radius), sim_(sim), timeHorizon_(timeHorizon), timeHorizonObst_(timeHorizonObst), velocity_(velocity), agentNo_(agentNo), goalNo_(agentNo), treated(false)
{ {
nearestDart = sim->envMap.getBelongingCell(VEC3(position[0],position[1],0)); nearestDart = sim->envMap.getBelongingCell(VEC3(position[0],position[1],0));
part = new Algo::MovingObjects::ParticleCell2D<PFP>(sim->envMap.map,nearestDart,position,sim->envMap.position,sim->envMap.closeMark); part = new Algo::MovingObjects::ParticleCell2D<PFP>(sim->envMap.map,nearestDart,position,sim->envMap.position,sim->envMap.closeMark);
......
...@@ -99,7 +99,6 @@ bool EnvMap::simplifyVertex(Dart& d) ...@@ -99,7 +99,6 @@ bool EnvMap::simplifyVertex(Dart& d)
if (d1==dd) // last edge is pending edge inside of face if (d1==dd) // last edge is pending edge inside of face
finished=true; finished=true;
map.deleteFace(dd); map.deleteFace(dd);
// map.deleteOrientedFace(dd);
dd = d1; dd = d1;
} while (!finished); } while (!finished);
...@@ -223,7 +222,7 @@ void EnvMap::insertObstacleOfFace(PFP::AGENTS agents,const Dart d) ...@@ -223,7 +222,7 @@ void EnvMap::insertObstacleOfFace(PFP::AGENTS agents,const Dart d)
do { do {
if(closeMark.isMarked(dd) /*&& (position[map.phi2(dd)][2]==0.0 || position[map.phi1(map.phi2(dd))][2] ==0.0f)*/) { if(closeMark.isMarked(dd) /*&& (position[map.phi2(dd)][2]==0.0 || position[map.phi1(map.phi2(dd))][2] ==0.0f)*/) {
for(PFP::AGENTS::iterator it=agents.begin(); it!= agents.end(); ++it) { for(PFP::AGENTS::iterator it=agents.begin(); it!= agents.end(); ++it) {
// if(leftOf((*it)->part->m_position,position[map.phi2(dd)],position[map.phi1(map.phi2(dd))])<0.0f) { // if(leftOf((*it)->part->m_position,position[dd],position[map.phi1(dd)])<0.0f) {
(*it)->insertObstacleNeighbor(dd); (*it)->insertObstacleNeighbor(dd);
// } // }
} }
...@@ -340,8 +339,8 @@ void EnvMap::addNeighborAgents(PFP::AGENTS agentsFrom,PFP::AGENTS agentsTo) ...@@ -340,8 +339,8 @@ void EnvMap::addNeighborAgents(PFP::AGENTS agentsFrom,PFP::AGENTS agentsTo)
void EnvMap::updateMap() void EnvMap::updateMap()
{ {
// simplifyFaces(); // simplifyFaces();
subdivideFaces() ; // subdivideFaces() ;
map.setCurrentLevel(map.getMaxLevel()) ; // map.setCurrentLevel(map.getMaxLevel()) ;
} }
void EnvMap::subdivideFaces() void EnvMap::subdivideFaces()
...@@ -637,7 +636,6 @@ void EnvMap::resetAgentInFace(Agent * agent) ...@@ -637,7 +636,6 @@ void EnvMap::resetAgentInFace(Agent * agent)
agent->part->state = FACE_ORBIT; agent->part->state = FACE_ORBIT;
agent->part->move(agent->position_) ; agent->part->move(agent->position_) ;
// agent->part->d = d; // agent->part->d = d;
agent->newCells=true;
} }
void EnvMap::addObstacle(std::vector<VEC3> points) void EnvMap::addObstacle(std::vector<VEC3> points)
......
...@@ -14,17 +14,18 @@ Simulator::Simulator() : agents_(), defaultAgent_(0), globalTime_(0.0f), timeSte ...@@ -14,17 +14,18 @@ Simulator::Simulator() : agents_(), defaultAgent_(0), globalTime_(0.0f), timeSte
// CGoGN::CityGenerator::generateGrid<PFP,PFP::TVEC3>(envMap.map,envMap.position,100,100,50.0f,envMap.closeMark); // CGoGN::CityGenerator::generateGrid<PFP,PFP::TVEC3>(envMap.map,envMap.position,100,100,50.0f,envMap.closeMark);
envMap.sideSize = 70.0f; envMap.sideSize = 70.0f;
CGoGN::CityGenerator::generateSmallCity<PFP,PFP::TVEC3>(envMap.map,envMap.position,envMap.closeMark,envMap.sideSize); // CGoGN::CityGenerator::generateSmallCity<PFP,PFP::TVEC3>(envMap.map,envMap.position,envMap.closeMark,envMap.sideSize);
// CGoGN::CityGenerator::generateAbsolutSpiralOfDeath<PFP>(envMap.map,envMap.position,envMap.closeMark,2000,0.25,110,100); // CGoGN::CityGenerator::generateAbsolutSpiralOfDeath<PFP>(envMap.map,envMap.position,envMap.closeMark,2000,0.25,110,100);
CGoGN::CityGenerator::generateToboggan<PFP>(envMap.map,envMap.position,envMap.closeMark,100,0.25,200,10);
// std::cout << "simplify" << std::endl; // std::cout << "simplify" << std::endl;
// envMap.simplify(); // envMap.simplify();
envMap.map.init(); // envMap.map.init();
std::cout << "setup scenario" << std::endl; std::cout << "setup scenario" << std::endl;
// setupHelicoidScenario(1,50); // setupScenario();
setupScenario(); setupHelicoidScenario(1,50);
// Dart dStop=envMap.map.begin(); // Dart dStop=envMap.map.begin();
// for(unsigned int i=0;i<5000;++i) envMap.map.next(dStop); // for(unsigned int i=0;i<5000;++i) envMap.map.next(dStop);
...@@ -190,6 +191,45 @@ void Simulator::setPreferredVelocities(PFP::VEC3 posToReach) ...@@ -190,6 +191,45 @@ void Simulator::setPreferredVelocities(PFP::VEC3 posToReach)
} }
} }
void Simulator::setPreferredNextCellVelocities()
{
for (int i = 0; i < static_cast<int>(agents_.size()); ++i) {
Dart dNext = agents_[i]->part->d;
while(envMap.closeMark.isMarked(envMap.map.phi2(dNext)) && envMap.map.phi1(dNext) != agents_[i]->part->d)
dNext = envMap.map.phi1(dNext);
VEC3 goalVector;
if(envMap.closeMark.isMarked(envMap.map.phi2(dNext))) {
goalVector = VEC3(0,0,0);
}
else {
// goalVector = Algo::Geometry::faceCentroid<PFP>(envMap.map,envMap.map.phi2(dNext),envMap.position);
goalVector = (envMap.position[dNext]+envMap.position[envMap.map.phi2(dNext)])*0.5f;
goalVector -= agents_[i]->position_;
goalVector = normalize(goalVector);
}
// goalVector *= 0.5f;
// goalVector += agents_[i]->prefVelocity_;
// goalVector *= 0.5f;
// if (absSq(goalVector) > 1.0f) {
// goalVector = normalize(goalVector);
// }
this->setAgentPrefVelocity(i, goalVector);
/*
* Perturb a little to avoid deadlocks due to perfect symmetry.
*/
float angle = std::rand() * 2.0f * M_PI / RAND_MAX;
float dist = std::rand() * 0.0001f / RAND_MAX;
this->setAgentPrefVelocity(i, this->getAgentPrefVelocity(i) +
VEC3(dist*std::cos(angle), dist*std::sin(angle),0.0f));
}
}
void Simulator::setPreferredPathVelocities() void Simulator::setPreferredPathVelocities()
{ {
for (int i = 0; i < static_cast<int>(agents_.size()); ++i) { for (int i = 0; i < static_cast<int>(agents_.size()); ++i) {
...@@ -307,7 +347,7 @@ void Simulator::setupHelicoidScenario(float rMax,float rMin) ...@@ -307,7 +347,7 @@ void Simulator::setupHelicoidScenario(float rMax,float rMin)
DartMarkerStore filled(envMap.map); DartMarkerStore filled(envMap.map);
bool found=false; bool found=false;
int nbPack=3000; int nbPack=2000;
for (int i = 0; i < nbPack && d != envMap.map.end(); ++i) { for (int i = 0; i < nbPack && d != envMap.map.end(); ++i) {
found = false; found = false;
......
...@@ -165,20 +165,29 @@ void MyGlutWin::myRedraw() ...@@ -165,20 +165,29 @@ void MyGlutWin::myRedraw()
glColor3f(1.0f,0.0f,0.0f); glColor3f(1.0f,0.0f,0.0f);
std::vector<PFP::VEC3> v = sim->getAgentsPosition();
// glLineWidth(10.0f);
// glPointSize(10.0f);
// glBegin(GL_POINTS); // glBegin(GL_POINTS);
// // for(std::vector<PFP::VEC3>::iterator it = v.begin() ; it != v.end(); ++it) { // glVertex3fv(&posToReach[0]);
// for(unsigned int i = 0.0f; i< v.size() ; ++i) { // for(Dart d = sim->envMap.map.begin() ; d != sim->envMap.map.end() ; sim->envMap.map.next(d))
// glColor3f(i%int(2.0f/3.0f*v.size())/(v.size()/3.0f),i%int(1.0f/3.0f*v.size())/(v.size()/3.0f),i/(v.size()/3.0f)); // glVertex3fv(&sim->envMap.getPosition(d)[0]);
// glVertex3fv(&(v[i])[0]); // glEnd();
// glBegin(GL_LINES);
// for(std::vector<Dart>::iterator it = sim->path.begin() ; it != sim->path.end() ; ++ it) {
// VEC3 c = Algo::Geometry::faceCentroid<PFP>(sim->envMap.map,*it,sim->envMap.position);
// glVertex3fv(&c[0]);
// } // }
// glEnd(); // glEnd();
// glPointSize(10.0f); // glBegin(GL_POINTS);
// glBegin(GL_POINTS); // for(unsigned int i = 0; i<4;++i) {
for(unsigned int i = 0.0f; i< v.size() ; ++i) { // for(std::vector<VEC3>::iterator it=(*sim->pathToFollow[0]).begin() ; it!=(*sim->pathToFollow[0]).end() ; ++it) {
// glVertex3fv(&(*it)[0]);
// }
// }
// glEnd();
unsigned int i=0;
for(std::vector<Agent * >::iterator it = sim->agents_.begin() ; it != sim->agents_.end() ; ++ it, ++i) {
// glColor3f(i%int(2.0f/3.0f*v.size())/(v.size()/3.0f),i%int(1.0f/3.0f*v.size())/(v.size()/3.0f),i/(v.size()/3.0f)); // glColor3f(i%int(2.0f/3.0f*v.size())/(v.size()/3.0f),i%int(1.0f/3.0f*v.size())/(v.size()/3.0f),i/(v.size()/3.0f));
// glCircle3i(v[i][0],v[i][1],1.5f); // glCircle3i(v[i][0],v[i][1],1.5f);
glPushMatrix(); glPushMatrix();
...@@ -205,34 +214,10 @@ void MyGlutWin::myRedraw() ...@@ -205,34 +214,10 @@ void MyGlutWin::myRedraw()
// glVertex3f(posR[0],posR[1],posR[2]); // glVertex3f(posR[0],posR[1],posR[2]);
glCircle3i(0,0,sim->agents_[i]->radius_); glCircle3i(0,0,sim->agents_[i]->radius_);
glPopMatrix(); glPopMatrix();
}
// glEnd(); // glEnd();
glColor3f(1.0f,1.0f,1.0f); glColor3f(1.0f,1.0f,1.0f);
// glBegin(GL_POINTS);
// glVertex3fv(&posToReach[0]);
// for(Dart d = sim->envMap.map.begin() ; d != sim->envMap.map.end() ; sim->envMap.map.next(d))
// glVertex3fv(&sim->envMap.getPosition(d)[0]);
// glEnd();
// glBegin(GL_LINES);
// for(std::vector<Dart>::iterator it = sim->path.begin() ; it != sim->path.end() ; ++ it) {
// VEC3 c = Algo::Geometry::faceCentroid<PFP>(sim->envMap.map,*it,sim->envMap.position);
// glVertex3fv(&c[0]);
// }
// glEnd();
// glBegin(GL_POINTS);
// for(unsigned int i = 0; i<4;++i) {
// for(std::vector<VEC3>::iterator it=(*sim->pathToFollow[0]).begin() ; it!=(*sim->pathToFollow[0]).end() ; ++it) {
// glVertex3fv(&(*it)[0]);
// }
// }
// glEnd();
unsigned int i=0;
for(std::vector<Agent * >::iterator it = sim->agents_.begin() ; it != sim->agents_.end() ; ++ it, ++i) {
// //draw all containing faces // //draw all containing faces
// glColor3f(1,1,0); // glColor3f(1,1,0);
// for(std::vector<Dart>::iterator incF = (*it)->includingFaces.begin(); incF != (*it)->includingFaces.end(); ++incF) { // for(std::vector<Dart>::iterator incF = (*it)->includingFaces.begin(); incF != (*it)->includingFaces.end(); ++incF) {
...@@ -256,7 +241,7 @@ void MyGlutWin::myRedraw() ...@@ -256,7 +241,7 @@ void MyGlutWin::myRedraw()
// //and prediction triangle // //and prediction triangle
glColor3f(((*it)->part->state)/3.0f,((*it)->part->state%2),0); glColor3f(((*it)->part->state)/3.0f,((*it)->part->state%2),0);
glLineWidth(5.0f); glLineWidth(5.0f);
renderPredictionTriangle(sim->envMap,(*it)->part->d,(*it)->part->m_position); renderPredictionTriangle(sim->envMap,(*it)->part->d,/*(*it)->part->m_position*/posR);
glLineWidth(1.0f); glLineWidth(1.0f);
//draw next goal //draw next goal
...@@ -403,8 +388,9 @@ void MyGlutWin::animate(void) ...@@ -403,8 +388,9 @@ void MyGlutWin::animate(void)
// std::cout << "pos to reach : " << posToReach << std::endl; // std::cout << "pos to reach : " << posToReach << std::endl;
// std::cout << sim->getGlobalTime() << " " << std::endl; // std::cout << sim->getGlobalTime() << " " << std::endl;
updateVisualization(sim); updateVisualization(sim);
sim->setPreferredVelocities(posToReach); // sim->setPreferredVelocities(posToReach);
// sim->setPreferredPathVelocities(); // sim->setPreferredPathVelocities();
sim->setPreferredNextCellVelocities();
sim->doStep(); sim->doStep();
// sim->envMap.simplify(); // sim->envMap.simplify();
glutPostRedisplay(); glutPostRedisplay();
......
...@@ -295,7 +295,7 @@ public: ...@@ -295,7 +295,7 @@ public:
* @param maxHeight height to reach * @param maxHeight height to reach
* @param turns number of turn * @param turns number of turn
*/ */
void embedHelicoid( float radius_min, float radius_max, float maxHeight, float nbTurn); void embedHelicoid( float radius_min, float radius_max, float maxHeight, float nbTurn, int orient=1);
/** /**
* transform the Polyhedron with transformation matrice * transform the Polyhedron with transformation matrice
......
...@@ -1017,7 +1017,7 @@ void Polyhedron<PFP>::embedTwistedStrip( float radius_min, float radius_max, fl ...@@ -1017,7 +1017,7 @@ void Polyhedron<PFP>::embedTwistedStrip( float radius_min, float radius_max, fl
} }
template <typename PFP> template <typename PFP>
void Polyhedron<PFP>::embedHelicoid( float radius_min, float radius_max, float maxHeight, float nbTurn) void Polyhedron<PFP>::embedHelicoid( float radius_min, float radius_max, float maxHeight, float nbTurn, int orient)
{ {
typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::VEC3 VEC3 ;
...@@ -1033,14 +1033,14 @@ void Polyhedron<PFP>::embedHelicoid( float radius_min, float radius_max, float ...@@ -1033,14 +1033,14 @@ void Polyhedron<PFP>::embedHelicoid( float radius_min, float radius_max, float
{ {
// float r = radius_max + radius_min*cos(beta*float(j)); // float r = radius_max + radius_min*cos(beta*float(j));
float r,x,y; float r,x,y;
if(i==1) { // if(i==1) {
r = radius_max; // r = radius_max;
} // }
else { // else {
r= radius_min; r= radius_min+(radius_max-radius_min)*float(i)/float(m_ny);
} // }
x = r*sin(alpha*float(j)); x = orient*r*sin(alpha*float(j));
y = r*cos(alpha*float(j)); y = orient*r*cos(alpha*float(j));
VEC3 pos(x, y, j*hS); VEC3 pos(x, y, j*hS);
Dart d = m_tableVertDarts[i*(m_nx+1)+j]; Dart d = m_tableVertDarts[i*(m_nx+1)+j];
......
...@@ -35,7 +35,8 @@ Orientation2D testOrientation2D(const VEC3& P, const VEC3& Pa, const VEC3& Pb) ...@@ -35,7 +35,8 @@ Orientation2D testOrientation2D(const VEC3& P, const VEC3& Pa, const VEC3& Pb)
{ {
typedef typename VEC3::DATA_TYPE T ; typedef typename VEC3::DATA_TYPE T ;
const T min = std::numeric_limits<T>::min()*T(100); // const T min = std::numeric_limits<T>::min()*T(100);
const T min = 0.00001;
T wsof = (Pa[0]-P[0])*(P[1]-Pb[1])-(P[0]-Pb[0])*(Pa[1]-P[1]); T wsof = (Pa[0]-P[0])*(P[1]-Pb[1])-(P[0]-Pb[0])*(Pa[1]-P[1]);
......
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