53 #ifndef ACG_BSPLINECURVENODET_HH 54 #define ACG_BSPLINECURVENODET_HH 59 #include <ACG/Scenegraph/BaseNode.hh> 60 #include <ACG/Scenegraph/DrawModes.hh> 64 #include <ACG/GL/globjects.hh> 65 #include <ACG/GL/VertexDeclaration.hh> 67 #include <ACG/GL/GLPrimitives.hh> 87 template <
class BSplineCurve>
93 typedef typename BSplineCurve::Point Point;
98 std::string _name=
"<BSplineCurveNode>" ) :
103 polygon_color_(
Vec4f(34.f/255.f, 139.f/255.f, 34.f/255.f, 1.f) ),
104 polygon_highlight_color_(
Vec4f(1.f, 1.f, 0.f, 1.f) ),
105 curve_color_(
Vec4f(178.f/255.f, 34.f/255.f, 34.f/255.f, 1.f) ),
106 curve_highlight_color_(
Vec4f(1.f, 1.f, 1.f, 1.f) ),
107 render_control_polygon_(true),
108 render_bspline_curve_(true),
109 bspline_draw_mode_(NORMAL),
110 bspline_selection_draw_mode_(NONE),
111 pick_texture_idx_(0),
112 pick_texture_res_(256),
113 pick_texture_baseidx_(0),
114 cp_selection_texture_idx_(0),
115 cp_selection_texture_res_(256),
116 knot_selection_texture_idx_(0),
117 knot_selection_texture_res_(256),
118 controlPointSelectionTexture_valid_(false),
119 knotVectorSelectionTexture_valid_(false),
120 curveLineVertices_(0),
121 invalidateCurveLine_(true),
122 controlPointSelCount_(0),
123 controlEdgeSelCount_(0),
124 invalidateControlPointVBO_(true),
125 invalidateControlPointSelIBO_(true),
126 invalidateControlEdgeSelIBO_(true)
130 cylinder_ =
new GLCylinder(16, 1, 1.0f,
true,
true);
132 fancySphere_ =
new GLSphere(16, 16);
150 enum BSplineDrawMode {
155 enum BSplineSelectionDrawMode {
164 void set_pick_radius(
double _pr) { pick_radius_ = _pr; }
181 void set_rendering_resolution(
int _res){resolution_ = _res;};
183 void render_control_polygon(
bool _render) {render_control_polygon_ = _render;};
184 bool render_control_polygon() {
return render_control_polygon_; };
186 void render_bspline_curve(
bool _render) {render_bspline_curve_ = _render;};
187 bool render_bspline_curve() {
return render_bspline_curve_; };
189 void set_selection_draw_mode(BSplineSelectionDrawMode _mode) {bspline_selection_draw_mode_ = _mode;};
191 BSplineSelectionDrawMode get_selection_draw_mode()
const {
return bspline_selection_draw_mode_; }
193 void set_bspline_draw_mode(BSplineDrawMode _mode) {bspline_draw_mode_ = _mode;};
195 void updateGeometry();
200 void cpSelectionTextureValid (
bool _valid){controlPointSelectionTexture_valid_ = _valid;};
201 void knotSelectionTextureValid(
bool _valid){knotVectorSelectionTexture_valid_ = _valid;};
205 void pick_vertices(
GLState& _state);
206 void pick_spline(
GLState& _state,
unsigned int _offset );
208 void draw_cylinder(
const Point& _p0,
const Point& _axis,
double _r,
GLState& _state);
209 void draw_sphere (
const Point& _p0,
double _r,
GLState& _state,
GLSphere* _sphere);
243 void updateControlPointSelectionTexture(
GLState& _state);
245 void updateKnotVectorSelectionTexture(
GLState& _state);
282 Vec4f polygon_color_;
283 Vec4f polygon_highlight_color_;
286 Vec4f curve_highlight_color_;
288 bool render_control_polygon_;
289 bool render_bspline_curve_;
291 BSplineDrawMode bspline_draw_mode_;
293 BSplineSelectionDrawMode bspline_selection_draw_mode_;
295 std::vector< std::pair< Vec3d, Vec4f > > curve_samples_;
298 QImage pick_texture_image_;
299 GLuint pick_texture_idx_;
300 int pick_texture_res_;
302 unsigned int pick_texture_baseidx_;
306 QImage cp_selection_texture_image_;
307 GLuint cp_selection_texture_idx_;
308 int cp_selection_texture_res_;
311 QImage knot_selection_texture_image_;
312 GLuint knot_selection_texture_idx_;
313 int knot_selection_texture_res_;
315 bool controlPointSelectionTexture_valid_;
316 bool knotVectorSelectionTexture_valid_;
324 GeometryBuffer curveLineVBO_;
326 int curveLineVertices_;
327 bool invalidateCurveLine_;
331 GeometryBuffer controlPointVBO_;
333 IndexBuffer controlPointSelIBO_;
334 int controlPointSelCount_;
335 IndexBuffer controlEdgeSelIBO_;
336 int controlEdgeSelCount_;
337 bool invalidateControlPointVBO_;
338 bool invalidateControlPointSelIBO_;
339 bool invalidateControlEdgeSelIBO_;
347 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_BSPLINECURVENODET_C) 348 #define ACG_BSPLINECURVENODET_TEMPLATES 349 #include "BSplineCurveNodeT_impl.hh" 352 #endif // ACG_BSPLINECURVENODET_HH defined void draw_textured_nurbs(GLState &_state)
draw textured nurbs patch
void updateControlPointSelBuffer()
update control point selection buffer for visualization
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax) override
update bounding box
~BSplineCurveNodeT()
Destructor.
DrawModes::DrawMode drawMode() const
Return the own draw modes of this node.
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 ...
void drawFancyCurve(GLState &_state)
Renders the spline curve by sampling the curve and rendering cylinders in between the samples...
Class to define the vertex input layout.
BSplineCurveNodeT(BSplineCurve &_bsc, BaseNode *_parent=0, std::string _name="<BSplineCurveNode>")
Constructor.
DrawModes::DrawMode availableDrawModes() const override
return available draw modes
void pick(GLState &_state, PickTarget _target) override
picking
void create_knot_selection_texture(GLState &_state)
creates texture to put onto nurbs curve for visualization of knotvector selection ...
PickTarget
What target to use for picking.
void pick_create_texture(GLState &_state)
create texture image
void updateControlPointBuffer()
update control point buffer for visualization
int & pick_texture_res()
Should be a power of 2.
void drawCurve(GLState &_state)
Renders the spline curve using gluNurbsRenderer.
BSplineCurveNodeT & operator=(const BSplineCurveNodeT &_rhs)
Assignment operator (not used)
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode) override
draw lines and normals
DrawMode POINTS
draw unlighted points using the default base color
ACG_CLASSNAME(BSplineCurveNodeT)
static name of this class
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 ...
void pick_init_texturing()
generate index and setup texture parameters
DrawMode WIREFRAME
draw wireframe
void selection_init_texturing(GLuint &_texture_idx)
generate index and setup texture parameters for selection visualization
void updateControlEdgeSelBuffer()
update control edge selection buffer for visualization
ACG::Vec4f generateHighlightColor(ACG::Vec4f _color)
generates a color to highlight the curve from the given color
void drawFancyControlPolygon(DrawModes::DrawMode _drawMode, GLState &_state)
Renders the control polygon using cylinders and spheres to include shading effects.
void drawControlPolygon(DrawModes::DrawMode _drawMode, GLState &_state)
Renders the control polygon.