Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes
omni::visual::Box Class Reference

Box with subdivisions for drawing. More...

#include <Box.h>

Inheritance diagram for omni::visual::Box:
Inheritance graph
[legend]
Collaboration diagram for omni::visual::Box:
Collaboration graph
[legend]

Public Member Functions

 Box ()
 
 ~Box ()
 
void draw () const
 Draw box. More...
 
void update ()
 Update box mesh. More...
 
- Public Member Functions inherited from omni::visual::Interface
virtual ~Interface ()
 

Private Attributes

size_t horizontal_ = 4
 
size_t vertical_ = 4
 
VertexVBO vbo_
 

Additional Inherited Members

- Static Protected Member Functions inherited from omni::visual::Interface
static void vertex3 (QVector3D const &)
 glVertex3f from QVector3D More...
 
static void visualLine (QVector3D const &_from, QVector3D const &_to)
 Draws a line. More...
 
static void color (QColor _color, float _alpha=1.0)
 glColor4f from QColor More...
 

Detailed Description

Box with subdivisions for drawing.

Constructor & Destructor Documentation

omni::visual::Box::Box ( )
25 {}
omni::visual::Box::~Box ( )
27 {}

Member Function Documentation

void omni::visual::Box::draw ( ) const
virtual

Draw box.

Implements omni::visual::Interface.

29  {
30  vbo_.bindAndDraw(vbo_.numIndices(), GL_QUADS);
31  }
VertexVBO vbo_
Definition: Box.h:43
void bindAndDraw(ARGS &&..._args) const
Definition: VertexVBO.h:63
size_t numIndices() const
Return number of indices in this buffer.
Definition: VertexVBO.cpp:102
void omni::visual::Box::update ( )
virtual

Update box mesh.

Reimplemented from omni::visual::Interface.

33  {
34  size_t _resX = horizontal_ + 1;
35  size_t _resY = vertical_ + 1;
36  size_t _numVertices = _resX * _resY;
37  VertexVBO::vertex_buffer_type _vertices(6 * _numVertices);
38  VertexVBO::index_buffer_type _indices(6 * 4 * _numVertices);
39 
40  auto _vertexIt = _vertices.begin();
41  auto _indexIt = _indices.begin();
42 
43  std::array<QVector3D, 6> _normals = {
44  QVector3D(0.0, 1.0, 0.0),
45  QVector3D(0.0, -1.0, 0.0),
46  QVector3D(1.0, 0.0, 0.0),
47  QVector3D(-1.0, 0.0, 0.0),
48  QVector3D(0.0, 0.0, 1.0),
49  QVector3D(0.0, 0.0, -1.0)
50  };
51 
52  for (size_t i = 0; i < 6; ++i) {
53  auto& _normal = _normals[i];
54 
55  for (size_t x = 0; x < _resX; ++x) {
56  for (size_t y = 0; y < _resY; ++y) {
57  // index
58  if (((x + 1) < _resX) && ((y + 1) < _resY)) {
59  *(_indexIt++) = i * _numVertices + (x + 0) * _resY + (y + 1);
60  *(_indexIt++) = i * _numVertices + (x + 1) * _resY + (y + 1);
61  *(_indexIt++) = i * _numVertices + (x + 1) * _resY + (y + 0);
62  *(_indexIt++) = i * _numVertices + (x + 0) * _resY + (y + 0);
63  }
64 
65  // texCoords
66  QVector2D _pos(x / float(_resX - 1), y / float(_resY - 1));
67  QVector2D _texCoord((i + 1.0 - _pos.x()) / 6.0, _pos.y());
68  _pos -= QVector2D(0.5, 0.5);
69 
70  switch (i)
71  {
72  case 0:
73  _vertexIt->setPos(QVector3D(_pos.x(), _normal.y() * 0.5, _pos.y()));
74  break;
75 
76  case 1:
77  _vertexIt->setPos(QVector3D(-_pos.x(), _normal.y() * 0.5,
78  _pos.y()));
79  break;
80 
81  case 2:
82  _vertexIt->setPos(QVector3D(_normal.x() * 0.5, -_pos.x(),
83  _pos.y()));
84  break;
85 
86  case 3:
87  _vertexIt->setPos(QVector3D(_normal.x() * 0.5, _pos.x(), _pos.y()));
88  break;
89 
90  case 4:
91  _vertexIt->setPos(QVector3D(-_pos.x(), _pos.y(),
92  _normal.z() * 0.5));
93  break;
94 
95  case 5:
96  _vertexIt->setPos(QVector3D(-_pos.x(), -_pos.y(),
97  _normal.z() * 0.5));
98  break;
99  }
100 
101  _vertexIt->setTexCoord(_texCoord);
102 
103  _vertexIt->setNormal(_normals[i]);
104  ++_vertexIt;
105  }
106  }
107  }
108 
109  primaryContextSwitch([&](QOpenGLFunctions& _) {
110  vbo_.buffer(_vertices, _indices);
111 
112  });
113  }
VertexVBO vbo_
Definition: Box.h:43
std::vector< uint32_t > index_buffer_type
Index buffer type.
Definition: VertexVBO.h:36
size_t horizontal_
Definition: Box.h:41
void primaryContextSwitch(ContextFunctor f)
Switch to primary context to create OpenGL objects like textures etc.
Definition: ContextSwitch.cpp:40
std::vector< Vertex > vertex_buffer_type
Vertex buffer type.
Definition: VertexVBO.h:33
size_t vertical_
Definition: Box.h:42
void buffer(vertex_buffer_type const &_vertices, index_buffer_type const &_indices)
Copy buffers to GPU.
Definition: VertexVBO.cpp:33

Field Documentation

size_t omni::visual::Box::horizontal_ = 4
private
VertexVBO omni::visual::Box::vbo_
private
size_t omni::visual::Box::vertical_ = 4
private

The documentation for this class was generated from the following files: