ProjectedTextures
Prototype software for spacial augmented reality applications.
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
Geometry.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <assimp/Importer.hpp>
4 #include <assimp/scene.h>
5 #include <assimp/postprocess.h>
6 #include <assimp/mesh.h>
7 
8 #include <QVector>
9 #include <QVector2D>
10 #include <QVector3D>
11 #include <QMatrix4x4>
12 #include <QOpenGLFunctions>
13 #include <QThread>
14 
15 #include "Trackable.h"
16 
17 
23  public QThread
24 {
25 public:
26  SceneDestroyer(Assimp::Importer* importer) : importer(importer){}
28 
29 protected:
30  Assimp::Importer* importer;
31  void run(){
32  importer->FreeScene();
33  }
34 };
35 
36 
40 struct ColorSetInfo{
41  QString name;
42  QMap<QString, QString> legend;
43 };
44 
45 
49 class Geometry :
50  public Trackable
51 {
52 
53  Q_OBJECT
54 
55 public:
62  Geometry(QString name, QString filename, QVector<ColorSetInfo> colorSetInfos, bool renderOnProjector=true);
63  ~Geometry(void);
64 
65  //setters
71 
72  //getters
73  QString getName(){return name;}
74  QString getFilename(bool wholePath);
76  bool isValid(){return valid;}
82  QMatrix4x4 getModelMatrix();
87  QVector<QVector4D>* getPositions(){return &positions;}
88  QVector<QVector3D>* getNormals(){return &normals;}
89  QVector<QVector2D>* getUvs(){return &uvs;}
90  QVector<GLuint>* getIndices(){return &indices;}
91  QVector<QVector4D>* getVertexColors(int layer);
93  QVector<ColorSetInfo>* getColorSetInfos(){return &colorSetInfos;}
95  bool hasNormals(){return !normals.isEmpty();}
96  bool hasUvs(){return !uvs.isEmpty();}
97  bool hasVertexColors(){return !vertexColors.isEmpty();}
99  int numVertices(){return positions.size();}
100  int numIndices(){return indices.size();}
101  int numColorSets(){return vertexColors.size();}
105 protected:
106  QString name;
107  QString filename;
109  Assimp::Importer importer;
112  bool valid;
114  QVector<QVector4D> positions;
115  QVector<QVector3D> normals;
116  QVector<QVector2D> uvs;
117  QVector<GLuint> indices;
118  QVector<QVector<QVector4D>> vertexColors;
119  QVector<ColorSetInfo> colorSetInfos;
126  void freeAssimpScene(){importer.FreeScene();}
131 public slots:
132  void scale(float factor);
133  void setScale(float absScale);
134  void setTranslation(float x, float y, float z);
135  void setRotation(QQuaternion rotation);
136  void setRotation(float x, float y, float z);
137  void setActiveColorSet(int layer);
138 };