Developer Documentation
Loading...
Searching...
No Matches
PointNode.hh
1/*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40\*===========================================================================*/
41
42
43
44
45
46
47//=============================================================================
48//
49// CLASS PointNode
50//
51//=============================================================================
52
53
54#ifndef ACG_POINTNODE_HH
55#define ACG_POINTNODE_HH
56
57
58//== INCLUDES =================================================================
59
60#include "BaseNode.hh"
61#include "DrawModes.hh"
62#include <ACG/GL/VertexDeclaration.hh>
63#include <vector>
64
65//== NAMESPACES ===============================================================
66
67namespace ACG {
68namespace SceneGraph {
69
70//== CLASS DEFINITION =========================================================
71
72
73
82class ACGDLLEXPORT PointNode : public BaseNode
83{
84public:
85
86 // typedefs
87 typedef std::vector<ACG::Vec3d> PointVector;
88 typedef PointVector::iterator PointIter;
89 typedef PointVector::const_iterator ConstPointIter;
90 typedef std::vector<ACG::Vec4f> ColorVector;
91 typedef ColorVector::iterator ColorIter;
92 typedef ColorVector::const_iterator ConstColorIter;
93
94
96 PointNode( BaseNode* _parent=0,
97 const std::string & _name="<PointNode>" )
98 : BaseNode(_parent, _name)
99 {}
100
103
106
108 DrawModes::DrawMode availableDrawModes() const override;
109
111 void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax) override;
112
114 void draw(GLState& _state, const DrawModes::DrawMode& _drawMode) override;
115
117 void getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawMode& _drawMode , const Material* _mat) override;
118
120 void reserve(unsigned int _np, unsigned int _nn, unsigned int _nc) {
121 points_.reserve(_np); normals_.reserve(_nn); colors_.reserve(_nc);
122 }
123
125 void add_point(const ACG::Vec3d& _p) { points_.push_back(_p); vbo_needs_update_ = true;}
127 void add_normal(const ACG::Vec3d& _n) { normals_.push_back(_n); vbo_needs_update_ = true;}
129 void add_color(const ACG::Vec4f& _c) { colors_.push_back(_c); vbo_needs_update_ = true;}
130
132 size_t n_points() const { return points_.size(); }
133
135 void clear_points() { points_.clear(); vbo_needs_update_ = true;}
137 void clear_normals() { normals_.clear(); vbo_needs_update_ = true;}
139 void clear_colors() { colors_.clear(); vbo_needs_update_ = true;}
141 void clear() { clear_points(); clear_normals(); clear_colors(); }
142
144 const PointVector& points() const { return points_; }
146 const PointVector& normals() const { return normals_; }
148 const ColorVector& colors() const { return colors_; }
149
150
151private:
152
153 void update_vbo();
154 PointVector points_, normals_;
155 ColorVector colors_;
156
157 GLuint vbo_ = 0;
158 std::vector<float> vbo_data_;
159 bool vbo_needs_update_ = true;
160
161 VertexDeclaration vertexDecl_;
162};
163
164
165//=============================================================================
166} // namespace SceneGraph
167} // namespace ACG
168//=============================================================================
169#endif // ACG_POINTNODE_HH defined
170//=============================================================================
ACG_CLASSNAME(PointNode)
static name of this class
const ColorVector & colors() const
get color container
Definition PointNode.hh:148
void add_color(const ACG::Vec4f &_c)
add color
Definition PointNode.hh:129
void clear_colors()
clear colors
Definition PointNode.hh:139
void clear_points()
clear points
Definition PointNode.hh:135
size_t n_points() const
how many points?
Definition PointNode.hh:132
PointNode(BaseNode *_parent=0, const std::string &_name="<PointNode>")
default constructor
Definition PointNode.hh:96
void clear_normals()
clear normals
Definition PointNode.hh:137
void add_point(const ACG::Vec3d &_p)
add point
Definition PointNode.hh:125
const PointVector & points() const
get point container
Definition PointNode.hh:144
const PointVector & normals() const
get normal container
Definition PointNode.hh:146
void clear()
clear points and normals and colors
Definition PointNode.hh:141
void reserve(unsigned int _np, unsigned int _nn, unsigned int _nc)
reserve mem for _np points and _nn normals
Definition PointNode.hh:120
void add_normal(const ACG::Vec3d &_n)
add normal
Definition PointNode.hh:127
Class to define the vertex input layout.
Namespace providing different geometric functions concerning angles.