GlobeEngine
MultiPolygonObject.h
Go to the documentation of this file.
1 //
2 // Polyline.h
3 // GlobeEngine
4 //
5 // Created by Mathias Thöny on 27.12.11.
6 // Copyright (c) 2011 University of Zurich. All rights reserved.
7 //
8 
9 #ifndef GlobeEngine_MultiPolygonObject_h
10 #define GlobeEngine_MultiPolygonObject_h
11 
12 #include <vmmlib/vmmlib.hpp>
13 #include "DrawableComponent.h"
14 #include "VBOVertex.h"
15 #include "OpenGL_Includes.h"
16 #include "PolyLine.h"
17 #include "PLYObject.h"
18 #include "ColorisationTable.h"
19 #include "MultiLineObject.h"
20 
21 namespace geData {
23  {
24  public:
25  /* 0 = line,
26  1 = triangulated with overlaps,
27  2 = triangulated as nice ribbon,
28  3 = gputriangulated
29  */
30  enum GEOMETRYMODE { LINES=0,
34 
37  void clear();
38  void create();
39  void update();
40  void draw(std::shared_ptr<ge::Camera> _cam);
41  void drawWithStandardShader(std::shared_ptr<ge::Camera> _cam);
42  void drawTextured(std::shared_ptr<ge::Camera> _cam, std::vector< GLuint > _texHandles);
43 
47  int addPolygon(std::shared_ptr<PolyLine> _polyline);
48 
52  void updatePolygon(int _id, std::shared_ptr<PolyLine> _polyline);
53 
57  void removePolygon(int _id);
58 
62  void insertPolygon(int _id, std::shared_ptr<PolyLine> _polyline);
63  const std::shared_ptr<PolyLine> getPolygon(int _idx) const;
64 
68  void createVAO(enum GEOMETRYMODE _mode=LINES);
69 
70  void setPolygonWeight(int _lineIdx, double _wheight);
71  void setPolygonWeightAndColor(int _idx, double _wheight, vmml::Vector3f _color);
72  void addToPolygonWeight(int _idx, double _value);
73  double getPolygonWeight(int _idx);
74  vmml::Vector3f getPolygonWeightColor(int _idx);
75 
76  int getPolygonCount();
77  void setWheightedColorBuffer(int _bufferID);
78 
79  enum GEOMETRYMODE getDrawMode() const{ return this->geometryDrawmode; };
80 
81  void setExtrusionY(double _input);
82 
83  void loadTriangulatedMesh(std::string _nameurl);
84  void loadPolygonsFromPLY(std::string _nameurl);
85  void savePolygonsToPLY(std::string _path);
86  void copyColorInformationToGPU(vmml::Vector3d _pickcolor = vmml::Vector3d(0.0, 0.0, 0.0), int _picked = -1, const std::shared_ptr<geData::ColorisationTable>& _colorTable = NULL);
87 
88  // geometry setup
89  void setGeometryBuffer(int _bufferID);
90  void setTextureCoordBuffer(int _bufferID);
91  //void setGeometryBufferAsRibbons(int _bufferID);
92  void setColorBuffer(int _bufferID, const vmml::Vector3f* _color=NULL);
93  void updateColorBuffer(vmml::Vector3f _color);
94  void setPickIDBuffer(int _bufferID);
95 
96  void setPolygonIndices();
97  void clearGeometryMemory();
98  void createTriangleIndices();
99 
100  void createTriangulation(std::shared_ptr<geData::MultiLineObject> _multilineGeometry, std::vector<int> _entityAssociation);
101  //void copyTriangleInformationToGPU();
102 
103  bool isTriangulated() {
104  return this->triangulated;
105  }
106 
107  private:
108  std::vector< std::shared_ptr<PolyLine> > entities;
109  std::vector<double> weights;
110  std::vector<vmml::Vector3f> weightColors;
111 
112  GEOMETRYMODE geometryDrawmode;
113 
114  // number of lines
115  int polygonCount;
116  int polygonLineSum;
117  int triangleCount;
118  // Rendering structures
119  GLsizei* lineStripLenght;
120 
121  float extrusionY;
122 
123  bool triangulated;
124 
125  int colorBuffer;
126 
127  // Triangulated information
128  std::vector< vmml::Vector3d > points;
129  std::vector< vmml::Vector2d > minboundPerPolygon;
130  std::vector< vmml::Vector2d > maxboundPerPolygon;
131  std::vector<int> polygonStartIdx;
132  std::vector<int> polygonIndexCount;
133  std::vector<int> polygonEntityAssociation;
134  };
135 
136 }
137 #endif
void setWheightedColorBuffer(int _bufferID)
Definition: MultiPolygonObject.cpp:368
Definition: DrawableComponent.h:25
void drawTextured(std::shared_ptr< ge::Camera > _cam, std::vector< GLuint > _texHandles)
Definition: MultiPolygonObject.cpp:143
void draw(std::shared_ptr< ge::Camera > _cam)
Definition: MultiPolygonObject.cpp:127
Definition: MultiPolygonObject.h:33
enum GEOMETRYMODE getDrawMode() const
Definition: MultiPolygonObject.h:79
const std::shared_ptr< PolyLine > getPolygon(int _idx) const
Definition: MultiPolygonObject.cpp:514
void addToPolygonWeight(int _idx, double _value)
Definition: MultiPolygonObject.cpp:503
void updatePolygon(int _id, std::shared_ptr< PolyLine > _polyline)
Definition: MultiPolygonObject.cpp:450
void clear()
Definition: MultiPolygonObject.cpp:19
Definition: AvalancheTrainingSimulationEngine.h:39
void clearGeometryMemory()
Definition: MultiPolygonObject.cpp:33
void loadPolygonsFromPLY(std::string _nameurl)
Definition: MultiPolygonObject.cpp:526
Definition: MultiPolygonObject.h:33
Definition: MultiPolygonObject.h:22
void drawWithStandardShader(std::shared_ptr< ge::Camera > _cam)
Definition: MultiPolygonObject.h:30
int addPolygon(std::shared_ptr< PolyLine > _polyline)
Definition: MultiPolygonObject.cpp:411
void copyColorInformationToGPU(vmml::Vector3d _pickcolor=vmml::Vector3d(0.0, 0.0, 0.0), int _picked=-1, const std::shared_ptr< geData::ColorisationTable > &_colorTable=NULL)
Definition: MultiPolygonObject.cpp:239
void removePolygon(int _id)
Definition: MultiPolygonObject.cpp:434
void setPolygonWeightAndColor(int _idx, double _wheight, vmml::Vector3f _color)
Definition: MultiPolygonObject.cpp:467
void createTriangleIndices()
Definition: MultiPolygonObject.cpp:347
void setExtrusionY(double _input)
Definition: MultiPolygonObject.cpp:571
bool isTriangulated()
Definition: MultiPolygonObject.h:103
double getPolygonWeight(int _idx)
Definition: MultiPolygonObject.cpp:479
vmml::Vector3f getPolygonWeightColor(int _idx)
Definition: MultiPolygonObject.cpp:491
void setTextureCoordBuffer(int _bufferID)
Definition: MultiPolygonObject.cpp:329
void setPolygonWeight(int _lineIdx, double _wheight)
Definition: MultiPolygonObject.cpp:456
void setPickIDBuffer(int _bufferID)
Definition: MultiPolygonObject.cpp:387
void updateColorBuffer(vmml::Vector3f _color)
Definition: MultiPolygonObject.cpp:210
Definition: MultiPolygonObject.h:31
~MultiPolygonObject()
Definition: MultiPolygonObject.cpp:14
void insertPolygon(int _id, std::shared_ptr< PolyLine > _polyline)
Definition: MultiPolygonObject.cpp:417
void update()
Definition: MultiPolygonObject.cpp:46
Definition: MultiPolygonObject.h:32
int getPolygonCount()
Definition: MultiPolygonObject.cpp:519
void savePolygonsToPLY(std::string _path)
Definition: MultiPolygonObject.cpp:551
MultiPolygonObject()
Definition: MultiPolygonObject.cpp:8
void setGeometryBuffer(int _bufferID)
Definition: MultiPolygonObject.cpp:305
void loadTriangulatedMesh(std::string _nameurl)
void setColorBuffer(int _bufferID, const vmml::Vector3f *_color=NULL)
Definition: MultiPolygonObject.cpp:214
void create()
Definition: MultiPolygonObject.cpp:41
void createVAO(enum GEOMETRYMODE _mode=LINES)
Definition: MultiPolygonObject.cpp:180
GEOMETRYMODE
Definition: MultiPolygonObject.h:30
void createTriangulation(std::shared_ptr< geData::MultiLineObject > _multilineGeometry, std::vector< int > _entityAssociation)
Definition: MultiPolygonObject.cpp:51