59 #ifndef ACG_BSPLINESURFACENODET_HH 60 #define ACG_BSPLINESURFACENODET_HH 65 #include <ACG/Scenegraph/BaseNode.hh> 66 #include <ACG/Scenegraph/DrawModes.hh> 73 #include <ACG/GL/globjects.hh> 74 #include <ACG/GL/VertexDeclaration.hh> 92 template <
class BSplineSurfaceType>
98 typedef typename BSplineSurfaceType::Point Point;
103 std::string _name=
"<BSplineSurfaceNode>" ) :
105 bsplineSurface_(_bss),
106 bspline_draw_mode_(NORMAL),
107 bspline_selection_draw_mode_(NONE),
110 controlnet_color_(
Vec4f(34.f/255.f, 139.f/255.f, 34.f/255.f, 1.f) ),
111 controlnet_highlight_color_(
Vec4f(1.0f, 1.0f, 1.0f, 1.0f) ),
112 surface_color_(
Vec4f(178.0f/255.0f, 34.0f/255.0f, 34.0f/255.0f, 1.0f) ),
113 surface_highlight_color_(
Vec4f(1.0f, 1.0f, 1.0f, 1.0f) ),
114 render_control_net_(false),
115 render_bspline_surface_(true),
116 adaptive_sampling_(false),
117 controlPointSelectionTexture_valid_(false),
118 knotVectorSelectionTexture_valid_(false),
119 pick_texture_idx_(0),
120 pick_texture_res_(256),
121 pick_texture_baseidx_(0),
122 cp_selection_texture_idx_(0),
123 cp_selection_texture_res_(256),
124 knot_selection_texture_idx_(0),
125 knot_selection_texture_res_(256),
127 arb_texture_used_(false),
128 arb_texture_repeat_(false),
129 arb_texture_repeat_u_(1.0),
130 arb_texture_repeat_v_(1.0),
131 surfaceIndexCount_(0),
132 invalidateSurfaceMesh_(true),
133 controlNetSelIndices_(0),
134 controlNetLineIndices_(0),
135 invalidateControlNetMesh_(true),
136 invalidateControlNetMeshSel_(true)
138 cylinder_ =
new GLCylinder(16, 1, 1.0f,
true,
true);
140 fancySphere_ =
new GLSphere(16, 16);
151 enum BSplineDrawMode {
156 enum BSplineSelectionDrawMode {
163 BSplineSurfaceType& bsplineSurface() {
return bsplineSurface_; }
165 void set_pick_radius(
double _pr) { pick_radius_ = _pr; }
188 void set_rendering_resolution(
int _res){resolution_ = _res;};
190 void render_control_net(
bool _render) {render_control_net_ = _render;};
192 bool render_control_net() {
return render_control_net_; };
194 void render_bspline_surface(
bool _render) {render_bspline_surface_ = _render;};
196 bool render_bspline_surface() {
return render_bspline_surface_; };
198 void set_bspline_draw_mode(BSplineDrawMode _mode) {bspline_draw_mode_ = _mode;};
200 void set_selection_draw_mode(BSplineSelectionDrawMode _mode) {bspline_selection_draw_mode_ = _mode;};
202 BSplineSelectionDrawMode get_selection_draw_mode()
const {
return bspline_selection_draw_mode_; }
204 void adaptive_sampling(
bool _adaptive){adaptive_sampling_ = _adaptive;};
206 void cpSelectionTextureValid (
bool _valid){controlPointSelectionTexture_valid_ = _valid;};
207 void knotSelectionTextureValid(
bool _valid){knotVectorSelectionTexture_valid_ = _valid;};
214 void set_arb_texture(
const QImage& _texture,
bool _repeat =
false,
float _u_repeat = 1.0f,
float _v_repeat = 1.0f);
215 void set_arb_texture(
const GLuint _texture) { arb_texture_idx_ = _texture; }
216 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; }
217 bool get_repeat_arb_texture( ) {
return arb_texture_repeat_; }
223 void pick_vertices(
GLState& _state );
224 void pick_spline(
GLState& _state );
225 void pick_surface(
GLState& _state,
unsigned int _offset );
227 void draw_cylinder(
const Point& _p0,
const Point& _axis,
double _r,
GLState& _state);
228 void draw_sphere (
const Point& _p0,
double _r,
GLState& _state,
GLSphere* _sphere);
236 void render(
GLState& _state,
bool _fill);
238 void drawSurface(
GLState& _state,
bool _fill =
true);
240 void drawTexturedSurface(
GLState& _state, GLuint _texture_idx);
242 void drawControlNet(
GLState& _state);
244 void drawFancyControlNet(
GLState& _state);
246 void updateControlPointSelectionTexture(
GLState& _state);
248 void updateKnotVectorSelectionTexture(
GLState& _state);
288 BSplineDrawMode bspline_draw_mode_;
290 BSplineSelectionDrawMode bspline_selection_draw_mode_;
296 Vec4f controlnet_color_;
297 Vec4f controlnet_highlight_color_;
299 Vec4f surface_color_;
300 Vec4f surface_highlight_color_;
302 bool render_control_net_;
303 bool render_bspline_surface_;
305 bool adaptive_sampling_;
307 bool controlPointSelectionTexture_valid_;
308 bool knotVectorSelectionTexture_valid_;
310 QImage pick_texture_image_;
311 GLuint pick_texture_idx_;
312 int pick_texture_res_;
314 unsigned int pick_texture_baseidx_;
317 QImage cp_selection_texture_image_;
318 GLuint cp_selection_texture_idx_;
319 int cp_selection_texture_res_;
322 QImage knot_selection_texture_image_;
323 GLuint knot_selection_texture_idx_;
324 int knot_selection_texture_res_;
327 QImage arb_texture_image_;
328 GLuint arb_texture_idx_;
329 bool arb_texture_used_;
330 bool arb_texture_repeat_;
331 float arb_texture_repeat_u_;
332 float arb_texture_repeat_v_;
340 GeometryBuffer surfaceVBO_;
341 IndexBuffer surfaceIBO_;
343 int surfaceIndexCount_;
344 bool invalidateSurfaceMesh_;
347 GeometryBuffer controlNetVBO_;
348 IndexBuffer controlNetSelIBO_;
349 int controlNetSelIndices_;
350 IndexBuffer controlNetLineIBO_;
351 int controlNetLineIndices_;
353 bool invalidateControlNetMesh_;
354 bool invalidateControlNetMeshSel_;
366 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_BSPLINESURFACENODET_C) 367 #define ACG_BSPLINESURFACENODET_TEMPLATES 368 #include "BSplineSurfaceNodeT.cc" 371 #endif // ACG_BSPLINESURFACENODET_HH defined void pick_create_texture(GLState &_state)
create texture image
BSplineSurfaceNodeT & operator=(const BSplineSurfaceNodeT &_rhs)
Assignment operator (not used)
void updateTexBuffers()
update texture resources for gpu-based spline evaluation
int & pick_texture_res()
Should be a power of 2.
~BSplineSurfaceNodeT()
Destructor.
void create_knot_selection_texture(GLState &_state)
creates texture to put onto nurbs curve for visualization of knotvector selection ...
Class to define the vertex input layout.
void getRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
create render objects
void pick(GLState &_state, PickTarget _target)
picking
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 pick_draw_textured_nurbs(GLState &_state)
draw textured nurbs patch
void selection_init_texturing(GLuint &_texture_idx)
generate index and setup texture parameters for selection visualization
PickTarget
What target to use for picking.
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode)
draw lines and normals
DrawModes::DrawMode availableDrawModes() const
return available draw modes
Namespace providing different geometric functions concerning angles.
void draw_textured_nurbs(GLState &_state)
draw textured nurbs patch
void updateSurfaceMesh(int _vertexCountU=50, int _vertexCountV=50)
update vertex + index buffer of surface mesh
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
void updateControlNetMeshSel()
update index buffer of selected control points
void pick_init_texturing()
generate index and setup texture parameters
void updateControlNetMesh()
update vertex + index buffer of control net mesh
void updateGeometry()
update vertex buffer for rendering
BSplineSurfaceNodeT(BSplineSurfaceType &_bss, BaseNode *_parent=0, std::string _name="<BSplineSurfaceNode>")
Constructor.
void create_cp_selection_texture(GLState &_state)
creates texture to put onto nurbs curve for visualization of control point selection ...
ACG_CLASSNAME(BSplineSurfaceNodeT)
static name of this class