Commit dd43f7c4 authored by Isaak Lim's avatar Isaak Lim
Browse files

introduced GLSphere* and GLCylinder* as members in BSplineSurfaceNode so that...

introduced GLSphere* and GLCylinder* as members in BSplineSurfaceNode so that the VBO does not get generated and uploaded at every draw call

refs #285

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13515 383ad7c9-94d9-4d36-a494-682f7c89f535
parent b9ff3081
......@@ -582,7 +582,7 @@ drawFancyControlNet(GLState& _state)
for (unsigned int j = 0; j < bsplineSurface_.n_control_points_n(); ++j)
{
if( bsplineSurface_.controlpoint_selection(i, j))
draw_sphere(bsplineSurface_(i, j), sphereRadius, _state, 16, 16);
draw_sphere(bsplineSurface_(i, j), sphereRadius, _state, fancySphere_);
}
}
......@@ -594,7 +594,7 @@ drawFancyControlNet(GLState& _state)
for (unsigned int i = 0; i < bsplineSurface_.n_control_points_m(); ++i)
for (unsigned int j = 0; j < bsplineSurface_.n_control_points_n(); ++j)
draw_sphere(bsplineSurface_(i, j), sphereRadius, _state, 16, 16);
draw_sphere(bsplineSurface_(i, j), sphereRadius, _state, fancySphere_);
// draw line segments
......@@ -708,7 +708,7 @@ pick_vertices( GLState& _state )
double r = l*tan(angle);
// draw 3d sphere
draw_sphere( bsplineSurface_(i,j), r, _state);
draw_sphere( bsplineSurface_(i,j), r, _state, sphere_);
}
}
}
......@@ -782,14 +782,13 @@ pick_surface( GLState& _state, unsigned int _offset )
template <class BSplineSurfaceType>
void
BSplineSurfaceNodeT<BSplineSurfaceType>::
draw_sphere( const Point& _p0, double _r, GLState& _state, unsigned int _slices, unsigned int _stacks)
draw_sphere( const Point& _p0, double _r, GLState& _state, GLSphere* _sphere)
{
// draw 3d sphere
_state.push_modelview_matrix();
_state.translate( _p0[0], _p0[1], _p0[2]);
GLSphere sphere(_slices,_stacks);
sphere.draw(_state,_r);
_sphere->draw(_state,_r);
_state.pop_modelview_matrix();
}
......@@ -799,7 +798,7 @@ draw_sphere( const Point& _p0, double _r, GLState& _state, unsigned int _slices,
template <class BSplineSurfaceType>
void
BSplineSurfaceNodeT<BSplineSurfaceType>::
draw_cylinder( const Point& _p0, const Point& _axis, double _r, GLState& _state, unsigned int _slices, unsigned int _stacks)
draw_cylinder( const Point& _p0, const Point& _axis, double _r, GLState& _state)
{
_state.push_modelview_matrix();
_state.translate(_p0[0], _p0[1], _p0[2]);
......@@ -818,8 +817,9 @@ draw_cylinder( const Point& _p0, const Point& _axis, double _r, GLState& _state,
else
_state.rotate(rot_angle,1,0,0);
GLCylinder cylinder(_slices,_stacks,_r,true,true);
cylinder.draw(_state,_axis.norm());
cylinder_->setBottomRadius(_r);
cylinder_->setTopRadius(_r);
cylinder_->draw(_state,_axis.norm());
_state.pop_modelview_matrix();
}
......
......@@ -111,10 +111,24 @@ class BSplineSurfaceNodeT : public BaseNode
knot_selection_texture_idx_ = 0;
pick_texture_idx_ = 0;
arb_texture_idx_ = 0;
cylinder_ = new GLCylinder(16, 1, 1.0f, true, true);
sphere_ = new GLSphere(5, 5);
fancySphere_ = new GLSphere(16, 16);
}
/// Destructor
~BSplineSurfaceNodeT() {}
~BSplineSurfaceNodeT()
{
if (cylinder_)
delete cylinder_;
if (sphere_)
delete sphere_;
if (fancySphere_)
delete fancySphere_;
}
enum BSplineDrawMode {
NORMAL = 0,
......@@ -184,8 +198,8 @@ private:
void pick_spline( GLState& _state );
void pick_surface( GLState& _state, unsigned int _offset );
void draw_cylinder( const Point& _p0, const Point& _axis, double _r, GLState& _state, unsigned int _slices = 16, unsigned int _stacks = 1);
void draw_sphere ( const Point& _p0, double _r, GLState& _state, unsigned int _slices = 5, unsigned int _stacks = 5);
void draw_cylinder( const Point& _p0, const Point& _axis, double _r, GLState& _state);
void draw_sphere ( const Point& _p0, double _r, GLState& _state, GLSphere* _sphere);
/// Copy constructor (not used)
BSplineSurfaceNodeT(const BSplineSurfaceNodeT& _rhs);
......@@ -279,6 +293,9 @@ private:
float arb_texture_repeat_u_;
float arb_texture_repeat_v_;
GLCylinder* cylinder_;
GLSphere* sphere_;
GLSphere* fancySphere_;
};
//=============================================================================
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment