53#ifndef ACG_BSPLINECURVENODET_HH
54#define ACG_BSPLINECURVENODET_HH
59#include <ACG/Scenegraph/BaseNode.hh>
60#include <ACG/Scenegraph/DrawModes.hh>
62#include <ACG/GL/globjects.hh>
63#include <ACG/GL/VertexDeclaration.hh>
65#include <ACG/GL/GLPrimitives.hh>
85template <
class BSplineCurve>
91 typedef typename BSplineCurve::Point Point;
96 std::string _name=
"<BSplineCurveNode>" ) :
101 polygon_color_(
Vec4f(34.f/255.f, 139.f/255.f, 34.f/255.f, 1.f) ),
102 polygon_highlight_color_(
Vec4f(1.f, 1.f, 0.f, 1.f) ),
103 curve_color_(
Vec4f(178.f/255.f, 34.f/255.f, 34.f/255.f, 1.f) ),
104 curve_highlight_color_(
Vec4f(1.f, 1.f, 1.f, 1.f) ),
105 render_control_polygon_(true),
106 render_bspline_curve_(true),
107 bspline_draw_mode_(NORMAL),
108 bspline_selection_draw_mode_(NONE),
109 pick_texture_idx_(0),
110 pick_texture_res_(256),
111 pick_texture_baseidx_(0),
112 cp_selection_texture_idx_(0),
113 cp_selection_texture_res_(256),
114 knot_selection_texture_idx_(0),
115 knot_selection_texture_res_(256),
116 controlPointSelectionTexture_valid_(false),
117 knotVectorSelectionTexture_valid_(false),
118 curveLineVertices_(0),
119 invalidateCurveLine_(true),
120 controlPointSelCount_(0),
121 controlEdgeSelCount_(0),
122 invalidateControlPointVBO_(true),
123 invalidateControlPointSelIBO_(true),
124 invalidateControlEdgeSelIBO_(true)
128 cylinder_ =
new GLCylinder(16, 1, 1.0f,
true,
true);
130 fancySphere_ =
new GLSphere(16, 16);
148 enum BSplineDrawMode {
153 enum BSplineSelectionDrawMode {
162 void set_pick_radius(
double _pr) { pick_radius_ = _pr; }
179 void set_rendering_resolution(
int _res){resolution_ = _res;};
181 void render_control_polygon(
bool _render) {render_control_polygon_ = _render;};
182 bool render_control_polygon() {
return render_control_polygon_; };
184 void render_bspline_curve(
bool _render) {render_bspline_curve_ = _render;};
185 bool render_bspline_curve() {
return render_bspline_curve_; };
187 void set_selection_draw_mode(BSplineSelectionDrawMode _mode) {bspline_selection_draw_mode_ = _mode;};
189 BSplineSelectionDrawMode get_selection_draw_mode()
const {
return bspline_selection_draw_mode_; }
191 void set_bspline_draw_mode(BSplineDrawMode _mode) {bspline_draw_mode_ = _mode;};
193 void updateGeometry();
198 void cpSelectionTextureValid (
bool _valid){controlPointSelectionTexture_valid_ = _valid;};
199 void knotSelectionTextureValid(
bool _valid){knotVectorSelectionTexture_valid_ = _valid;};
203 void pick_vertices(GLState& _state);
204 void pick_spline( GLState& _state,
unsigned int _offset );
206 void draw_cylinder(
const Point& _p0,
const Point& _axis,
double _r, GLState& _state);
207 void draw_sphere (
const Point& _p0,
double _r, GLState& _state, GLSphere* _sphere);
241 void updateControlPointSelectionTexture(
GLState& _state);
243 void updateKnotVectorSelectionTexture(
GLState& _state);
280 Vec4f polygon_color_;
281 Vec4f polygon_highlight_color_;
284 Vec4f curve_highlight_color_;
286 bool render_control_polygon_;
287 bool render_bspline_curve_;
289 BSplineDrawMode bspline_draw_mode_;
291 BSplineSelectionDrawMode bspline_selection_draw_mode_;
293 std::vector< std::pair< Vec3d, Vec4f > > curve_samples_;
296 QImage pick_texture_image_;
297 GLuint pick_texture_idx_;
298 int pick_texture_res_;
300 unsigned int pick_texture_baseidx_;
304 QImage cp_selection_texture_image_;
305 GLuint cp_selection_texture_idx_;
306 int cp_selection_texture_res_;
309 QImage knot_selection_texture_image_;
310 GLuint knot_selection_texture_idx_;
311 int knot_selection_texture_res_;
313 bool controlPointSelectionTexture_valid_;
314 bool knotVectorSelectionTexture_valid_;
322 GeometryBuffer curveLineVBO_;
324 int curveLineVertices_;
325 bool invalidateCurveLine_;
329 GeometryBuffer controlPointVBO_;
331 IndexBuffer controlPointSelIBO_;
332 int controlPointSelCount_;
333 IndexBuffer controlEdgeSelIBO_;
334 int controlEdgeSelCount_;
335 bool invalidateControlPointVBO_;
336 bool invalidateControlPointSelIBO_;
337 bool invalidateControlEdgeSelIBO_;
345#if defined(INCLUDE_TEMPLATES) && !defined(ACG_BSPLINECURVENODET_C)
346#define ACG_BSPLINECURVENODET_TEMPLATES
347#include "BSplineCurveNodeT_impl.hh"
BSplineCurveNodeT(BSplineCurve &_bsc, BaseNode *_parent=0, std::string _name="<BSplineCurveNode>")
Constructor.
void updateControlEdgeSelBuffer()
update control edge selection buffer for visualization
BSplineCurveNodeT(const BSplineCurveNodeT &_rhs)
Copy constructor (not used)
void selection_init_texturing(GLuint &_texture_idx)
generate index and setup texture parameters for selection visualization
void drawFancyControlPolygon(DrawModes::DrawMode _drawMode, GLState &_state)
Renders the control polygon using cylinders and spheres to include shading effects.
ACG_CLASSNAME(BSplineCurveNodeT)
static name of this class
DrawModes::DrawMode availableDrawModes() const override
return available draw modes
int & pick_texture_res()
Should be a power of 2.
void updateControlPointBuffer()
update control point buffer for visualization
void pick(GLState &_state, PickTarget _target) override
picking
void create_cp_selection_texture(GLState &_state)
creates texture to put onto nurbs curve for visualization of control point selection
void updateControlPointSelBuffer()
update control point selection buffer for visualization
~BSplineCurveNodeT()
Destructor.
void getRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat) override
Deferred draw call with shader based renderer.
void draw_textured_nurbs(GLState &_state)
draw textured nurbs patch
void drawTexturedCurve(GLState &_state, GLuint _texture_idx)
renders a textured cuve using the gluNurbsRenderer to vilualize either the control point ot the knot ...
void pick_create_texture(GLState &_state)
create texture image
void pick_init_texturing()
generate index and setup texture parameters
void drawFancyCurve(GLState &_state)
Renders the spline curve by sampling the curve and rendering cylinders in between the samples.
void updateCurveBuffer(int _numVertices=50)
update curve line buffer for drawing
void drawCurve(GLState &_state)
Renders the spline curve using gluNurbsRenderer.
void drawControlPolygon(DrawModes::DrawMode _drawMode, GLState &_state)
Renders the control polygon.
BSplineCurveNodeT & operator=(const BSplineCurveNodeT &_rhs)
Assignment operator (not used)
ACG::Vec4f generateHighlightColor(ACG::Vec4f _color)
generates a color to highlight the curve from the given color
void create_knot_selection_texture(GLState &_state)
creates texture to put onto nurbs curve for visualization of knotvector selection
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode) override
draw lines and normals
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax) override
update bounding box
DrawModes::DrawMode drawMode() const
Return the own draw modes of this node.
Class to define the vertex input layout.
DrawMode WIREFRAME
draw wireframe
DrawMode POINTS
draw unlighted points using the default base color
PickTarget
What target to use for picking.
Namespace providing different geometric functions concerning angles.