Commit c240a2b6 authored by Thomas Jund's avatar Thomas Jund
Browse files

Merge cgogn:~habibi/CGoGN_Apps/SocialAgents2

parents 0323caf1 a738b569
......@@ -183,7 +183,7 @@ inline void renderAgent(EnvMap& m, Agent* agent, bool showNeighborDist = false,
for (std::vector<VEC3>::iterator it = (agent->goals_.begin()) ; it != agent->goals_.end() ;
++it)
{
glVertex3f((*it)[0], (*it)[1], (*it)[2]) ;
glVertex3f((*it)[0], (*it)[1], agent->agentNo) ;
}
glVertex3f((*(agent->goals_.begin()))[0], (*(agent->goals_.begin()))[1], (*(agent->goals_.begin()))[2]) ;
......
......@@ -13,7 +13,8 @@ unsigned int Agent::maxNeighbors_ = 10 ;
unsigned int Agent::maxMovingObstacles_ = 10;
float Agent::averageMaxSpeed_ = 2.0f ;
// float Agent::averageMaxSpeed_ = 20.0f ;
float Agent::neighborDist_ = 10.0f ;
// float Agent::neighborDist_ = 10.0f ;
float Agent::neighborDist_ = 20.0f ;
float Agent::neighborDistSq_ = neighborDist_ * neighborDist_ ;
float Agent::radius_ = 1.5f ;
//float Agent::timeHorizon_ = 10.0f ;
......@@ -543,12 +544,20 @@ void Agent::computeNewVelocity()
float ag_ambient_damping = 1.0;
double mass_var = 0.95;
double average_mass = 1.0;
// double average_radius = 20.f;
// double radius_var = 0.9;
// range_ = 2*timeHorizonObst_ * averageMaxSpeed_ + radius_ ;
// rangeSq_ = range_ * range_ ;
srand48(agentNo);
double rand = 2.0*drand48()-1.0; // compris entre -1 et 1
// double ag_mass = average_mass + rand*rand*rand*mass_var; // valeurs plus denses autour de la moyenne
double ag_mass = average_mass + rand*mass_var; // valeurs uniformement réparties entre min et max
double ag_mass = average_mass*(1 + rand*mass_var); // valeurs uniformement réparties entre min et max
/*
rand = 2.0*drand48()-1.0; // compris entre -1 et 1
radius_ = average_radius + rand*radius_var; // valeurs uniformement réparties entre min et max
range_ = 2*timeHorizonObst_ * averageMaxSpeed_ + radius_ ;
rangeSq_ = range_ * range_ ;
*/
//-------------
VEC3 vec, forces, previous_pos;
......@@ -563,8 +572,12 @@ void Agent::computeNewVelocity()
VEC3 u_goal = p_goal - getPosition();
u_goal.normalize();
// cerr << agentNo << "---------------- position = " << getPosition() << endl;
forces += goal_attraction_force * u_goal;
// cerr << "goal forces = " << forces << endl;
//----- forces dues à la répulsion des obstacles en mouvement ----------
VEC3 norm;
......@@ -592,7 +605,6 @@ void Agent::computeNewVelocity()
{
mo = movingObstacles_[mo_count];
float dist = (getPosition()-mo->focus2).norm() + (getPosition()-mo->focus1).norm();
// double effective_range = 3*mo->sum_dist_foci;
double effective_range = mo->sum_dist_foci;
if(dist <= effective_range)
{
......@@ -648,8 +660,7 @@ void Agent::computeNewVelocity()
norm[0]=vec[1] ;
norm[1]=-vec[0] ;
forces += force_value * norm;
// cerr << "force_value = " << force_value << endl;
// cerr << "norm=" << norm << endl;
// cerr << "obstacles fixes : nobst=" << nobst << " dist=" << dist << " force=" << force_value*norm << endl;
nobst++;
}
......@@ -658,9 +669,12 @@ void Agent::computeNewVelocity()
double ag_stiffness = 200.0; // agent-agent interaction stiffness
double ag_damping = 1.0; // agent-agent interaction damping
double ag_phys_radius_coef = 20.0;
double ag_power = 1; // the power to which elevate the agent-agent distance
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
unsigned int nbA = 0 ;
for (std::vector<std::pair<float, Agent*> >::iterator it = agentNeighbors_.begin() ;
......@@ -692,13 +706,15 @@ void Agent::computeNewVelocity()
float force_value = - ag_stiffness*collision_softening_factor*(combinedRadius-dist)
- ag_damping * (dist - previous_dist) / sim_->timeStep_;
// cerr << "autres agents : force_value = " << force_value << endl;
forces += force_value * u_other;
}
}
//------- calcul de la trainee --------------------------------------
forces -= ag_ambient_damping * velocity_;
// forces -= ag_ambient_damping * velocity_;
//------- calcul de la nouvelle valeur de la vitesse ----------------
......
......@@ -432,6 +432,16 @@ void MovingObstacle::update()
float stretch = rigidity*(edgeLength[dd]-v1.norm());
VEC3 f = stretch*(v1/norm)*sim_->timeStep_;
/*------------------------ ajoute par Arash (???)
target += (velocity_ * sim_->timeStep_);
vertices[i]=target;
bary += target;
}
front=(vertices[1] + vertices[2]) / 2;
if(angle >0)
*/
/*------------------------ ajoute par thomas J ------*/
//apply force symmetrically
velocity[dd] -= f;
velocity[map.phi1(dd)] += f;
......@@ -449,6 +459,7 @@ void MovingObstacle::update()
//apply force to each vertex
d = groundFace;
for (unsigned int i = 0; i < nbVertices; ++i)
/*--------------- fin de l'ajout de Thomas --------------*/
{
position[d] += (velocity[d] * sim_->timeStep_);
position[map.phi<211>(d)] += (velocity[d] * sim_->timeStep_);
......
......@@ -693,7 +693,7 @@ void SocialAgents::animate()
timer->stop() ;
exit(0) ;
}
simulator.doStep() ;
simulator.doStep() ;
// gettimeofday(&endTime, NULL) ;
// seconds = endTime.tv_sec - startTime.tv_sec ;
......
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