agent.h 1.9 KB
Newer Older
Thomas Pitiot 's avatar
Thomas Pitiot committed
1 2 3
#ifndef Agent_H
#define Agent_H

Thomas Pitiot 's avatar
Thomas Pitiot committed
4 5
#include "Algo/MovingObjects/MovingObject.h"
#include "Algo/MovingObjects/ParticleAgent.h"
Thomas Pitiot 's avatar
Thomas Pitiot committed
6 7 8
//particules


Thomas Pitiot 's avatar
Thomas Pitiot committed
9 10 11
typedef CGoGN::Algo::Volume::MovingObjects::MovingObject MovingObject;
typedef CGoGN::Algo::Volume::MovingObjects::ParticleAgent ParticleAgent;
typedef CGoGN::Algo::Volume::MovingObjects::mapOperators mapOperators;
Thomas Pitiot 's avatar
Thomas Pitiot committed
12 13

using namespace CGoGN ;
Thomas Pitiot 's avatar
Thomas Pitiot committed
14
class Agent : public ParticleAgent, public MovingObject
Thomas Pitiot 's avatar
Thomas Pitiot committed
15 16
{
public:
Thomas Pitiot 's avatar
Thomas Pitiot committed
17 18
    Agent(mapOperators * operators, int numAgent, VEC3 startingPoint, std::vector<VEC3> goals, float timeStep_);
    void init(mapOperators * operators , int numAgent, VEC3 startingPoint,std::vector<VEC3> goals, float timeStep_);
19
    VEC3 getPosition();
Thomas Pitiot 's avatar
Thomas Pitiot committed
20
    void updatePosition( );
Thomas Pitiot 's avatar
Thomas Pitiot committed
21
    void updateNeighbors() ;
Thomas Pitiot 's avatar
Thomas Pitiot committed
22
    void computeNewVelocity( );
Thomas Pitiot 's avatar
Thomas Pitiot committed
23 24

    static float radius; // taille de l'agent
25
    static float averageVelocity; // vitesse moyenne d'un agent
Thomas Pitiot 's avatar
Thomas Pitiot committed
26 27 28 29 30
    // objectif(s)
    unsigned int curGoal_ ;
    std::vector<VEC3> goals_ ;

    //vitesses
Thomas Pitiot 's avatar
Thomas Pitiot committed
31

32 33 34 35
    VEC3 forces;
    double ag_stiffness;    // agent-agent interaction stiffness
    double ag_damping  ;     // agent-agent interaction damping
    double ag_mass ;
Thomas Pitiot 's avatar
Thomas Pitiot committed
36
    float maxVelocity_;
Thomas Pitiot 's avatar
Thomas Pitiot committed
37 38


Thomas Pitiot 's avatar
Thomas Pitiot committed
39 40 41 42 43 44
    void move(VEC3 diff);
    void updateRegistration();
    void color_close();
    void unColor_close(Dart oldCell);


Thomas Pitiot 's avatar
Thomas Pitiot committed
45
    //voisins retenus pour l'évitement
Thomas Pitiot 's avatar
Thomas Pitiot committed
46 47 48
    std::vector<std::pair<float, ParticleAgent*> > agentNeighbors_ ;
//    std::vector<std::pair<float, Segment*> > segmentNeighbors_ ;
//    std::vector<std::pair<float, Triangle*> > triangleNeighbors_;
Thomas Pitiot 's avatar
Thomas Pitiot committed
49

50 51
    //avec les distances de détection
    float neighborAgDistSq_;
Thomas Pitiot 's avatar
Thomas Pitiot committed
52 53
//    float neighborSegDistSq_;
//    float neighborTriDistSq_;
54 55

    //calcul des répulsions
56
    void goalAttraction();
Thomas Pitiot 's avatar
Thomas Pitiot committed
57 58 59
    void avoidanceAgents( );
//    void avoidanceSegments();
//    void avoidanceTriangles();
60 61 62

    // nb de voisins considérés par l'évitement
//    int maxNeighbors_ ;
Thomas Pitiot 's avatar
Thomas Pitiot committed
63 64

    float timeStep_;
Thomas Pitiot 's avatar
Thomas Pitiot committed
65 66 67 68 69 70
};




#endif