Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SplatCloudNode.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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50 //================================================================
51 //
52 // CLASS SplatCloudNode
53 //
54 // SplatCloudNode renders splats by passing positions, normals, pointsizes and colors (and picking colors) to the GL.
55 // These elements are internally stored in an array using an OpenGL vertex-buffer-object
56 // including vertices, normals, texcoords and colors.
57 //
58 //================================================================
59
60
61 #ifndef ACG_SPLATCLOUDNODE_HH
62 #define ACG_SPLATCLOUDNODE_HH
63
64
65 //== INCLUDES ====================================================
66
67
68 #include "SplatCloud/SplatCloud.hh"
69
70 #include <OpenFlipper/common/GlobalDefines.hh>
71
72 #include <ACG/Scenegraph/BaseNode.hh>
73
74 #include <ACG/Scenegraph/DrawModes.hh>
75
76 #include <ACG/GL/gl.hh>
77
78
79 //== NAMESPACES ==================================================
80
81
82 namespace ACG {
83 namespace SceneGraph {
84
85
86 //== CLASS DEFINITION ============================================
87
88
94 class DLLEXPORT SplatCloudNode : public BaseNode
95 {
96 public:
97
98 //-- TYPEDEFS ----------------------------------------------------
99
100 typedef SplatCloud::Position Position;
101 typedef SplatCloud::Color Color;
102 typedef SplatCloud::Normal Normal;
103 typedef SplatCloud::Pointsize Pointsize;
104 typedef SplatCloud::Index Index;
105 typedef SplatCloud::Viewlist Viewlist;
106 typedef SplatCloud::Selection Selection;
107
108 //----------------------------------------------------------------
109
110 public:
111
113 SplatCloudNode( const SplatCloud &_splatCloud, BaseNode *_parent = 0, std::string _name = "<SplatCloudNode>" );
114
116 ~SplatCloudNode();
117
118 ACG_CLASSNAME( SplatCloudNode );
119
121 inline DrawModes::DrawMode availableDrawModes() const { return splatsDrawMode_ | dotsDrawMode_ | pointsDrawMode_; }
122
124 void boundingBox( ACG::Vec3d &_bbMin, ACG::Vec3d &_bbMax );
125
127 void draw( GLState &_state, const DrawModes::DrawMode &_drawMode );
128
130 void pick( GLState &_state, PickTarget _target );
131
132 // TODO: hack, because pick() doesn't get a drawmode
133 inline void enterPick( GLState &_state, PickTarget _target, const DrawModes::DrawMode &_drawMode ) { pickDrawMode_ = _drawMode; }
134
135 // ---- splat cloud ----
136
137 inline const SplatCloud &splatCloud() const { return splatCloud_; }
138
139 // ---- modification tags ----
140
141 inline void modifiedPositions() { positionsModified_ = true; }
142 inline void modifiedColors() { colorsModified_ = true; }
143 inline void modifiedNormals() { normalsModified_ = true; }
144 inline void modifiedPointsizes() { pointsizesModified_ = true; }
145 inline void modifiedSelections() { selectionsModified_ = true; }
146 inline void modifiedPickColors() { pickColorsModified_ = true; }
147
148 inline void modifiedAll()
149 {
150 modifiedPositions();
151 modifiedColors();
152 modifiedNormals();
153 modifiedPointsizes();
154 modifiedSelections();
155 modifiedPickColors();
156 }
157
158 // ---- default values ----
159
160 inline void setDefaultColor ( const Color &_color ) { defaultColor_ = _color; }
161 inline void setDefaultNormal ( const Normal &_normal ) { defaultNormal_ = _normal; }
162 inline void setDefaultPointsize( const Pointsize &_pointsize ) { defaultPointsize_ = _pointsize; }
163
164 inline const Color &defaultColor() const { return defaultColor_; }
165 inline const Normal &defaultNormal() const { return defaultNormal_; }
166 inline const Pointsize &defaultPointsize() const { return defaultPointsize_; }
167
169 inline const Position &getPosition ( int _idx ) const { return splatCloud_.hasPositions() ? splatCloud_.positions ( _idx ) : DEFAULT_POSITION; }
170 inline const Color &getColor ( int _idx ) const { return splatCloud_.hasColors() ? splatCloud_.colors ( _idx ) : defaultColor_; }
171 inline const Normal &getNormal ( int _idx ) const { return splatCloud_.hasNormals() ? splatCloud_.normals ( _idx ) : defaultNormal_; }
172 inline const Pointsize &getPointsize( int _idx ) const { return splatCloud_.hasPointsizes() ? splatCloud_.pointsizes( _idx ) : defaultPointsize_; }
173 inline const Index &getIndex ( int _idx ) const { return splatCloud_.hasIndices() ? splatCloud_.indices ( _idx ) : DEFAULT_INDEX; }
174 inline const Viewlist &getViewlist ( int _idx ) const { return splatCloud_.hasViewlists() ? splatCloud_.viewlists ( _idx ) : DEFAULT_VIEWLIST; }
175 inline const Selection &getSelection( int _idx ) const { return splatCloud_.hasSelections() ? splatCloud_.selections( _idx ) : DEFAULT_SELECTION; }
176
177 //----------------------------------------------------------------
178
179 private:
180
181 // ---- splat cloud ----
182
184 const SplatCloud &splatCloud_;
185
186 // ---- modification tags ----
187
189 bool positionsModified_;
190 bool colorsModified_;
191 bool normalsModified_;
192 bool pointsizesModified_;
193 bool selectionsModified_;
194 bool pickColorsModified_;
195
197 inline bool vboModified() const
198 {
199 return positionsModified_ ||
200 colorsModified_ ||
201 normalsModified_ ||
202 pointsizesModified_ ||
203 selectionsModified_ ||
204 pickColorsModified_;
205 }
206
207 // ---- default values ----
208
210 Color defaultColor_;
211 Normal defaultNormal_;
212 Pointsize defaultPointsize_;
213
214 // ---- draw modes ----
215
216 DrawModes::DrawMode splatsDrawMode_;
217 DrawModes::DrawMode dotsDrawMode_;
218 DrawModes::DrawMode pointsDrawMode_;
219
220 // ---- picking ----
221
222 unsigned int pickingBaseIndex_;
223
224 // TODO: hack, see enterPick()
225 DrawModes::DrawMode pickDrawMode_;
226
227 // ---- vertex buffer object ----
228
229 GLuint vboGlId_;
230 unsigned int vboNumSplats_;
231 unsigned char *vboData_;
232
234 int vboPositionsOffset_;
235 int vboColorsOffset_;
236 int vboNormalsOffset_;
237 int vboPointsizesOffset_;
238 int vboSelectionsOffset_;
239 int vboPickColorsOffset_;
240
242 inline bool vboStructureModified() const
243 {
244 return vboNumSplats_ != splatCloud_.numSplats() ||
245 (vboPositionsOffset_ != -1) != splatCloud_.hasPositions() ||
246 (vboColorsOffset_ != -1) != splatCloud_.hasColors() ||
247 (vboNormalsOffset_ != -1) != splatCloud_.hasNormals() ||
248 (vboPointsizesOffset_ != -1) != splatCloud_.hasPointsizes() ||
249 (vboSelectionsOffset_ != -1) != splatCloud_.hasSelections();
250 }
251
252 void createVBO();
253 void destroyVBO();
254 void rebuildVBO( GLState &_state );
255
256 void rebuildVBOPositions();
257 void rebuildVBOColors();
258 void rebuildVBONormals();
259 void rebuildVBOPointsizes();
260 void rebuildVBOSelections();
261 void rebuildVBOPickColors( GLState &_state );
262
263 static const Position DEFAULT_POSITION;
264 static const Index DEFAULT_INDEX;
265 static const Viewlist DEFAULT_VIEWLIST;
266 static const Selection DEFAULT_SELECTION;
267 };
268
269
270 //================================================================
271
272
273 } // namespace SceneGraph
274 } // namespace ACG
275
276
277 //================================================================
278
279
280 #endif // ACG_SPLATCLOUDNODE_HH
OpenMesh::Attributes::Color
Add colors to mesh item (vertices/faces/edges)
Definition: Attributes.hh:88
SplatCloud::hasPositions
bool hasPositions() const
Return the availability of the predefined property.
Definition: SplatCloud.hh:613
ACG
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:135
ACG::SceneGraph::PickTarget
PickTarget
What target to use for picking.
Definition: BaseNode.hh:99
SplatCloud::hasNormals
bool hasNormals() const
Return the availability of the predefined property.
Definition: SplatCloud.hh:615
GlobalDefines.hh
ACG::SceneGraph::SplatCloudNode::vboModified
bool vboModified() const
return true iff any of the data values in the VBO has to be changed
Definition: SplatCloudNode.hh:197
ACG::GLState
Definition: GLState.hh:220
SplatCloud::numSplats
unsigned int numSplats() const
Get the number of splats.
Definition: SplatCloud.hh:185
ACG::SceneGraph::SplatCloudNode::positionsModified_
bool positionsModified_
marks if parts of the data has been modified
Definition: SplatCloudNode.hh:189
ACG::SceneGraph::SplatCloudNode
Definition: SplatCloudNode.hh:94
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:294
ACG::SceneGraph::SplatCloudNode::vboStructureModified
bool vboStructureModified() const
returns true iff the internal block structure of the VBO has to be changed
Definition: SplatCloudNode.hh:242
ACG::SceneGraph::SplatCloudNode::availableDrawModes
DrawModes::DrawMode availableDrawModes() const
return available draw modes
Definition: SplatCloudNode.hh:121
SplatCloud::hasPointsizes
bool hasPointsizes() const
Return the availability of the predefined property.
Definition: SplatCloud.hh:616
ACG::SceneGraph::SplatCloudNode::vboPositionsOffset_
int vboPositionsOffset_
offsets relative to vboData_ or -1 if not present in VBO
Definition: SplatCloudNode.hh:234
ACG::SceneGraph::SplatCloudNode::defaultColor_
Color defaultColor_
the default values will be used when the specific array is not present
Definition: SplatCloudNode.hh:210
OpenMesh::VectorT
Definition: Vector11T.hh:83
ACG::SceneGraph::SplatCloudNode::getPosition
const Position & getPosition(int _idx) const
if the data array exists, the entry with the given index is returned, otherwise the default value is ...
Definition: SplatCloudNode.hh:169
ACG::SceneGraph::SplatCloudNode::splatCloud_
const SplatCloud & splatCloud_
reference to class containing all the data
Definition: SplatCloudNode.hh:184
DLLEXPORT
#define DLLEXPORT
Definition: GlobalDefines.hh:107
OpenMesh::Attributes::Normal
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:87
SplatCloud
Definition: SplatCloud.hh:85
SplatCloudNode
ACG::SceneGraph::SplatCloudNode SplatCloudNode
Simple Name for SplatCloudNode.
Definition: SplatCloudTypes.hh:82
SplatCloud::hasColors
bool hasColors() const
Return the availability of the predefined property.
Definition: SplatCloud.hh:614
SplatCloud::hasSelections
bool hasSelections() const
Return the availability of the predefined property.
Definition: SplatCloud.hh:619