Commit 3069bcaa authored by Jan Möbius's avatar Jan Möbius
Browse files

Use glstate in polyLineNode

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5376 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 66442e88
......@@ -218,6 +218,8 @@ pick_vertices( GLState& _state )
{
// radius in pixels
int psize = 7;
unsigned int slices(4);
unsigned int stacks(3);
_state.pick_set_maximum (polyline_.n_vertices());
_state.pick_set_name (0);
......@@ -235,7 +237,14 @@ pick_vertices( GLState& _state )
double r = l*tan(angle);
// draw 3d sphere
draw_sphere( polyline_.point(i), r);
_state.push_modelview_matrix();
_state.translate(polyline_.point(i)[0], polyline_.point(i)[1], polyline_.point(i)[2]);
GLUquadricObj *qobj = gluNewQuadric();
gluSphere(qobj, r, slices, stacks);
gluDeleteQuadric(qobj);
_state.pop_modelview_matrix();
}
}
......@@ -279,7 +288,7 @@ pick_edges( GLState& _state, unsigned int _offset)
double r = l*tan(angle);
// draw cylinder
draw_cylinder( p0, p1-p0, r);
draw_cylinder( p0, p1-p0, r, _state);
}
}
......@@ -290,10 +299,10 @@ pick_edges( GLState& _state, unsigned int _offset)
template <class PolyLine>
void
PolyLineNodeT<PolyLine>::
draw_cylinder( const Point& _p0, const Point& _axis, double _r)
draw_cylinder( const Point& _p0, const Point& _axis, double _r, GLState& _state)
{
glPushMatrix();
glTranslated( _p0[0], _p0[1], _p0[2]);
_state.push_modelview_matrix();
_state.translate(_p0[0], _p0[1], _p0[2]);
unsigned int slices(6);
unsigned int stacks(1);
......@@ -308,48 +317,18 @@ draw_cylinder( const Point& _p0, const Point& _axis, double _r)
rot_normal = ((z_axis % direction).normalize());
if(fabs(rot_angle) > 0.0001 && fabs(180-rot_angle) > 0.0001)
glRotatef(rot_angle,rot_normal[0], rot_normal[1], rot_normal[2]);
if( fabs( rot_angle ) > 0.0001 && fabs( 180 - rot_angle ) > 0.0001)
_state.rotate(rot_angle,rot_normal[0], rot_normal[1], rot_normal[2]);
else
glRotatef(rot_angle,1,0,0);
GLUquadricObj *qobj;
qobj = gluNewQuadric();
// gluQuadricDrawStyle(qobj, GLU_FILL);
// gluQuadricNormals(qobj, GLU_SMOOTH);
_state.rotate(rot_angle,1,0,0);
GLUquadricObj *qobj = gluNewQuadric();
gluCylinder(qobj, _r, _r, _axis.norm(), slices, stacks);
glPopMatrix();
}
//----------------------------------------------------------------------------
gluDeleteQuadric(qobj);
template <class PolyLine>
void
PolyLineNodeT<PolyLine>::
draw_sphere( const Point& _p0, double _r)
{
glPushMatrix();
glTranslated( _p0[0], _p0[1], _p0[2]);
unsigned int slices(4);
unsigned int stacks(3);
GLUquadricObj *qobj;
qobj = gluNewQuadric();
// gluQuadricDrawStyle(qobj, GLU_FILL);
// gluQuadricNormals(qobj, GLU_NONE);
gluSphere(qobj, _r, slices, stacks);
glPopMatrix();
_state.pop_modelview_matrix();
}
//----------------------------------------------------------------------------
......
......@@ -12,12 +12,12 @@
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
......@@ -61,11 +61,11 @@ namespace SceneGraph {
/** \class PolyLineNodeT PolyLineNodeT.hh <ACG/.../PolyLineNodeT.hh>
Brief Description.
A more elaborate description follows.
*/
......@@ -73,7 +73,7 @@ template <class PolyLine>
class PolyLineNodeT : public MaterialNode
{
public:
// typedefs for easy access
typedef typename PolyLine::Point Point;
......@@ -81,9 +81,9 @@ public:
PolyLineNodeT(PolyLine& _pl,
BaseNode* _parent=0,
std::string _name="<PolyLineNode>" ) :
MaterialNode(_parent,
_name,
MaterialNode::BaseColor |
MaterialNode(_parent,
_name,
MaterialNode::BaseColor |
MaterialNode::LineWidth |
MaterialNode::PointSize |
MaterialNode::RoundPoints),
......@@ -95,7 +95,7 @@ public:
set_round_points(true);
set_random_color();
}
/// Destructor
~PolyLineNodeT() {}
......@@ -118,15 +118,14 @@ public:
/// picking
void pick(GLState& _state, PickTarget _target);
private:
void pick_vertices( GLState& _state );
void pick_edges( GLState& _state, unsigned int _offset);
void draw_cylinder( const Point& _p0, const Point& _axis, double _r);
void draw_sphere ( const Point& _p0, double _r);
void draw_cylinder( const Point& _p0, const Point& _axis, double _r, GLState& _state);
/// Copy constructor (not used)
......@@ -134,7 +133,7 @@ private:
/// Assignment operator (not used)
PolyLineNodeT& operator=(const PolyLineNodeT& _rhs);
private:
PolyLine& polyline_;
......
Markdown is supported
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