52#define ACG_BSPLINECURVENODET_C
56#include "BSplineCurveNodeT.hh"
57#include <ACG/GL/gl.hh>
58#include <ACG/GL/GLError.hh>
59#include <ACG/GL/IRenderer.hh>
60#include <ACG/Utils/VSToolsT.hh>
62#include <OpenMesh/Core/Utils/vector_cast.hh>
63#include <ACG/Utils/ImageConversion.hh>
75template <
class BSplineCurve>
80 for (
unsigned int i = 0; i < bsplineCurve_.n_control_points(); ++i)
82 _bbMin.
minimize(bsplineCurve_.get_control_point(i));
83 _bbMax.
maximize(bsplineCurve_.get_control_point(i));
89template <
class BSplineCurve>
114template <
class BSplineCurve>
119 glPushAttrib(GL_ENABLE_BIT);
122 if ( bspline_selection_draw_mode_ == CONTROLPOINT
123 && controlPointSelectionTexture_valid_ ==
false)
124 updateControlPointSelectionTexture(_state);
126 if ( bspline_selection_draw_mode_ == KNOTVECTOR
127 && knotVectorSelectionTexture_valid_ ==
false)
128 updateKnotVectorSelectionTexture(_state);
135 if (bspline_draw_mode_ == NORMAL)
139 else if (bspline_draw_mode_ == FANCY)
143 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
149 render( _state,
false, _drawMode);
156 render( _state,
false, _drawMode);
165template <
class BSplineCurve>
171 if ( bspline_selection_draw_mode_ == CONTROLPOINT
172 && controlPointSelectionTexture_valid_ ==
false)
173 updateControlPointSelectionTexture(_state);
175 if ( bspline_selection_draw_mode_ == KNOTVECTOR
176 && knotVectorSelectionTexture_valid_ ==
false)
177 updateKnotVectorSelectionTexture(_state);
198 if (props->primitive() == DrawModes::PRIMITIVE_POINT)
200 ro.glDrawArrays(GL_POINTS, 0, curveLineVertices_);
203 else if (props->primitive() == DrawModes::PRIMITIVE_WIREFRAME)
205 ro.glDrawArrays(GL_LINE_STRIP, 0, curveLineVertices_);
211 if (render_control_polygon_)
213 updateControlPointBuffer();
214 updateControlPointSelBuffer();
215 updateControlEdgeSelBuffer();
225 Vec3f highlightColor = OpenMesh::vector_cast<Vec3f, Vec4f>(generateHighlightColor(polygon_color_));
226 Vec3f polygonColor = OpenMesh::vector_cast<Vec3f, Vec4f>(polygon_color_);
232 if (controlEdgeSelCount_)
234 ro.emissive = highlightColor;
238 ro.glDrawElements(GL_LINES, 2 * controlEdgeSelCount_, GL_UNSIGNED_INT, 0);
243 ro.emissive = polygonColor;
245 ro.glDrawArrays(GL_LINE_STRIP, 0, bsplineCurve_.n_control_points());
251 if (controlPointSelCount_)
253 ro.emissive = highlightColor;
257 ro.glDrawElements(GL_POINTS, controlPointSelCount_, GL_UNSIGNED_INT, 0);
262 ro.emissive = polygonColor;
264 ro.glDrawElements(GL_POINTS, bsplineCurve_.n_control_points(), GL_UNSIGNED_INT, 0);
271template <
class BSplineCurve>
277 if (render_control_polygon_)
279 if (bspline_draw_mode_ == NORMAL)
280 drawControlPolygon(_drawMode, _state);
281 else if (bspline_draw_mode_ == FANCY)
282 drawFancyControlPolygon(_drawMode, _state);
289 if (bspline_selection_draw_mode_ == NONE)
291 if (bspline_draw_mode_ == NORMAL)
294 drawFancyCurve(_state);
298 if (bspline_selection_draw_mode_ == CONTROLPOINT) {
299 drawTexturedCurve(_state, cp_selection_texture_idx_);
301 else if (bspline_selection_draw_mode_ == KNOTVECTOR) {
302 drawTexturedCurve(_state, knot_selection_texture_idx_);
310template <
class BSplineCurve>
317 curveLineVBO_.bind();
318 curveLineDecl_.activateFixedFunction();
320 glDrawArrays(GL_LINE_STRIP, 0, curveLineVertices_);
322 curveLineDecl_.deactivateFixedFunction();
323 curveLineVBO_.unbind();
328template <
class BSplineCurve>
335 double cylinderRadius = _state.
line_width() * 0.2;
337 for (
int i = 0; i < (int)curve_samples_.size() - 1; ++i)
339 Vec3d p = curve_samples_[i].first;
340 Vec3d p_next = curve_samples_[i+1].first;
341 draw_cylinder(p, p_next - p, cylinderRadius, _state);
347template <
class BSplineCurve>
352 float c1 = _color[0]*1.5;
353 c1 = c1 > 1.0 ? 1.0 : c1;
355 float c2 = _color[1]*1.5;
356 c2 = c2 > 1.0 ? 1.0 : c2;
358 float c3 = _color[2]*1.5;
359 c3 = c3 > 1.0 ? 1.0 : c3;
361 return Vec4f( c1, c2, c3, _color[3]);
366template <
class BSplineCurve>
371 updateControlPointBuffer();
372 updateControlPointSelBuffer();
373 updateControlEdgeSelBuffer();
378 controlPointVBO_.bind();
379 controlPointDecl_.activateFixedFunction();
385 if( bsplineCurve_.edge_selections_available())
390 glColor(generateHighlightColor(polygon_color_));
391 glLineWidth(2*line_width_old);
393 controlEdgeSelIBO_.bind();
394 glDrawElements(GL_LINES, 2 * controlEdgeSelCount_, GL_UNSIGNED_INT, 0);
395 controlEdgeSelIBO_.unbind();
397 glLineWidth(line_width_old);
408 glDrawArrays(GL_LINE_STRIP, 0, bsplineCurve_.n_control_points());
418 if (controlPointSelCount_)
423 glColor(generateHighlightColor(polygon_color_));
426 controlPointSelIBO_.bind();
427 glDrawElements(GL_POINTS, controlPointSelCount_, GL_UNSIGNED_INT, 0);
428 controlPointSelIBO_.unbind();
430 glPointSize(point_size_old);
436 glPointSize(point_size_old + 4);
438 glDrawArrays(GL_POINTS, 0, bsplineCurve_.n_control_points());
440 glPointSize(point_size_old);
444 controlPointDecl_.deactivateFixedFunction();
445 controlPointVBO_.unbind();
453template <
class BSplineCurve>
465 double cylinderRadius = _state.
line_width() * 0.2;
468 if( bsplineCurve_.edge_selections_available())
470 glColor(generateHighlightColor(polygon_color_));
473 for (
int i = 0; i < (int)bsplineCurve_.n_control_points()-1; ++i)
475 if (bsplineCurve_.edge_selection(i))
477 Point p = bsplineCurve_.get_control_point(i);
478 Point axis = bsplineCurve_.get_control_point(i+1) - bsplineCurve_.get_control_point(i);
479 draw_cylinder(p, axis, cylinderRadius, _state);
488 for (
unsigned int i = 0; i < bsplineCurve_.n_control_points() - 1; ++i)
490 Point p = bsplineCurve_.get_control_point(i);
491 Point axis = bsplineCurve_.get_control_point(i+1) - bsplineCurve_.get_control_point(i);
492 draw_cylinder(p, axis, cylinderRadius, _state);
500 if (bsplineCurve_.n_control_points() == 0)
505 double sphereRadius = _state.
point_size() * 0.25;
508 if( bsplineCurve_.controlpoint_selections_available())
510 glColor(generateHighlightColor(polygon_color_));
513 for (
unsigned int i = 0; i < bsplineCurve_.n_control_points(); ++i)
514 if (bsplineCurve_.controlpoint_selection(i))
515 draw_sphere(bsplineCurve_.get_control_point(i), sphereRadius, _state, fancySphere_);
521 for (
unsigned int i = 0; i < bsplineCurve_.n_control_points(); ++i)
522 draw_sphere(bsplineCurve_.get_control_point(i), sphereRadius, _state, fancySphere_);
531template <
class BSplineCurve>
536 glPushAttrib(GL_ALL_ATTRIB_BITS);
538 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
545 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
546 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
548 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
549 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
551 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
554 draw_textured_nurbs( _state);
555 glLineWidth(line_width_old);
565template <
class BSplineCurve>
570 invalidateCurveLine_ =
true;
571 invalidateControlPointVBO_ =
true;
573 curve_samples_.clear();
575 std::pair< Vec3d, Vec4f > sample;
577 int d = bsplineCurve_.degree();
578 int k = bsplineCurve_.n_knots();
580 for (
int l = d; l < k - d - 1; ++l )
582 for (
int s = 0; s <= resolution_; ++s )
584 double step = s / (float) resolution_ ;
585 double u = bsplineCurve_.get_knot( l ) + step * ( bsplineCurve_.get_knot( l+1 ) - bsplineCurve_.get_knot( l ) );
588 if ( bsplineCurve_.get_knotvector_ref()->selections_available() )
590 if ( bsplineCurve_.get_knotvector_ref()->selection(l)
591 && bsplineCurve_.get_knotvector_ref()->selection(l+1))
592 sample.second = curve_highlight_color_;
594 sample.second = curve_color_;
597 sample.second = curve_color_;
599 sample.first = bsplineCurve_.curvePoint(u);
608template <
class BSplineCurve>
618 pick_vertices(_state);
625 pick_spline(_state, 0);
632 _state.
pick_set_maximum (bsplineCurve_.n_control_points() + pick_texture_res_);
633 pick_vertices(_state);
634 pick_spline(_state, bsplineCurve_.n_control_points());
647template <
class BSplineCurve>
657 for (
unsigned int i = 0; i < bsplineCurve_.n_control_points(); ++i)
663 int px = round( window_pos[0]);
664 int py = round( window_pos[1]);
666 double l = (_state.
eye() - (
Vec3d)bsplineCurve_.get_control_point(i)).norm();
667 double r = l*tan(angle);
670 draw_sphere(bsplineCurve_.get_control_point(i), r, _state, sphere_);
676template <
class BSplineCurve >
678BSplineCurveNodeT<BSplineCurve>::
679pick_spline( GLState& _state,
unsigned int _offset )
681 glPushAttrib(GL_ALL_ATTRIB_BITS);
688 if( _state.pick_current_index () + _offset != pick_texture_baseidx_)
690 pick_texture_baseidx_ = _state.pick_current_index() + _offset;
691 pick_create_texture( _state);
696 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
697 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
699 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
700 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
702 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
708 float line_width_old = _state.line_width();
710 draw_textured_nurbs( _state);
711 glLineWidth(line_width_old);
725template <
class BSplineCurve>
727BSplineCurveNodeT<BSplineCurve>::
728draw_sphere(
const Point& _p0,
double _r, GLState& _state, GLSphere* _sphere)
731 _state.push_modelview_matrix();
732 _state.translate( _p0[0], _p0[1], _p0[2]);
734 _sphere->draw(_state,_r);
736 _state.pop_modelview_matrix();
741template <
class BSplineCurve>
743BSplineCurveNodeT<BSplineCurve>::
744draw_cylinder(
const Point& _p0,
const Point& _axis,
double _r, GLState& _state)
746 _state.push_modelview_matrix();
747 _state.translate(_p0[0], _p0[1], _p0[2]);
749 Point direction = _axis;
754 direction.normalize();
755 rot_angle = acos((z_axis | direction))*180/M_PI;
756 rot_normal = ((z_axis % direction).normalize());
759 if( fabs( rot_angle ) > 0.0001 && fabs( 180 - rot_angle ) > 0.0001)
760 _state.rotate(rot_angle,rot_normal[0], rot_normal[1], rot_normal[2]);
762 _state.rotate(rot_angle,1,0,0);
764 cylinder_->setBottomRadius(_r);
765 cylinder_->setTopRadius(_r);
766 cylinder_->draw(_state,_axis.norm());
768 _state.pop_modelview_matrix();
773template <
class BSplineCurve>
775BSplineCurveNodeT<BSplineCurve>::
776updateControlPointSelectionTexture(GLState& _state)
778 create_cp_selection_texture(_state);
779 controlPointSelectionTexture_valid_ =
true;
782 invalidateControlPointSelIBO_ =
true;
787template <
class BSplineCurve>
789BSplineCurveNodeT<BSplineCurve>::
790updateKnotVectorSelectionTexture(GLState& _state)
792 create_knot_selection_texture(_state);
793 knotVectorSelectionTexture_valid_ =
true;
798template <
class BSplineCurve>
804 glGenTextures( 1, &_texture_idx );
808 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
809 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
811 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
812 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
814 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
821template <
class BSplineCurve>
826 if (bsplineCurve_.n_knots() == 0)
829 if(cp_selection_texture_idx_ == 0)
830 selection_init_texturing(cp_selection_texture_idx_);
832 QImage b(cp_selection_texture_res_, 2, QImage::Format_ARGB32);
834 int degree = bsplineCurve_.degree();
835 int numKnots = bsplineCurve_.n_knots();
837 double minu = bsplineCurve_.get_knot( degree );
838 double maxu = bsplineCurve_.get_knot( numKnots - degree -1 );
839 double diffu = maxu - minu;
840 if (diffu == 0.0)
return;
845 Vec4f curveColor = curve_color_;
846 Vec4f highlightColor = curve_highlight_color_;
850 for (
int m = 0; m < cp_selection_texture_res_; ++m)
852 double step_m = (double)m / (
double)cp_selection_texture_res_;
853 double u = step_m * diffu;
858 if (span[0] < 0 || span[1] < 0)
862 for (
int i = 0; i < degree+1; ++i)
864 int idx = span[0] + i;
867 if (bsplineCurve_.controlpoint_selected(idx))
868 alpha += bsplineCurve_.basisFunction(idx, degree, u);
872 Vec4f color = curveColor * (1.0 - alpha) + highlightColor * alpha;
875 b.setPixel (texelIdx, 0, qRgba((
int)(color[0]*255.0), (
int)(color[1]*255.0), (
int)(color[2]*255.0), 255));
876 b.setPixel (texelIdx, 1, qRgba((
int)(color[0]*255.0), (
int)(color[1]*255.0), (
int)(color[2]*255.0), 255));
884 cp_selection_texture_image_ = ACG::Util::convertToGLFormat( b );
888 glTexImage2D( GL_TEXTURE_2D,
889 0, GL_RGBA, cp_selection_texture_image_.width(), cp_selection_texture_image_.height(),
890 0, GL_RGBA, GL_UNSIGNED_BYTE, cp_selection_texture_image_.bits() );
895template <
class BSplineCurve>
900 if (bsplineCurve_.n_knots() == 0)
903 if(knot_selection_texture_idx_ == 0)
904 selection_init_texturing(knot_selection_texture_idx_);
906 QImage b(knot_selection_texture_res_, 2, QImage::Format_ARGB32);
908 int degree = bsplineCurve_.degree();
909 int numKnots = bsplineCurve_.n_knots();
911 double minu = bsplineCurve_.get_knot( degree );
912 double maxu = bsplineCurve_.get_knot( numKnots - degree -1 );
913 double diffu = maxu - minu;
914 if (diffu == 0.0)
return;
919 std::vector<bool> selectedKnotSpans(numKnots,
false);
920 for (
int i = 0; i < numKnots; ++i)
922 if (bsplineCurve_.get_knotvector_ref()->selection(i))
925 ACG::Vec2i span = bsplineCurve_.span(bsplineCurve_.get_knot(i));
927 if (span[0] < 0 || span[1] < 0)
930 for(
int j = span[0]; j <= span[1]+degree; ++j)
931 selectedKnotSpans[j] =
true;
937 Vec4f curveColor = curve_color_;
938 Vec4f highlightColor = curve_highlight_color_;
940 for (
int m = 0; m < knot_selection_texture_res_; ++m)
942 double step_m = (double)m / (
double)knot_selection_texture_res_;
943 double u = step_m * diffu;
946 Vec2i interval = bsplineCurve_.interval(u);
948 if (selectedKnotSpans[interval[0]] && selectedKnotSpans[interval[1]])
949 color = highlightColor;
954 b.setPixel (texelIdx, 0, qRgba((
int)(color[0]*255.0), (
int)(color[1]*255.0), (
int)(color[2]*255.0), 255));
955 b.setPixel (texelIdx, 1, qRgba((
int)(color[0]*255.0), (
int)(color[1]*255.0), (
int)(color[2]*255.0), 255));
963 knot_selection_texture_image_ = ACG::Util::convertToGLFormat( b );
967 glTexImage2D( GL_TEXTURE_2D,
968 0, GL_RGBA, knot_selection_texture_image_.width(), knot_selection_texture_image_.height(),
969 0, GL_RGBA, GL_UNSIGNED_BYTE, knot_selection_texture_image_.bits() );
974template <
class BSplineCurve>
979 pick_texture_res_ = 256;
980 pick_texture_baseidx_ = 0;
983 glGenTextures( 1, &pick_texture_idx_ );
987 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
988 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
990 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
991 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
993 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
1000template <
class BSplineCurve>
1005 if(pick_texture_idx_ == 0)
1006 pick_init_texturing();
1008 QImage b(pick_texture_res_, 2, QImage::Format_ARGB32);
1012 for(
int i = 0; i < pick_texture_res_; ++i)
1015 b.setPixel (i, 0, qRgba((
int)cur_col[0], (
int)cur_col[1], (
int)cur_col[2], (
int)cur_col[3]));
1016 b.setPixel (i, 1, qRgba((
int)cur_col[0], (
int)cur_col[1], (
int)cur_col[2], (
int)cur_col[3]));
1049 pick_texture_image_ = ACG::Util::convertToGLFormat( b );
1053 glTexImage2D( GL_TEXTURE_2D,
1054 0, GL_RGBA, pick_texture_image_.width(), pick_texture_image_.height(),
1055 0, GL_RGBA, GL_UNSIGNED_BYTE, pick_texture_image_.bits() );
1060template <
class BSplineCurve>
1065 updateCurveBuffer();
1067 curveLineVBO_.bind();
1068 curveLineDecl_.activateFixedFunction();
1070 glDrawArrays(GL_LINE_STRIP, 0, curveLineVertices_);
1072 curveLineDecl_.deactivateFixedFunction();
1073 curveLineVBO_.unbind();
1078template <
class BSplineCurve>
1083 if (!invalidateCurveLine_)
1087 if (!curveLineDecl_.getNumElements())
1096 std::vector<float> vboData(_numVertices * 4);
1098 for (
int i = 0; i < _numVertices; ++i)
1101 typename BSplineCurve::Scalar u01 =
typename BSplineCurve::Scalar(i) /
typename BSplineCurve::Scalar(_numVertices - 1);
1104 typename BSplineCurve::Scalar u = (1 - u01) * bsplineCurve_.lower() + u01 * bsplineCurve_.upper();
1107 typename BSplineCurve::Point pos = bsplineCurve_.curvePoint(u);
1110 for (
int k = 0; k < 3; ++k)
1111 vboData[i*4 + k] = pos[k];
1114 vboData[i*4 + 3] = u01;
1118 curveLineVBO_.del();
1120 curveLineVBO_.upload(vboData.size() * 4, &vboData[0], GL_STATIC_DRAW);
1123 curveLineVertices_ = _numVertices;
1125 invalidateCurveLine_ =
false;
1130template <
class BSplineCurve>
1135 if (!invalidateControlPointVBO_)
1139 if (!controlPointDecl_.getNumElements())
1142 int numCP = bsplineCurve_.n_control_points();
1146 std::vector<float> vboData(numCP * 3);
1148 for (
int i = 0; i < numCP; ++i)
1150 typename BSplineCurve::Point pos = bsplineCurve_.get_control_point(i);
1151 for (
int k = 0; k < 3; ++k)
1152 vboData[i*3 + k] = pos[k];
1155 controlPointVBO_.del();
1157 controlPointVBO_.upload(vboData.size() * 4, &vboData[0], GL_STATIC_DRAW);
1159 invalidateControlPointVBO_ =
false;
1164template <
class BSplineCurve>
1169 if (!invalidateControlPointSelIBO_)
1172 controlPointSelIBO_.del();
1174 if (bsplineCurve_.controlpoint_selections_available())
1176 int numCP = bsplineCurve_.n_control_points();
1180 for (
int i = 0; i < numCP; ++i)
1182 if (bsplineCurve_.controlpoint_selection(i))
1187 controlPointSelCount_ = numSel;
1193 std::vector<int> iboData(numSel);
1195 for (
int i = 0; i < numCP; ++i)
1197 if (bsplineCurve_.controlpoint_selection(i))
1198 iboData[numSel++] = i;
1201 controlPointSelIBO_.upload(numSel * 4, &iboData[0], GL_STATIC_DRAW);
1205 invalidateControlPointSelIBO_ =
false;
1210template <
class BSplineCurve>
1215 if (!invalidateControlEdgeSelIBO_)
1218 controlEdgeSelIBO_.del();
1220 if (bsplineCurve_.edge_selections_available())
1222 int numCP = bsplineCurve_.n_control_points();
1223 int numE = numCP - 1;
1227 for (
int i = 0; i < numE; ++i)
1229 if (bsplineCurve_.edge_selection(i))
1234 controlEdgeSelCount_ = numSel;
1239 std::vector<int> iboData(numSel * 2);
1241 for (
int i = 0; i < numE; ++i)
1243 if (bsplineCurve_.edge_selection(i))
1245 iboData[numSel++] = i;
1246 iboData[numSel++] = (i+1)%numCP;
1250 controlEdgeSelIBO_.upload(numSel * 4, &iboData[0], GL_STATIC_DRAW);
1254 invalidateControlEdgeSelIBO_ =
false;
Vec3d eye() const
get eye point
Vec4uc pick_get_name_color(size_t _idx)
static void enable(GLenum _cap, bool _warnRemoved=true)
replaces glEnable, but supports locking
static void bindTexture(GLenum _target, GLuint _buffer)
replaces glBindTexture, supports locking
int viewport_width() const
get viewport width
void pick_set_name(size_t _idx)
sets the current name/color (like glLoadName(_idx))
Vec3d viewing_direction() const
get viewing ray
const Vec4f & base_color() const
get base color (used when lighting is off)
bool pick_set_maximum(size_t _idx)
Set the maximal number of primitives/components of your object.
Vec3d project(const Vec3d &_point) const
project point in world coordinates to window coordinates
static void disable(GLenum _cap, bool _warnRemoved=true)
replaces glDisable, but supports locking
int viewport_height() const
get viewport height
float line_width() const
get line width
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
float point_size() const
get point size
virtual void addRenderObject(RenderObject *_renderObject)
Callback for the scenegraph nodes, which send new render objects via this function.
void updateControlEdgeSelBuffer()
update control edge selection buffer for visualization
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.
DrawModes::DrawMode availableDrawModes() const override
return available draw modes
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
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.
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
void push_back(BaseNode *_node)
Insert _node at the end of the list of children.
DrawModeProperties stores a set of properties that defines, how to render an object.
const DrawModeProperties * getLayer(unsigned int _i) const
returns the property set at layer i
size_t getNumLayers() const
returns the layer count
void clearTextures()
disables texture support and removes all texture types
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
auto normalize() -> decltype(*this/=std::declval< VectorT< S, DIM > >().norm())
DrawMode WIREFRAME
draw wireframe
DrawMode POINTS
draw unlighted points using the default base color
PickTarget
What target to use for picking.
@ PICK_ANYTHING
pick any of the prior targets (should be implemented for all nodes)
@ PICK_SPLINE
Pick spline curve or surface (picks u or u,v coords respectively)
@ PICK_VERTEX
picks verices (may not be implemented for all nodes)
Namespace providing different geometric functions concerning angles.
void glColor(const Vec3f &_v)
Wrapper: glColor for Vec3f.
VectorT< float, 4 > Vec4f
VectorT< float, 2 > Vec2f
@ VERTEX_USAGE_POSITION
"inPosition"
@ VERTEX_USAGE_TEXCOORD
"inTexCoord"
VectorT< double, 3 > Vec3d
Interface class between scenegraph and renderer.
ShaderGenDesc shaderDesc
Drawmode and other shader params.
void setupLineRendering(float _lineWidth, const Vec2f &_screenSize)
Setup rendering of thick lines.
const VertexDeclaration * vertexDecl
Defines the vertex buffer layout, ignored if VAO is provided.
void setupShaderGenFromDrawmode(const SceneGraph::DrawModes::DrawModeProperties *_props)
Fills out ShaderGenDesc parameters based on Drawmode properties.
void resetLineRendering()
Reset shader template names blocked by line rendering.
GLuint indexBuffer
Use vertex array object.
GLuint vertexBuffer
VBO, IBO ids, ignored if VAO is provided.
void initFromState(GLState *_glState)
Initializes a RenderObject instance.
void setupPointRendering(float _pointSize, const Vec2f &_screenSize)
Setup rendering of circle points.