53#ifndef ACG_BSPLINESURFACENODET_HH
54#define ACG_BSPLINESURFACENODET_HH
59#include <ACG/Scenegraph/BaseNode.hh>
60#include <ACG/Scenegraph/DrawModes.hh>
65#include <ACG/GL/globjects.hh>
66#include <ACG/GL/VertexDeclaration.hh>
67#include <ACG/GL/GLPrimitives.hh>
85template <
class BSplineSurfaceType>
91 typedef typename BSplineSurfaceType::Point Point;
96 std::string _name=
"<BSplineSurfaceNode>" ) :
98 bsplineSurface_(_bss),
99 bspline_draw_mode_(NORMAL),
100 bspline_selection_draw_mode_(NONE),
103 controlnet_color_(
Vec4f(34.f/255.f, 139.f/255.f, 34.f/255.f, 1.f) ),
104 controlnet_highlight_color_(
Vec4f(1.0f, 1.0f, 1.0f, 1.0f) ),
105 surface_color_(
Vec4f(178.0f/255.0f, 34.0f/255.0f, 34.0f/255.0f, 1.0f) ),
106 surface_highlight_color_(
Vec4f(1.0f, 1.0f, 1.0f, 1.0f) ),
107 render_control_net_(false),
108 render_bspline_surface_(true),
109 adaptive_sampling_(false),
110 controlPointSelectionTexture_valid_(false),
111 knotVectorSelectionTexture_valid_(false),
112 pick_texture_idx_(0),
113 pick_texture_res_(256),
114 pick_texture_baseidx_(0),
115 cp_selection_texture_idx_(0),
116 cp_selection_texture_res_(256),
117 knot_selection_texture_idx_(0),
118 knot_selection_texture_res_(256),
120 arb_texture_used_(false),
121 arb_texture_repeat_(false),
122 arb_texture_repeat_u_(1.0),
123 arb_texture_repeat_v_(1.0),
124 surfaceIndexCount_(0),
125 invalidateSurfaceMesh_(true),
126 controlNetSelIndices_(0),
127 controlNetLineIndices_(0),
128 invalidateControlNetMesh_(true),
129 invalidateControlNetMeshSel_(true)
131 cylinder_ =
new GLCylinder(16, 1, 1.0f,
true,
true);
133 fancySphere_ =
new GLSphere(16, 16);
144 enum BSplineDrawMode {
149 enum BSplineSelectionDrawMode {
156 BSplineSurfaceType& bsplineSurface() {
return bsplineSurface_; }
158 void set_pick_radius(
double _pr) { pick_radius_ = _pr; }
181 void set_rendering_resolution(
int _res){resolution_ = _res;};
183 void render_control_net(
bool _render) {render_control_net_ = _render;};
185 bool render_control_net() {
return render_control_net_; };
187 void render_bspline_surface(
bool _render) {render_bspline_surface_ = _render;};
189 bool render_bspline_surface() {
return render_bspline_surface_; };
191 void set_bspline_draw_mode(BSplineDrawMode _mode) {bspline_draw_mode_ = _mode;};
193 void set_selection_draw_mode(BSplineSelectionDrawMode _mode) {bspline_selection_draw_mode_ = _mode;};
195 BSplineSelectionDrawMode get_selection_draw_mode()
const {
return bspline_selection_draw_mode_; }
197 void adaptive_sampling(
bool _adaptive){adaptive_sampling_ = _adaptive;};
199 void cpSelectionTextureValid (
bool _valid){controlPointSelectionTexture_valid_ = _valid;};
200 void knotSelectionTextureValid(
bool _valid){knotVectorSelectionTexture_valid_ = _valid;};
207 void set_arb_texture(
const QImage& _texture,
bool _repeat =
false,
float _u_repeat = 1.0f,
float _v_repeat = 1.0f);
208 void set_arb_texture(
const GLuint _texture) { arb_texture_idx_ = _texture; }
209 void set_repeat_arb_texture(
bool _repeat =
true,
float _urep = 5.0f,
float _vrep = 5.0f) { arb_texture_repeat_ = _repeat; arb_texture_repeat_u_ = _urep; arb_texture_repeat_v_ = _vrep; }
210 bool get_repeat_arb_texture( ) {
return arb_texture_repeat_; }
216 void pick_vertices( GLState& _state );
217 void pick_spline( GLState& _state );
218 void pick_surface( GLState& _state,
unsigned int _offset );
220 void draw_cylinder(
const Point& _p0,
const Point& _axis,
double _r, GLState& _state);
221 void draw_sphere (
const Point& _p0,
double _r, GLState& _state, GLSphere* _sphere);
229 void render(
GLState& _state,
bool _fill);
231 void drawSurface(
GLState& _state,
bool _fill =
true);
233 void drawTexturedSurface(
GLState& _state, GLuint _texture_idx);
235 void drawControlNet(
GLState& _state);
237 void drawFancyControlNet(
GLState& _state);
239 void updateControlPointSelectionTexture(
GLState& _state);
241 void updateKnotVectorSelectionTexture(
GLState& _state);
281 BSplineDrawMode bspline_draw_mode_;
283 BSplineSelectionDrawMode bspline_selection_draw_mode_;
289 Vec4f controlnet_color_;
290 Vec4f controlnet_highlight_color_;
292 Vec4f surface_color_;
293 Vec4f surface_highlight_color_;
295 bool render_control_net_;
296 bool render_bspline_surface_;
298 bool adaptive_sampling_;
300 bool controlPointSelectionTexture_valid_;
301 bool knotVectorSelectionTexture_valid_;
303 QImage pick_texture_image_;
304 GLuint pick_texture_idx_;
305 int pick_texture_res_;
307 unsigned int pick_texture_baseidx_;
310 QImage cp_selection_texture_image_;
311 GLuint cp_selection_texture_idx_;
312 int cp_selection_texture_res_;
315 QImage knot_selection_texture_image_;
316 GLuint knot_selection_texture_idx_;
317 int knot_selection_texture_res_;
320 QImage arb_texture_image_;
321 GLuint arb_texture_idx_;
322 bool arb_texture_used_;
323 bool arb_texture_repeat_;
324 float arb_texture_repeat_u_;
325 float arb_texture_repeat_v_;
333 GeometryBuffer surfaceVBO_;
334 IndexBuffer surfaceIBO_;
336 int surfaceIndexCount_;
337 bool invalidateSurfaceMesh_;
340 GeometryBuffer controlNetVBO_;
341 IndexBuffer controlNetSelIBO_;
342 int controlNetSelIndices_;
343 IndexBuffer controlNetLineIBO_;
344 int controlNetLineIndices_;
346 bool invalidateControlNetMesh_;
347 bool invalidateControlNetMeshSel_;
359#if defined(INCLUDE_TEMPLATES) && !defined(ACG_BSPLINESURFACENODET_C)
360#define ACG_BSPLINESURFACENODET_TEMPLATES
361#include "BSplineSurfaceNodeT_impl.hh"
void pick_draw_textured_nurbs(GLState &_state)
draw textured nurbs patch
void create_cp_selection_texture(GLState &_state)
creates texture to put onto nurbs curve for visualization of control point selection
BSplineSurfaceNodeT(const BSplineSurfaceNodeT &_rhs)
Copy constructor (not used)
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax) override
update bounding box
DrawModes::DrawMode availableDrawModes() const override
return available draw modes
void updateControlNetMeshSel()
update index buffer of selected control points
void getRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat) override
create render objects
void updateSurfaceMesh(int _vertexCountU=50, int _vertexCountV=50)
update vertex + index buffer of surface mesh
void set_arb_texture(const QImage &_texture, bool _repeat=false, float _u_repeat=1.0f, float _v_repeat=1.0f)
use arbitrary texture (in SOLID_TEXTURED mode)
void draw_textured_nurbs(GLState &_state)
draw textured nurbs patch
void updateTexBuffers()
update texture resources for gpu-based spline evaluation
~BSplineSurfaceNodeT()
Destructor.
void updateGeometry()
update vertex buffer for rendering
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode) override
draw lines and normals
void pick_init_texturing()
generate index and setup texture parameters
void pick(GLState &_state, PickTarget _target) override
picking
BSplineSurfaceNodeT & operator=(const BSplineSurfaceNodeT &_rhs)
Assignment operator (not used)
ACG_CLASSNAME(BSplineSurfaceNodeT)
static name of this class
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 updateControlNetMesh()
update vertex + index buffer of control net mesh
int & pick_texture_res()
Should be a power of 2.
BSplineSurfaceNodeT(BSplineSurfaceType &_bss, BaseNode *_parent=0, std::string _name="<BSplineSurfaceNode>")
Constructor.
void selection_init_texturing(GLuint &_texture_idx)
generate index and setup texture parameters for selection visualization
Class to define the vertex input layout.
PickTarget
What target to use for picking.
Namespace providing different geometric functions concerning angles.