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

A plane with n x m grid points Vertex data is not stored on host, it is copied to GPU directly. Plane has dimensions [-0.5,-0.5] - [0.5,0.5]. More...

#include <Plane.h>

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

Public Types

typedef std::function< void(QVector2D
&, size_t, size_t)> 
texcoord_transform_functor_type
 

Public Member Functions

 Plane ()
 
 ~Plane ()
 
void draw () const
 Draw plane. More...
 
void update (texcoord_transform_functor_type _f)
 Update mesh with texcoord transformation. More...
 
void update ()
 Update mesh (without transforming texture coordinates) More...
 
size_t horizontal () const
 Return number of horizontal subdivisions. More...
 
void setHorizontal (size_t _horizontal)
 Set horizontal subdivisions (does not regenerate the mesh) More...
 
size_t vertical () const
 Return number of vertical subdivisions. More...
 
void setVertical (size_t _vertical)
 Set vertical subdivisions (does not regenerate the mesh) More...
 
void resize (size_t _horizontal, size_t _vertical)
 Set horizontal and vertical subdivisions (does not regenerate the. More...
 
- Public Member Functions inherited from omni::visual::Interface
virtual ~Interface ()
 

Private Attributes

size_t horizontal_ = 10
 
size_t vertical_ = 10
 
ContextBoundPtr< VertexVBOvbo_
 

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

A plane with n x m grid points Vertex data is not stored on host, it is copied to GPU directly. Plane has dimensions [-0.5,-0.5] - [0.5,0.5].

Member Typedef Documentation

typedef std::function<void (QVector2D&, size_t, size_t)> omni::visual::Plane::texcoord_transform_functor_type

Constructor & Destructor Documentation

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

Member Function Documentation

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

Draw plane.

Implements omni::visual::Interface.

29  {
30  if (!vbo_) return;
31  vbo_->bindAndDraw(vbo_->numIndices(), GL_QUADS);
32  }
ContextBoundPtr< VertexVBO > vbo_
Definition: Plane.h:70
size_t omni::visual::Plane::horizontal ( ) const

Return number of horizontal subdivisions.

76  {
77  return horizontal_;
78  }
size_t horizontal_
Definition: Plane.h:68
void omni::visual::Plane::resize ( size_t  _horizontal,
size_t  _vertical 
)

Set horizontal and vertical subdivisions (does not regenerate the.

98  {
99  setHorizontal(_horizontal);
100  setVertical(_vertical);
101  }
void setVertical(size_t _vertical)
Set vertical subdivisions (does not regenerate the mesh)
Definition: Plane.cpp:91
void setHorizontal(size_t _horizontal)
Set horizontal subdivisions (does not regenerate the mesh)
Definition: Plane.cpp:80
void omni::visual::Plane::setHorizontal ( size_t  _horizontal)

Set horizontal subdivisions (does not regenerate the mesh)

80  {
81  if (_horizontal < 2) _horizontal = 2;
82 
83  if (_horizontal > 0xFF) _horizontal = 0xFF;
84  horizontal_ = _horizontal;
85  }
size_t horizontal_
Definition: Plane.h:68
void omni::visual::Plane::setVertical ( size_t  _vertical)

Set vertical subdivisions (does not regenerate the mesh)

91  {
92  if (_vertical < 2) _vertical = 2;
93 
94  if (_vertical > 0xFF) _vertical = 0xFF;
95  vertical_ = _vertical;
96  }
size_t vertical_
Definition: Plane.h:69
void omni::visual::Plane::update ( texcoord_transform_functor_type  _f)

Update mesh with texcoord transformation.

34  {
35  size_t _resX = horizontal_ + 1;
36  size_t _resY = vertical_ + 1;
37  size_t _numVertices = _resX * _resY;
38  VertexVBO::vertex_buffer_type _vertices(_numVertices);
39  VertexVBO::index_buffer_type _indices(4 * _numVertices);
40 
41  auto _vertexIt = _vertices.begin();
42  auto _indexIt = _indices.begin();
43 
44  for (size_t x = 0; x < _resX; ++x) {
45  for (size_t y = 0; y < _resY; ++y) {
46  // index
47  if (((x + 1) < _resX) && ((y + 1) < _resY)) {
48  *(_indexIt++) = (x + 0) * _resY + (y + 0);
49  *(_indexIt++) = (x + 1) * _resY + (y + 0);
50  *(_indexIt++) = (x + 1) * _resY + (y + 1);
51  *(_indexIt++) = (x + 0) * _resY + (y + 1);
52  }
53 
54  // texCoords
55  QVector2D _texCoord(x / (float)(_resX - 1),
56  1.0 - y / (float)(_resY - 1));
57  _texTrans(_texCoord, x, y);
58 
59  _vertexIt->setTexCoord(_texCoord);
60  _vertexIt->setPos(QVector3D(_texCoord.x() - 0.5, _texCoord.y() - 0.5,
61  0.0));
62  _vertexIt->setNormal(QVector3D(0.0, 0.0, 1.0));
63  ++_vertexIt;
64  }
65  }
66 
67  primaryContextSwitch([&](QOpenGLFunctions& _) {
68  vbo_.reset(new VertexVBO(_vertices, _indices));
69  });
70  }
ContextBoundPtr< VertexVBO > vbo_
Definition: Plane.h:70
size_t horizontal_
Definition: Plane.h:68
size_t vertical_
Definition: Plane.h:69
std::vector< uint32_t > index_buffer_type
Index buffer type.
Definition: VertexVBO.h:36
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
void omni::visual::Plane::update ( )
virtual

Update mesh (without transforming texture coordinates)

Reimplemented from omni::visual::Interface.

72  {
73  update([](QVector2D&, size_t, size_t) {});
74  }
void update()
Update mesh (without transforming texture coordinates)
Definition: Plane.cpp:72
size_t omni::visual::Plane::vertical ( ) const

Return number of vertical subdivisions.

87  {
88  return vertical_;
89  }
size_t vertical_
Definition: Plane.h:69

Field Documentation

size_t omni::visual::Plane::horizontal_ = 10
private
ContextBoundPtr<VertexVBO> omni::visual::Plane::vbo_
private
size_t omni::visual::Plane::vertical_ = 10
private

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