surface.h 2.45 KB
Newer Older
Thomas Pitiot 's avatar
Thomas Pitiot committed
1 2 3 4 5 6
#ifndef Surface_H
#define Surface_H

#include <iostream>
#include "glm/glm.hpp"
#include "env_map.h"
Thomas Pitiot 's avatar
Thomas Pitiot committed
7 8 9

#include "utils.h"

Thomas Pitiot 's avatar
Thomas Pitiot committed
10 11 12 13
#include "Algo/Tiling/Surface/triangular.h"

#include "Algo/Render/GL2/mapRender.h"
#include "Utils/vbo.h"
14 15
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Algo/Render/GL2/colorPerFaceRender.h"
Thomas Pitiot 's avatar
Thomas Pitiot committed
16

Thomas Pitiot 's avatar
Thomas Pitiot committed
17
#include "Utils/Shaders/shaderColorPerVertex.h"
Thomas Pitiot 's avatar
Thomas Pitiot committed
18 19 20 21 22 23
//particules



using namespace CGoGN ;
class Simulator;
Thomas Pitiot 's avatar
Thomas Pitiot committed
24
class Surface
Thomas Pitiot 's avatar
Thomas Pitiot committed
25 26 27 28
{
public:
    Surface(Simulator* sim, VEC3 offset) ;

Thomas Pitiot 's avatar
Thomas Pitiot committed
29 30 31 32 33 34 35 36

    VEC3 getPosition(int index);
    unsigned int nbVertices;
    unsigned int nbTriangles;

    std::vector<PARTICULE*> parts_ ;
    std::vector<Triangle *> triangles_;

Thomas Pitiot 's avatar
Thomas Pitiot committed
37
    SURFACE surfaceMap; // map
38
    CGoGN::Algo::MR::Primal::Adaptive::IHM2<PFPSurface> mapOperator;
Thomas Pitiot 's avatar
Thomas Pitiot committed
39 40
    VertexAttribute<VEC3, SURFACE> positionSurface ; //position
    VertexAttribute<int, SURFACE> indexParticule; // index des particules de chaque sommet
Thomas Pitiot 's avatar
Thomas Pitiot committed
41 42 43 44 45 46 47
    FaceAttribute<int, SURFACE> indexTriangle;
    FaceAttribute<VEC3,SURFACE> faceColor;





Thomas Pitiot 's avatar
Thomas Pitiot committed
48
    void initPlane(); //initialisation d'une grille
49 50
    REAL faceMaxdistance(Face face); //calcul du rayon max d'une face
    bool subdiveMap(); //subdivision de la map
Thomas Pitiot 's avatar
Thomas Pitiot committed
51 52 53
    void initOperators(SubdivisionType st); // fonction de sélection du type de subdivision pour l'ihm2


Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
54 55 56 57
    void addGeneralCell ( Dart d);
    bool removeGeneralCell (Dart d);
    void addGeneralNeighbor ( Dart d);
    bool removeGeneralNeighbor (Dart d);
Thomas Pitiot 's avatar
Thomas Pitiot committed
58 59


Thomas Pitiot 's avatar
Thomas Pitiot committed
60 61
    std::vector< std::vector<Dart> > belonging_cells;
    std::vector< std::vector<Dart> > neighbor_cells;
Thomas Pitiot 's avatar
Thomas Pitiot committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

    std::vector<std::pair<Dart, int> > general_belonging;
    std::vector<std::pair<Dart, int> > general_neighbors;
    double width;
    Simulator* sim_;
    unsigned int index_surface;


    float r; // indice de couleur rouge
    float g; // indice de couleur vert
    float b; // indice de couleur bleu
    float distanceColorationMini; // distance minimale pour commencer a virer rouge
    float distanceColorationMaxi; // distance a partir de laquelle on est completement rouge



Thomas Pitiot 's avatar
Thomas Pitiot committed
78
    // visualisation
Thomas Pitiot 's avatar
Thomas Pitiot committed
79 80 81
    void initGL(); // initialisation GL
    void draw();    // redessiner l'objet
    void changeColor(Triangle *t, float distance);
Thomas Pitiot 's avatar
Thomas Pitiot committed
82
    Algo::Render::GL2::MapRender* m_render_map; // render de l'objet
83
    Algo::Render::GL2::ColorPerFaceRender * m_render;
Thomas Pitiot 's avatar
Thomas Pitiot committed
84 85
    Utils::VBO* m_positionVBO;  //VBO
    Utils::VBO* m_colorVBO;
Thomas Pitiot 's avatar
Thomas Pitiot committed
86
    Utils::ShaderSimpleColor* m_simpleColorShader;   // shader
Thomas Pitiot 's avatar
Thomas Pitiot committed
87 88
    Utils::ShaderColorPerVertex * m_shader;

Thomas Pitiot 's avatar
Thomas Pitiot committed
89 90 91 92 93 94
};




#endif