53 #ifndef ACG_BSPLINESURFACENODET_HH 54 #define ACG_BSPLINESURFACENODET_HH 59 #include <ACG/Scenegraph/BaseNode.hh> 60 #include <ACG/Scenegraph/DrawModes.hh> 67 #include <ACG/GL/globjects.hh> 68 #include <ACG/GL/VertexDeclaration.hh> 69 #include <ACG/GL/GLPrimitives.hh> 87 template <
class BSplineSurfaceType>
93 typedef typename BSplineSurfaceType::Point Point;
98 std::string _name=
"<BSplineSurfaceNode>" ) :
100 bsplineSurface_(_bss),
101 bspline_draw_mode_(NORMAL),
102 bspline_selection_draw_mode_(NONE),
105 controlnet_color_(
Vec4f(34.f/255.f, 139.f/255.f, 34.f/255.f, 1.f) ),
106 controlnet_highlight_color_(
Vec4f(1.0f, 1.0f, 1.0f, 1.0f) ),
107 surface_color_(
Vec4f(178.0f/255.0f, 34.0f/255.0f, 34.0f/255.0f, 1.0f) ),
108 surface_highlight_color_(
Vec4f(1.0f, 1.0f, 1.0f, 1.0f) ),
109 render_control_net_(false),
110 render_bspline_surface_(true),
111 adaptive_sampling_(false),
112 controlPointSelectionTexture_valid_(false),
113 knotVectorSelectionTexture_valid_(false),
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),
122 arb_texture_used_(false),
123 arb_texture_repeat_(false),
124 arb_texture_repeat_u_(1.0),
125 arb_texture_repeat_v_(1.0),
126 surfaceIndexCount_(0),
127 invalidateSurfaceMesh_(true),
128 controlNetSelIndices_(0),
129 controlNetLineIndices_(0),
130 invalidateControlNetMesh_(true),
131 invalidateControlNetMeshSel_(true)
133 cylinder_ =
new GLCylinder(16, 1, 1.0f,
true,
true);
135 fancySphere_ =
new GLSphere(16, 16);
146 enum BSplineDrawMode {
151 enum BSplineSelectionDrawMode {
158 BSplineSurfaceType& bsplineSurface() {
return bsplineSurface_; }
160 void set_pick_radius(
double _pr) { pick_radius_ = _pr; }
183 void set_rendering_resolution(
int _res){resolution_ = _res;};
185 void render_control_net(
bool _render) {render_control_net_ = _render;};
187 bool render_control_net() {
return render_control_net_; };
189 void render_bspline_surface(
bool _render) {render_bspline_surface_ = _render;};
191 bool render_bspline_surface() {
return render_bspline_surface_; };
193 void set_bspline_draw_mode(BSplineDrawMode _mode) {bspline_draw_mode_ = _mode;};
195 void set_selection_draw_mode(BSplineSelectionDrawMode _mode) {bspline_selection_draw_mode_ = _mode;};
197 BSplineSelectionDrawMode get_selection_draw_mode()
const {
return bspline_selection_draw_mode_; }
199 void adaptive_sampling(
bool _adaptive){adaptive_sampling_ = _adaptive;};
201 void cpSelectionTextureValid (
bool _valid){controlPointSelectionTexture_valid_ = _valid;};
202 void knotSelectionTextureValid(
bool _valid){knotVectorSelectionTexture_valid_ = _valid;};
209 void set_arb_texture(
const QImage& _texture,
bool _repeat =
false,
float _u_repeat = 1.0f,
float _v_repeat = 1.0f);
210 void set_arb_texture(
const GLuint _texture) { arb_texture_idx_ = _texture; }
211 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; }
212 bool get_repeat_arb_texture( ) {
return arb_texture_repeat_; }
218 void pick_vertices(
GLState& _state );
219 void pick_spline(
GLState& _state );
220 void pick_surface(
GLState& _state,
unsigned int _offset );
222 void draw_cylinder(
const Point& _p0,
const Point& _axis,
double _r,
GLState& _state);
223 void draw_sphere (
const Point& _p0,
double _r,
GLState& _state,
GLSphere* _sphere);
231 void render(
GLState& _state,
bool _fill);
233 void drawSurface(
GLState& _state,
bool _fill =
true);
235 void drawTexturedSurface(
GLState& _state, GLuint _texture_idx);
237 void drawControlNet(
GLState& _state);
239 void drawFancyControlNet(
GLState& _state);
241 void updateControlPointSelectionTexture(
GLState& _state);
243 void updateKnotVectorSelectionTexture(
GLState& _state);
283 BSplineDrawMode bspline_draw_mode_;
285 BSplineSelectionDrawMode bspline_selection_draw_mode_;
291 Vec4f controlnet_color_;
292 Vec4f controlnet_highlight_color_;
294 Vec4f surface_color_;
295 Vec4f surface_highlight_color_;
297 bool render_control_net_;
298 bool render_bspline_surface_;
300 bool adaptive_sampling_;
302 bool controlPointSelectionTexture_valid_;
303 bool knotVectorSelectionTexture_valid_;
305 QImage pick_texture_image_;
306 GLuint pick_texture_idx_;
307 int pick_texture_res_;
309 unsigned int pick_texture_baseidx_;
312 QImage cp_selection_texture_image_;
313 GLuint cp_selection_texture_idx_;
314 int cp_selection_texture_res_;
317 QImage knot_selection_texture_image_;
318 GLuint knot_selection_texture_idx_;
319 int knot_selection_texture_res_;
322 QImage arb_texture_image_;
323 GLuint arb_texture_idx_;
324 bool arb_texture_used_;
325 bool arb_texture_repeat_;
326 float arb_texture_repeat_u_;
327 float arb_texture_repeat_v_;
335 GeometryBuffer surfaceVBO_;
336 IndexBuffer surfaceIBO_;
338 int surfaceIndexCount_;
339 bool invalidateSurfaceMesh_;
342 GeometryBuffer controlNetVBO_;
343 IndexBuffer controlNetSelIBO_;
344 int controlNetSelIndices_;
345 IndexBuffer controlNetLineIBO_;
346 int controlNetLineIndices_;
348 bool invalidateControlNetMesh_;
349 bool invalidateControlNetMeshSel_;
361 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_BSPLINESURFACENODET_C) 362 #define ACG_BSPLINESURFACENODET_TEMPLATES 363 #include "BSplineSurfaceNodeT_impl.hh" 366 #endif // ACG_BSPLINESURFACENODET_HH defined void pick_init_texturing()
generate index and setup texture parameters
void draw_textured_nurbs(GLState &_state)
draw textured nurbs patch
DrawModes::DrawMode availableDrawModes() const override
return available draw modes
Namespace providing different geometric functions concerning angles.
void updateTexBuffers()
update texture resources for gpu-based spline evaluation
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax) override
update bounding box
int & pick_texture_res()
Should be a power of 2.
void updateControlNetMesh()
update vertex + index buffer of control net mesh
Class to define the vertex input layout.
void create_knot_selection_texture(GLState &_state)
creates texture to put onto nurbs curve for visualization of knotvector selection ...
void pick(GLState &_state, PickTarget _target) override
picking
void updateGeometry()
update vertex buffer for rendering
~BSplineSurfaceNodeT()
Destructor.
PickTarget
What target to use for picking.
BSplineSurfaceNodeT & operator=(const BSplineSurfaceNodeT &_rhs)
Assignment operator (not used)
void pick_create_texture(GLState &_state)
create texture image
ACG_CLASSNAME(BSplineSurfaceNodeT)
static name of this class
void selection_init_texturing(GLuint &_texture_idx)
generate index and setup texture parameters for selection visualization
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode) override
draw lines and normals
void create_cp_selection_texture(GLState &_state)
creates texture to put onto nurbs curve for visualization of control point selection ...
void getRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat) override
create render objects
BSplineSurfaceNodeT(BSplineSurfaceType &_bss, BaseNode *_parent=0, std::string _name="<BSplineSurfaceNode>")
Constructor.
void pick_draw_textured_nurbs(GLState &_state)
draw textured nurbs patch
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 updateControlNetMeshSel()
update index buffer of selected control points
void updateSurfaceMesh(int _vertexCountU=50, int _vertexCountV=50)
update vertex + index buffer of surface mesh