Developer Documentation
Loading...
Searching...
No Matches
PolyLineNodeT.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 PolyLineNodeT
50//
51// Author: David Bommes <bommes@cs.rwth-aachen.de>
52//
53//=============================================================================
54
55
56#ifndef ACG_POLYLINENODET_HH
57#define ACG_POLYLINENODET_HH
58
59
60//== INCLUDES =================================================================
61
62#include <ACG/Scenegraph/BaseNode.hh>
63#include <ACG/Scenegraph/DrawModes.hh>
64#include <ACG/GL/VertexDeclaration.hh>
65#include <ACG/GL/IRenderer.hh>
66#include <ACG/GL/GLPrimitives.hh>
67#include <ACG/GL/globjects.hh>
68
69//== FORWARDDECLARATIONS ======================================================
70
71//== NAMESPACES ===============================================================
72
73namespace ACG {
74namespace SceneGraph {
75
76//== CLASS DEFINITION =========================================================
77
78
79
80
88template <class PolyLine>
89class PolyLineNodeT : public BaseNode
90{
91public:
92
93 // typedefs for easy access
94 typedef typename PolyLine::Point Point;
95
97 PolyLineNodeT(PolyLine& _pl, BaseNode* _parent = 0, std::string _name = "<PolyLineNode>");
98
101
102 PolyLine& polyline() { return polyline_; }
103
106
109
111 void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax) override;
112
114 void draw(GLState& /*_state*/,const DrawModes::DrawMode& _drawMode) override;
115
117 void pick(GLState& _state, PickTarget _target) override;
118
126 void getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::SceneGraph::DrawModes::DrawMode& _drawMode , const ACG::SceneGraph::Material* _mat) override;
127
129 void update() { updateVBO_ = true; };
130
131
164 int addCustomBuffer(const ACG::VertexElement& _desc, const void* _buffer);
165
166
172 void setCustomBuffer(int _id, const void* _buffer);
173
174
175
184 void setupVertexDeclaration(VertexDeclaration* _dst, int _colorSource) const;
185
186
199 size_t fillVertexBuffer(void* _buf, size_t _bufSize, bool _addLineStripEndVertex);
200
201private:
202
203 void pick_vertices ( GLState& _state );
204 void pick_spheres ( GLState& _state );
205 void pick_spheres_screen ( GLState& _state );
206 void pick_edges ( GLState& _state, unsigned int _offset);
207
210
213
216
219
222
224 std::vector< std::pair<ACG::VertexElement, const void*> > customBuffers_;
225
227 std::map< typename PolyLine::CustomPropertyHandle, int> polylinePropMap_;
228
234 void updateVBO();
235
241 void writeVertex(unsigned int _vertex, void* _dst);
242
249 void writeVertexColor(unsigned int _vertex, bool _colorSourceVertex, void* _dst) const;
250
251private:
252
255
257 GeometryBuffer vbo_;
258
260 std::vector<unsigned int> selectedVertexIndexBuffer_;
261
263 std::vector<unsigned int> selectedEdgeIndexBuffer_;
264
267
270
273
276};
277
278
279//=============================================================================
280} // namespace SceneGraph
281} // namespace ACG
282//=============================================================================
283#if defined(INCLUDE_TEMPLATES) && !defined(ACG_POLYLINENODET_C)
284#define ACG_POLYLINENODET_TEMPLATES
285#include "PolyLineNodeT_impl.hh"
286#endif
287//=============================================================================
288#endif // ACG_POLYLINENODET_HH defined
289//=============================================================================
290
ACG::VertexDeclaration vertexDecl_
Vertex layout without vertex colors.
void getRenderObjects(ACG::IRenderer *_renderer, ACG::GLState &_state, const ACG::SceneGraph::DrawModes::DrawMode &_drawMode, const ACG::SceneGraph::Material *_mat) override
Add the objects to the given renderer.
DrawModes::DrawMode POINTS_SPHERES
This defines a local point spheres draw mode for all polyLine nodes.
void update()
Trigger an update of the vbo.
ACG_CLASSNAME(PolyLineNodeT)
static name of this class
void updateVBO()
Trigger an update of the vbo.
void writeVertexColor(unsigned int _vertex, bool _colorSourceVertex, void *_dst) const
Write color for rendering to a buffer.
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax) override
update bounding box
ACG::VertexDeclaration vertexDeclECol_
Vertex layout with edge colors.
ACG::VertexDeclaration vertexDeclVCol_
Vertex layout with vertex colors.
void setCustomBuffer(int _id, const void *_buffer)
void setupVertexDeclaration(VertexDeclaration *_dst, int _colorSource) const
Create the vertex declaration.
int addCustomBuffer(const ACG::VertexElement &_desc, const void *_buffer)
void draw(GLState &, const DrawModes::DrawMode &_drawMode) override
draw lines and normals
std::vector< unsigned int > selectedEdgeIndexBuffer_
Index buffer for selected edges.
size_t fillVertexBuffer(void *_buf, size_t _bufSize, bool _addLineStripEndVertex)
Fill a buffer with vertex data.
std::vector< std::pair< ACG::VertexElement, const void * > > customBuffers_
Custom vertex data for shader based rendering.
void writeVertex(unsigned int _vertex, void *_dst)
Write vertex data for rendering to a buffer.
PolyLineNodeT(const PolyLineNodeT &_rhs)
Copy constructor (not used)
std::map< typename PolyLine::CustomPropertyHandle, int > polylinePropMap_
Map from custom properties in PolyLine to id in customBuffers_.
GLSphere * sphere_
Sphere for VertexSphere DrawMode.
DrawModes::DrawMode availableDrawModes() const override
return available draw modes
DrawModes::DrawMode POINTS_SPHERES_SCREEN
This defines a local point spheres draw mode for all polyLine nodes with constant screen size.
PolyLineNodeT & operator=(const PolyLineNodeT &_rhs)
Assignment operator (not used)
GeometryBuffer vbo_
VBO used to render the poly line.
bool updateVBO_
Flag to trigger update of vbo.
std::vector< unsigned int > selectedVertexIndexBuffer_
Index buffer for selected vertices.
PolyLine & polyline_
The associated poly line.
void pick(GLState &_state, PickTarget _target) override
picking
Class to define the vertex input layout.
PickTarget
What target to use for picking.
Definition PickTarget.hh:74
Namespace providing different geometric functions concerning angles.
Description of one vertex element.