59 #ifndef ACG_BSPLINECURVENODET_HH
60 #define ACG_BSPLINECURVENODET_HH
65 #include <ACG/Scenegraph/BaseNode.hh>
66 #include <ACG/Scenegraph/DrawModes.hh>
70 #include <ACG/GL/globjects.hh>
71 #include <ACG/GL/VertexDeclaration.hh>
79 namespace SceneGraph {
90 template <
class BSplineCurve>
96 typedef typename BSplineCurve::Point Point;
101 std::string _name=
"<BSplineCurveNode>" ) :
106 polygon_color_(
Vec4f(34.f/255.f, 139.f/255.f, 34.f/255.f, 1.f) ),
107 polygon_highlight_color_(
Vec4f(1.f, 1.f, 0.f, 1.f) ),
108 curve_color_(
Vec4f(178.f/255.f, 34.f/255.f, 34.f/255.f, 1.f) ),
109 curve_highlight_color_(
Vec4f(1.f, 1.f, 1.f, 1.f) ),
110 render_control_polygon_(true),
111 render_bspline_curve_(true),
112 bspline_draw_mode_(NORMAL),
113 bspline_selection_draw_mode_(NONE),
114 pick_texture_idx_(0),
115 pick_texture_res_(256),
116 pick_texture_baseidx_(0),
117 cp_selection_texture_idx_(0),
118 cp_selection_texture_res_(256),
119 knot_selection_texture_idx_(0),
120 knot_selection_texture_res_(256),
121 controlPointSelectionTexture_valid_(false),
122 knotVectorSelectionTexture_valid_(false),
123 curveLineVertices_(0),
124 invalidateCurveLine_(true),
125 controlPointSelCount_(0),
126 controlEdgeSelCount_(0),
127 invalidateControlPointVBO_(true),
128 invalidateControlPointSelIBO_(true),
129 invalidateControlEdgeSelIBO_(true)
133 cylinder_ =
new GLCylinder(16, 1, 1.0f,
true,
true);
135 fancySphere_ =
new GLSphere(16, 16);
153 enum BSplineDrawMode {
158 enum BSplineSelectionDrawMode {
167 void set_pick_radius(
double _pr) { pick_radius_ = _pr; }
179 void draw(GLState& _state,
const DrawModes::DrawMode& _drawMode);
184 void set_rendering_resolution(
int _res){resolution_ = _res;};
186 void render_control_polygon(
bool _render) {render_control_polygon_ = _render;};
187 bool render_control_polygon() {
return render_control_polygon_; };
189 void render_bspline_curve(
bool _render) {render_bspline_curve_ = _render;};
190 bool render_bspline_curve() {
return render_bspline_curve_; };
192 void set_selection_draw_mode(BSplineSelectionDrawMode _mode) {bspline_selection_draw_mode_ = _mode;};
194 BSplineSelectionDrawMode get_selection_draw_mode()
const {
return bspline_selection_draw_mode_; }
196 void set_bspline_draw_mode(BSplineDrawMode _mode) {bspline_draw_mode_ = _mode;};
198 void updateGeometry();
203 void cpSelectionTextureValid (
bool _valid){controlPointSelectionTexture_valid_ = _valid;};
204 void knotSelectionTextureValid(
bool _valid){knotVectorSelectionTexture_valid_ = _valid;};
208 void pick_vertices(GLState& _state);
209 void pick_spline( GLState& _state,
unsigned int _offset );
211 void draw_cylinder(
const Point& _p0,
const Point& _axis,
double _r, GLState& _state);
212 void draw_sphere (
const Point& _p0,
double _r, GLState& _state, GLSphere* _sphere);
221 void render(GLState& _state,
bool _fill, DrawModes::DrawMode _drawMode);
223 void getRenderObjects(IRenderer* _renderer, GLState& _state ,
const DrawModes::DrawMode& _drawMode ,
const Material* _mat);
246 void updateControlPointSelectionTexture(GLState& _state);
248 void updateKnotVectorSelectionTexture(GLState& _state);
285 Vec4f polygon_color_;
286 Vec4f polygon_highlight_color_;
289 Vec4f curve_highlight_color_;
291 bool render_control_polygon_;
292 bool render_bspline_curve_;
294 BSplineDrawMode bspline_draw_mode_;
296 BSplineSelectionDrawMode bspline_selection_draw_mode_;
298 std::vector< std::pair< Vec3d, Vec4f > > curve_samples_;
301 QImage pick_texture_image_;
302 GLuint pick_texture_idx_;
303 int pick_texture_res_;
305 unsigned int pick_texture_baseidx_;
309 QImage cp_selection_texture_image_;
310 GLuint cp_selection_texture_idx_;
311 int cp_selection_texture_res_;
314 QImage knot_selection_texture_image_;
315 GLuint knot_selection_texture_idx_;
316 int knot_selection_texture_res_;
318 bool controlPointSelectionTexture_valid_;
319 bool knotVectorSelectionTexture_valid_;
321 GLCylinder* cylinder_;
323 GLSphere* fancySphere_;
327 GeometryBuffer curveLineVBO_;
328 VertexDeclaration curveLineDecl_;
329 int curveLineVertices_;
330 bool invalidateCurveLine_;
334 GeometryBuffer controlPointVBO_;
335 VertexDeclaration controlPointDecl_;
336 IndexBuffer controlPointSelIBO_;
337 int controlPointSelCount_;
338 IndexBuffer controlEdgeSelIBO_;
339 int controlEdgeSelCount_;
340 bool invalidateControlPointVBO_;
341 bool invalidateControlPointSelIBO_;
342 bool invalidateControlEdgeSelIBO_;
350 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_BSPLINECURVENODET_C)
351 #define ACG_BSPLINECURVENODET_TEMPLATES
352 #include "BSplineCurveNodeT.cc"
355 #endif // ACG_BSPLINECURVENODET_HH defined
~BSplineCurveNodeT()
Destructor.
ACG_CLASSNAME(BSplineCurveNodeT)
static name of this class
void updateControlPointSelBuffer()
update control point selection buffer for visualization
void selection_init_texturing(GLuint &_texture_idx)
generate index and setup texture parameters for selection visualization
Namespace providing different geometric functions concerning angles.
void create_cp_selection_texture(GLState &_state)
creates texture to put onto nurbs curve for visualization of control point selection ...
PickTarget
What target to use for picking.
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 drawTexturedCurve(GLState &_state, GLuint _texture_idx)
renders a textured cuve using the gluNurbsRenderer to vilualize either the control point ot the knot ...
VectorT< double, 3 > Vec3d
DrawModes::DrawMode availableDrawModes() const
return available draw modes
BSplineCurveNodeT(BSplineCurve &_bsc, BaseNode *_parent=0, std::string _name="<BSplineCurveNode>")
Constructor.
void draw_textured_nurbs(GLState &_state)
draw textured nurbs patch
int & pick_texture_res()
Should be a power of 2.
void pick(GLState &_state, PickTarget _target)
picking
DrawModes::DrawMode drawMode() const
Return the own draw modes of this node.
void create_knot_selection_texture(GLState &_state)
creates texture to put onto nurbs curve for visualization of knotvector selection ...
void pick_create_texture(GLState &_state)
create texture image
void drawControlPolygon(DrawModes::DrawMode _drawMode, GLState &_state)
Renders the control polygon.
DrawMode POINTS
draw unlighted points using the default base color
void drawFancyControlPolygon(DrawModes::DrawMode _drawMode, GLState &_state)
Renders the control polygon using cylinders and spheres to include shading effects.
ACG::Vec4f generateHighlightColor(ACG::Vec4f _color)
generates a color to highlight the curve from the given color
DrawMode WIREFRAME
draw wireframe
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
BSplineCurveNodeT & operator=(const BSplineCurveNodeT &_rhs)
Assignment operator (not used)
void drawCurve(GLState &_state)
Renders the spline curve using gluNurbsRenderer.
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode)
draw lines and normals
void pick_init_texturing()
generate index and setup texture parameters
void updateControlEdgeSelBuffer()
update control edge selection buffer for visualization
void updateControlPointBuffer()
update control point buffer for visualization