added main menu added debug display many debug widgets for plotting live data worked on android live sensors added offline-data sensor feeding some dummy data sensors worked on the map display added ui debug for grid-points, particles and weights added a cool dude to display the estimation added real filtering based on the Indoor components c++11 fixes for android compilation online and offline filtering support new resampling technique for testing map loading via dialog
112 lines
2.2 KiB
C++
112 lines
2.2 KiB
C++
#ifndef GLPOINTS_H
|
|
#define GLPOINTS_H
|
|
|
|
|
|
#include <QOpenGLFunctions>
|
|
#include "GL.h"
|
|
#include "GLHelper.h"
|
|
|
|
#include <Indoor/geo/Point3.h>
|
|
|
|
class GLPoints : protected QOpenGLFunctions {
|
|
|
|
private:
|
|
|
|
QOpenGLBuffer arrayBuf;
|
|
QOpenGLBuffer indexBuf;
|
|
|
|
std::vector<VertColor> vertices;
|
|
std::vector<GLuint> indices;
|
|
|
|
int mode = GL_POINTS;
|
|
bool initOnce = true;
|
|
|
|
public:
|
|
|
|
/** ctor */
|
|
GLPoints() : arrayBuf(QOpenGLBuffer::VertexBuffer), indexBuf(QOpenGLBuffer::IndexBuffer) {
|
|
alloc();
|
|
}
|
|
|
|
/** dtor */
|
|
~GLPoints() {
|
|
destroy();
|
|
}
|
|
|
|
/** add a new face to this element */
|
|
void addPoint(const QVector3D& pt, const QColor& color) {
|
|
indices.push_back(vertices.size());
|
|
QVector3D c(color.redF(), color.greenF(), color.blueF());
|
|
vertices.push_back(VertColor(pt, c));
|
|
}
|
|
|
|
|
|
void alloc() {
|
|
if (!indexBuf.isCreated()) {indexBuf.create();}
|
|
if (!arrayBuf.isCreated()) {arrayBuf.create();}
|
|
}
|
|
|
|
void destroy() {
|
|
if (indexBuf.isCreated()) {indexBuf.destroy();}
|
|
if (arrayBuf.isCreated()) {arrayBuf.destroy();}
|
|
}
|
|
|
|
/** build the underlying buffers */
|
|
void build() {
|
|
|
|
// Transfer vertex data to VBO 0
|
|
arrayBuf.bind();
|
|
arrayBuf.allocate(vertices.data(), vertices.size() * sizeof(vertices[0]));
|
|
|
|
// Transfer index data to VBO 1
|
|
indexBuf.bind();
|
|
indexBuf.allocate(indices.data(), indices.size() * sizeof(indices[0]));
|
|
|
|
}
|
|
|
|
void initGL() {
|
|
initializeOpenGLFunctions();
|
|
}
|
|
|
|
void rebuild() {
|
|
build();
|
|
}
|
|
|
|
void clear() {
|
|
indices.clear();
|
|
vertices.clear();
|
|
}
|
|
|
|
void setMode(const int mode) {
|
|
this->mode = mode;
|
|
}
|
|
|
|
/** render the element */
|
|
void render(QOpenGLShaderProgram *program) {
|
|
|
|
if (indices.empty()) {return;}
|
|
|
|
// Tell OpenGL which VBOs to use
|
|
arrayBuf.bind();
|
|
indexBuf.bind();
|
|
|
|
// vertices
|
|
int vertLoc = program->attributeLocation("a_position");
|
|
program->enableAttributeArray(vertLoc);
|
|
program->setAttributeBuffer(vertLoc, GL_FLOAT, vertices[0].getVertOffset(), 3, sizeof(vertices[0]));
|
|
|
|
// colors
|
|
int colorLoc = program->attributeLocation("a_color");
|
|
program->enableAttributeArray(colorLoc);
|
|
program->setAttributeBuffer(colorLoc, GL_FLOAT, vertices[0].getColorOffset(), 3, sizeof(vertices[0]));
|
|
|
|
// Draw cube geometry using indices from VBO 1
|
|
glDrawElements(mode, indices.size(), GL_UNSIGNED_INT, 0);
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
#endif // GLPOINTS_H
|