Commit 542cf331 authored by Arash HABIBI's avatar Arash HABIBI
Browse files

slugs

parent 9b2657d2
......@@ -203,6 +203,12 @@ inline void renderAgent(EnvMap& m, Agent* agent, bool showNeighborDist = false,
glVertex3fv(g.data()) ;
glEnd() ;
glPointSize(1.0f) ;
glBegin(GL_LINES);
VEC3 p = agent->getPosition();
glVertex3fv(p.data()) ;
glVertex3fv(g.data()) ;
glEnd();
}
if (showNeighborDist)
......
......@@ -73,6 +73,7 @@ public:
std::vector<Dart> * belonging_cells;
std::vector<Dart> * neighbor_cells;
std::set<Dart> general_belonging;
int use_ellipse;
VEC3 front;
VEC3 focus1, focus2;
double length, width, sum_dist_foci, sum_dist_foci_rest;
......
......@@ -610,24 +610,30 @@ void Agent::computeNewVelocity()
mo_count++)
{
mo = movingObstacles_[mo_count];
float dist = (getPosition()-mo->focus2).norm() + (getPosition()-mo->focus1).norm();
double effective_range = mo->sum_dist_foci;
if(dist <= effective_range)
if(mo->use_ellipse)
{
float dist = (getPosition()-mo->focus2).norm() + (getPosition()-mo->focus1).norm();
double effective_range = mo->sum_dist_foci;
if(dist <= effective_range)
{
collision_softening_factor = pow(1 - dist/effective_range,obst_power);
force_value = obst_stiffness*collision_softening_factor*(effective_range-dist);
norm.zero();
// norm = (getPosition()-mo->focus2) + (getPosition()-mo->focus1);
// norm.normalize();
VEC3 vec1 = getPosition()-mo->focus1;
vec1.normalize();
VEC3 vec2 = getPosition()-mo->focus2;
vec2.normalize();
norm = vec1 + vec2;
norm.normalize();
forces += force_value * norm;
}
}
else
{
collision_softening_factor = pow(1 - dist/effective_range,obst_power);
force_value = obst_stiffness*collision_softening_factor*(effective_range-dist);
norm.zero();
// norm = (getPosition()-mo->focus2) + (getPosition()-mo->focus1);
// norm.normalize();
VEC3 vec1 = getPosition()-mo->focus1;
vec1.normalize();
VEC3 vec2 = getPosition()-mo->focus2;
vec2.normalize();
norm = vec1 + vec2;
norm.normalize();
forces += force_value * norm;
}
}
......@@ -656,6 +662,8 @@ void Agent::computeNewVelocity()
force_value = fixed_obst_stiffness*collision_softening_factor*(effective_range-dist);
}
if(fixed_obst.mo!=NULL)
cerr << "Collision avec limace !!!" << endl;
fixed_obst=it->second ;
VEC3 p1=fixed_obst->p1 ;
VEC3 p2=fixed_obst->p2 ;
......@@ -679,7 +687,7 @@ void Agent::computeNewVelocity()
rand = 2.0*drand48()-1.0; // compris entre -1 et 1
double radius_var = 0.8;
double ag_phys_radius_coef = 8.0*(1 + rand*radius_var); // valeurs uniformement réparties entre min et max
double ag_phys_radius_coef = 4.0*(1 + rand*radius_var); // valeurs uniformement réparties entre min et max
unsigned int nbA = 0 ;
......@@ -718,6 +726,9 @@ void Agent::computeNewVelocity()
}
}
//------- calcul de la trainee --------------------------------------
//------- calcul de la trainee --------------------------------------
// forces -= ag_ambient_damping * velocity_;
......
......@@ -156,11 +156,18 @@ MovingObstacle::MovingObstacle(Simulator* sim, int ind, std::vector<VEC3> pos, s
//-------- code ajoute par Arash pour les obstacles rectangulaires --------------
length = (pos[0]-pos[1]).norm();
width = (pos[1]-pos[2]).norm();
sum_dist_foci_rest = 2*(length + width*(sqrt(2)-0.5));
// M appartient à l'ellipse ssi MF1 + MF2 = sum_dist_foci est une constante
// où F1 et F2 sont les deux foyers.
use_ellipse = 0;
if(nbVertices==4)
use_ellipse = 1;
if(use_ellipse)
{
length = (pos[0]-pos[1]).norm();
width = (pos[1]-pos[2]).norm();
sum_dist_foci_rest = 2*(length + width*(sqrt(2)-0.5));
// M appartient à l'ellipse ssi MF1 + MF2 = sum_dist_foci est une constante
// où F1 et F2 sont les deux foyers.
}
//-------- fin du code ajoute par Arash pour les obstacles rectangulaires -------
......@@ -515,22 +522,26 @@ void MovingObstacle::update()
// if(!rigid_)
// center = position[groundFace];
//-------- code ajoute par Arash pour les obstacles rectangulaires --------------
VEC3 P0_P1 = position[1] - position[0];
float velocity_coef = 10.0;
//-------- code ajoute par Arash pour les obstacles rectangulaires --------------
if(P0_P1 * velocity_ > 0) // P0_P1 est dans le sens de la vitesse
{
focus1 = center - P0_P1*(1-(width/length)*(sqrt(2)-0.5));
focus2 = center + P0_P1*(1-(width/length)*(sqrt(2)-0.5)) + (velocity_coef*velocity_);
}
else
if(use_ellipse)
{
focus1 = center - P0_P1*(1-(width/length)*(sqrt(2)-0.5)) + (velocity_coef*velocity_);
focus2 = center + P0_P1*(1-(width/length)*(sqrt(2)-0.5));
VEC3 P0_P1 = position[1] - position[0];
float velocity_coef = 10.0;
if(P0_P1 * velocity_ > 0) // P0_P1 est dans le sens de la vitesse
{
focus1 = center - P0_P1*(1-(width/length)*(sqrt(2)-0.5));
focus2 = center + P0_P1*(1-(width/length)*(sqrt(2)-0.5)) + (velocity_coef*velocity_);
}
else
{
focus1 = center - P0_P1*(1-(width/length)*(sqrt(2)-0.5)) + (velocity_coef*velocity_);
focus2 = center + P0_P1*(1-(width/length)*(sqrt(2)-0.5));
}
sum_dist_foci = sum_dist_foci_rest + velocity_coef*velocity_.norm();
}
sum_dist_foci = sum_dist_foci_rest + velocity_coef*velocity_.norm();
//-------- fin du code ajoute par Arash pour les obstacles rectangulaires -------
......
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