diff --git a/panda/src/parametrics/Sources.pp b/panda/src/parametrics/Sources.pp index 5dbe09a7d8..704616e47e 100644 --- a/panda/src/parametrics/Sources.pp +++ b/panda/src/parametrics/Sources.pp @@ -4,17 +4,15 @@ #begin lib_target #define TARGET parametrics #define LOCAL_LIBS \ - pgraph grutil linmath express putil pandabase + pgraph linmath express putil pandabase #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx #define SOURCES \ config_parametrics.h \ - cubicCurveseg.h parametricCurveDrawer.I \ - parametricCurveDrawer.h curveFitter.I curveFitter.h \ + cubicCurveseg.h curveFitter.I curveFitter.h \ hermiteCurve.h \ nurbsCurve.I nurbsCurve.h \ - nurbsCurveDrawer.I nurbsCurveDrawer.h \ nurbsCurveEvaluator.I nurbsCurveEvaluator.h \ nurbsCurveInterface.I nurbsCurveInterface.h \ nurbsCurveResult.I nurbsCurveResult.h \ @@ -30,9 +28,8 @@ #define INCLUDED_SOURCES \ config_parametrics.cxx cubicCurveseg.cxx \ - parametricCurveDrawer.cxx curveFitter.cxx hermiteCurve.cxx \ + curveFitter.cxx hermiteCurve.cxx \ nurbsCurve.cxx \ - nurbsCurveDrawer.cxx \ nurbsCurveEvaluator.cxx \ nurbsCurveInterface.cxx \ nurbsCurveResult.cxx \ @@ -48,11 +45,9 @@ #define INSTALL_HEADERS \ config_parametrics.h \ cubicCurveseg.h \ - parametricCurveDrawer.I parametricCurveDrawer.h \ curveFitter.I curveFitter.h \ hermiteCurve.h \ nurbsCurve.I nurbsCurve.h \ - nurbsCurveDrawer.I nurbsCurveDrawer.h \ nurbsCurveEvaluator.I nurbsCurveEvaluator.h \ nurbsCurveInterface.I nurbsCurveInterface.h \ nurbsCurveResult.I nurbsCurveResult.h \ diff --git a/panda/src/parametrics/config_parametrics.cxx b/panda/src/parametrics/config_parametrics.cxx index 2cf5c037da..b679a2b3ad 100644 --- a/panda/src/parametrics/config_parametrics.cxx +++ b/panda/src/parametrics/config_parametrics.cxx @@ -21,10 +21,8 @@ #include "cubicCurveseg.h" #include "curveFitter.h" #include "hermiteCurve.h" -#include "nurbsCurveDrawer.h" #include "nurbsCurveInterface.h" #include "parametricCurve.h" -#include "parametricCurveDrawer.h" #include "piecewiseCurve.h" #include "ropeNode.h" #include "sheetNode.h" @@ -37,10 +35,8 @@ ConfigureFn(config_parametrics) { CubicCurveseg::init_type(); CurveFitter::init_type(); HermiteCurve::init_type(); - NurbsCurveDrawer::init_type(); NurbsCurveInterface::init_type(); ParametricCurve::init_type(); - ParametricCurveDrawer::init_type(); PiecewiseCurve::init_type(); RopeNode::init_type(); SheetNode::init_type(); diff --git a/panda/src/parametrics/nurbsCurveDrawer.I b/panda/src/parametrics/nurbsCurveDrawer.I deleted file mode 100644 index 5ae146b534..0000000000 --- a/panda/src/parametrics/nurbsCurveDrawer.I +++ /dev/null @@ -1,31 +0,0 @@ -// Filename: nurbsCurveDrawer.I -// Created by: drose (05Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::hilight -// Access: Published -// Description: Hilights a particular CV by showing it and its knot -// in a different color. Returns true if the CV exists -// and has been drawn, false otherwise. -//////////////////////////////////////////////////////////////////// -INLINE bool NurbsCurveDrawer:: -hilight(int n) { - return hilight(n, 1.0f, 1.0f, 0.0f); -} - diff --git a/panda/src/parametrics/nurbsCurveDrawer.cxx b/panda/src/parametrics/nurbsCurveDrawer.cxx deleted file mode 100644 index 49435d5e65..0000000000 --- a/panda/src/parametrics/nurbsCurveDrawer.cxx +++ /dev/null @@ -1,296 +0,0 @@ -// Filename: nurbsCurveDrawer.cxx -// Created by: drose (27Feb98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -#include "nurbsCurveDrawer.h" -#include "nurbsCurveInterface.h" -#include "parametricCurve.h" - - -TypeHandle NurbsCurveDrawer::_type_handle; - - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -NurbsCurveDrawer:: -NurbsCurveDrawer() { - set_cv_color(1.0f, 0.0f, 0.0f); - set_hull_color(1.0f, 0.5, 0.5); - set_knot_color(0.0f, 0.0f, 1.0f); - - _cvs.set_thickness(4.0f); - _hull.set_thickness(1.0f); - _knots.set_thickness(4.0f); - - _show_cvs = true; - _show_hull = true; - _show_knots = true; -} - - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -NurbsCurveDrawer:: -~NurbsCurveDrawer() { -} - - - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::set_cv_color -// Access: Published -// Description: Specifies the color of the CV's. -//////////////////////////////////////////////////////////////////// -void NurbsCurveDrawer:: -set_cv_color(float r, float g, float b) { - _cv_color.set(r, g, b); - _cvs.set_color(r, g, b); - - redraw(); -} - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::set_knot_color -// Access: Published -// Description: Specifies the color of the knots. -//////////////////////////////////////////////////////////////////// -void NurbsCurveDrawer:: -set_knot_color(float r, float g, float b) { - _knot_color.set(r, g, b); - _knots.set_color(r, g, b); - - redraw(); -} - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::set_hull_color -// Access: Published -// Description: Specifies the color of the convex hull. -//////////////////////////////////////////////////////////////////// -void NurbsCurveDrawer:: -set_hull_color(float r, float g, float b) { - _hull_color.set(r, g, b); - _hull.set_color(r, g, b); - - redraw(); -} - - - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::draw -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -bool NurbsCurveDrawer:: -draw() { - // First, draw the curve itself. - if (!ParametricCurveDrawer::draw()) { - return false; - } - - ParametricCurve *curve = (ParametricCurve *)NULL; - NurbsCurveInterface *nurbs = (NurbsCurveInterface *)NULL; - - if (_curves != (ParametricCurveCollection *)NULL) { - curve = _curves->get_default_curve(); - - if (curve != (ParametricCurve *)NULL) { - nurbs = curve->get_nurbs_interface(); - } - } - - if (nurbs == (NurbsCurveInterface *)NULL) { - // The rest of this depends on having an actual NURBS curve. - return true; - } - - int i; - if (_show_knots) { - _num_cvs = nurbs->get_num_cvs(); - _knotnums.erase(_knotnums.begin(), _knotnums.end()); - - float lt = -1.0f; - int ki = -1; - for (i = 0; i < _num_cvs; i++) { - float t = nurbs->get_knot(i); - if (t != lt) { - lt = t; - LVecBase3f knot_pos; - curve->get_point(nurbs->get_knot(i), knot_pos); - _knots.move_to(knot_pos); - ki++; - } - _knotnums.push_back(ki); - } - - _knots.create(_geom_node, _frame_accurate); - } - - if (_show_cvs) { - _num_cvs = nurbs->get_num_cvs(); - for (i = 0; i < _num_cvs; i++) { - _cvs.move_to(nurbs->get_cv_point(i)); - } - - _cvs.create(_geom_node, _frame_accurate); - } - - if (_show_hull) { - _num_cvs = nurbs->get_num_cvs(); - for (i = 0; i < _num_cvs; i++) { - _hull.draw_to(nurbs->get_cv_point(i)); - } - - _hull.create(_geom_node, _frame_accurate); - } - - return true; -} - - - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::recompute -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -bool NurbsCurveDrawer:: -recompute(float t1, float t2, ParametricCurve *curve) { - return draw(); -} - - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::set_show_cvs -// Access: Published -// Description: Sets the flag that hides or shows the CV's. -//////////////////////////////////////////////////////////////////// -void NurbsCurveDrawer:: -set_show_cvs(bool flag) { - _show_cvs = flag; - redraw(); -} - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::get_show_cvs -// Access: Published -// Description: Returns the current state of the show-CV's flag. -//////////////////////////////////////////////////////////////////// -bool NurbsCurveDrawer:: -get_show_cvs() const { - return _show_cvs; -} - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::set_show_hull -// Access: Published -// Description: Sets the flag that hides or shows the convex hull. -//////////////////////////////////////////////////////////////////// -void NurbsCurveDrawer:: -set_show_hull(bool flag) { - _show_hull = flag; - redraw(); -} - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::get_show_hull -// Access: Published -// Description: Returns the current state of the show-hull flag. -//////////////////////////////////////////////////////////////////// -bool NurbsCurveDrawer:: -get_show_hull() const { - return _show_hull; -} - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::set_show_knots -// Access: Published -// Description: Sets the flag that hides or shows the knots. -//////////////////////////////////////////////////////////////////// -void NurbsCurveDrawer:: -set_show_knots(bool flag) { - _show_knots = flag; - redraw(); -} - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::get_show_knots -// Access: Published -// Description: Returns the current state of the show-knots flag. -//////////////////////////////////////////////////////////////////// -bool NurbsCurveDrawer:: -get_show_knots() const { - return _show_knots; -} - - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::hilight -// Access: Published -// Description: Hilights a particular CV by showing it and its knot -// in a different color. Returns true if the CV exists -// and has been drawn, false otherwise. -//////////////////////////////////////////////////////////////////// -bool NurbsCurveDrawer:: -hilight(int n, float hr, float hg, float hb) { - if (n < 0 || n >= _cvs.get_num_vertices()) { - // Return false if we're out of range. - return false; - } - - if (_show_cvs) { - _cvs.set_vertex_color(n, hr, hg, hb); - } - if (_show_knots) { - nassertr(_knotnums[n] >= 0 && _knotnums[n] < _knots.get_num_vertices(), false); - _knots.set_vertex_color(_knotnums[n], hr, hg, hb); - } - - return true; -} - - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveDrawer::unhilight -// Access: Published -// Description: Removes the hilight previously set on a CV. -//////////////////////////////////////////////////////////////////// -bool NurbsCurveDrawer:: -unhilight(int n) { - if (n < 0 || n >= _cvs.get_num_vertices()) { - return false; - } - - if (_show_cvs) { - _cvs.set_vertex_color(n, _cv_color[0], _cv_color[1], _cv_color[2]); - } - if (_show_knots) { - nassertr(_knotnums[n] >= 0 && _knotnums[n] < _knots.get_num_vertices(), false); - _knots.set_vertex_color(_knotnums[n], - _knot_color[0], _knot_color[1], _knot_color[2]); - } - - return true; -} - diff --git a/panda/src/parametrics/nurbsCurveDrawer.h b/panda/src/parametrics/nurbsCurveDrawer.h deleted file mode 100644 index de630e6167..0000000000 --- a/panda/src/parametrics/nurbsCurveDrawer.h +++ /dev/null @@ -1,88 +0,0 @@ -// Filename: nurbsCurveDrawer.h -// Created by: drose (27Feb98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -#ifndef NURBSCURVEDRAWER_H -#define NURBSCURVEDRAWER_H - -#include "pandabase.h" - -#include "parametricCurveDrawer.h" -#include "lineSegs.h" -#include "vector_int.h" - - -//////////////////////////////////////////////////////////////////// -// Class : NurbsCurveDrawer -// Description : Draws a Nurbs curve, also drawing in the control -// vertices and tangent vectors. -//////////////////////////////////////////////////////////////////// -class EXPCL_PANDA NurbsCurveDrawer : public ParametricCurveDrawer { -PUBLISHED: - NurbsCurveDrawer(); - virtual ~NurbsCurveDrawer(); - - void set_cv_color(float r, float g, float b); - void set_hull_color(float r, float g, float b); - void set_knot_color(float r, float g, float b); - - virtual bool draw(); - virtual bool recompute(float t1, float t2, ParametricCurve *curve=NULL); - - void set_show_cvs(bool flag); - bool get_show_cvs() const; - void set_show_hull(bool flag); - bool get_show_hull() const; - void set_show_knots(bool flag); - bool get_show_knots() const; - - INLINE bool hilight(int n); - bool hilight(int n, float hr, float hg, float hb); - bool unhilight(int n); - -protected: - LVecBase3f _cv_color, _hull_color, _knot_color; - int _num_cvs, _num_hull, _num_knots; - LineSegs _hull, _knots, _cvs; - vector_int _knotnums; - - bool _show_cvs, _show_hull, _show_knots; - - -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - ParametricCurveDrawer::init_type(); - register_type(_type_handle, "NurbsCurveDrawer", - ParametricCurveDrawer::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - -private: - static TypeHandle _type_handle; -}; - -#include "nurbsCurveDrawer.I" - -#endif - - diff --git a/panda/src/parametrics/parametricCurve.cxx b/panda/src/parametrics/parametricCurve.cxx index 3a80334311..292cd8daee 100644 --- a/panda/src/parametrics/parametricCurve.cxx +++ b/panda/src/parametrics/parametricCurve.cxx @@ -20,7 +20,6 @@ #include "config_parametrics.h" #include "hermiteCurve.h" #include "nurbsCurve.h" -#include "parametricCurveDrawer.h" #include "datagram.h" #include "datagramIterator.h" @@ -682,12 +681,14 @@ invalidate(float, float) { //////////////////////////////////////////////////////////////////// void ParametricCurve:: invalidate_all() { + /* DrawerList::iterator n; for (n = _drawers.begin(); n != _drawers.end(); ++n) { (*n)->redraw(); } + */ } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/parametrics/parametricCurveCollection.cxx b/panda/src/parametrics/parametricCurveCollection.cxx index 406b2e4510..806446e292 100644 --- a/panda/src/parametrics/parametricCurveCollection.cxx +++ b/panda/src/parametrics/parametricCurveCollection.cxx @@ -19,7 +19,6 @@ #include "parametricCurveCollection.h" #include "config_parametrics.h" #include "curveFitter.h" -#include "parametricCurveDrawer.h" #include "nurbsCurve.h" #include "indent.h" @@ -982,9 +981,11 @@ prepare_remove_curve(ParametricCurve *curve) { //////////////////////////////////////////////////////////////////// void ParametricCurveCollection:: redraw() { + /* DrawerList::iterator di; for (di = _drawers.begin(); di != _drawers.end(); ++di) { ParametricCurveDrawer *drawer = (*di); drawer->redraw(); } + */ } diff --git a/panda/src/parametrics/parametricCurveDrawer.I b/panda/src/parametrics/parametricCurveDrawer.I deleted file mode 100644 index dab1145b9f..0000000000 --- a/panda/src/parametrics/parametricCurveDrawer.I +++ /dev/null @@ -1,44 +0,0 @@ -// Filename: parametricCurveDrawer.I -// Created by: drose (04Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::get_max_t -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE float ParametricCurveDrawer:: -get_max_t() const { - if (_curves == (ParametricCurveCollection *)NULL) { - return 0.0f; - } else { - return _curves->get_max_t(); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::redraw -// Access: Public -// Description: Redraws the curve if it is currently visible. -//////////////////////////////////////////////////////////////////// -INLINE void ParametricCurveDrawer:: -redraw() { - if (_drawn) { - draw(); - } -} diff --git a/panda/src/parametrics/parametricCurveDrawer.cxx b/panda/src/parametrics/parametricCurveDrawer.cxx deleted file mode 100644 index c276b4ab2d..0000000000 --- a/panda/src/parametrics/parametricCurveDrawer.cxx +++ /dev/null @@ -1,440 +0,0 @@ -// Filename: parametricCurveDrawer.cxx -// Created by: drose (14Mar97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - - -#include "parametricCurveDrawer.h" -#include "parametricCurve.h" -#include "config_parametrics.h" - -TypeHandle ParametricCurveDrawer::_type_handle; - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -ParametricCurveDrawer:: -ParametricCurveDrawer() { - _lines.set_color(1.0f, 1.0f, 1.0f); - _ticks.set_color(1.0f, 0.0f, 0.0f); - _tick_scale = 0.1; - _num_segs = 100.0; - _num_ticks = 0.0f; - _frame_accurate = false; - _geom_node = new GeomNode("pcd"); - _drawn = false; -} - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -ParametricCurveDrawer:: -~ParametricCurveDrawer() { - hide(); - - // Unregister all the curves. - clear_curves(); -} - - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::set_curve -// Access: Published -// Description: Sets the drawer up to draw just the one curve. -//////////////////////////////////////////////////////////////////// -void ParametricCurveDrawer:: -set_curve(ParametricCurve *curve) { - PT(ParametricCurveCollection) curves = new ParametricCurveCollection(); - curves->add_curve(curve); - set_curves(curves); -} - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::set_curves -// Access: Published -// Description: Sets the drawer up to draw the curves in the -// indicated collection. The drawer will actually draw -// just the first XYZ curve in the collection, but if -// one or more timewarps are present, this will affect -// the placement of tick marks. -//////////////////////////////////////////////////////////////////// -void ParametricCurveDrawer:: -set_curves(ParametricCurveCollection *curves) { - if (curves != _curves) { - // First, unregister the old curves. - if (_curves != (ParametricCurveCollection *)NULL) { - _curves->unregister_drawer(this); - } - - _curves = curves; - - // Now, register the new ones. - if (_curves != (ParametricCurveCollection *)NULL) { - _curves->register_drawer(this); - } - - redraw(); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::clear_curves -// Access: Published -// Description: Empties the list of curves the drawer will update. -// It will draw nothing. -//////////////////////////////////////////////////////////////////// -void ParametricCurveDrawer:: -clear_curves() { - set_curves((ParametricCurveCollection *)NULL); -} - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::get_curves -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -ParametricCurveCollection *ParametricCurveDrawer:: -get_curves() { - return _curves; -} - - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::get_geom_node -// Access: Published -// Description: Returns a pointer to the drawer's GeomNode. This is -// where the drawer will build the visible -// representation of the curve. This GeomNode must be -// inserted into the scene graph to make the curve -// visible. The GeomNode remains connected to the drawer, -// so that future updates to the drawer will reflect in -// the GeomNode, and the GeomNode will be emptied when the -// drawer destructs. Also see detach_geom_node(). -//////////////////////////////////////////////////////////////////// -GeomNode *ParametricCurveDrawer:: -get_geom_node() { - return _geom_node; -} - - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::detach_geom_node -// Access: Published -// Description: Detaches the GeomNode from the drawer so that the -// drawing will remain after the death of the drawer. -// Returns the now-static GeomNode. A new, dynamic GeomNode -// is created for the drawer's future use; get_geom_node() -// will return this new GeomNode which will be empty until -// the next call to draw(). -//////////////////////////////////////////////////////////////////// -PT(GeomNode) ParametricCurveDrawer:: -detach_geom_node() { - if (!_drawn) { - draw(); - } - PT(GeomNode) g = _geom_node; - _geom_node = new GeomNode("pcd"); - _drawn = false; - return g; -} - - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::set_num_segs -// Access: Published -// Description: Specifies the number of line segments used to -// approximate the curve for each parametric unit. This -// just affects the visual appearance of the curve as it -// is drawn. The total number of segments drawn for the -// curve will be get_max_t() * get_num_segs(). -//////////////////////////////////////////////////////////////////// -void ParametricCurveDrawer:: -set_num_segs(float num_segs) { - _num_segs = num_segs; - redraw(); -} - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::get_num_segs -// Access: Published -// Description: Returns the number of line segments used to -// approximate the curve for each parametric unit. This -// just affects the visual appearance of the curve as it -// is drawn. The total number of segments drawn for the -// curve will be get_max_t() * get_num_segs(). -//////////////////////////////////////////////////////////////////// -float ParametricCurveDrawer:: -get_num_segs() const { - return _num_segs; -} - - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::set_num_ticks -// Access: Published -// Description: Specifies the number of time tick marks drawn -// for each unit of time. These tick marks are drawn at -// equal increments in time to give a visual -// approximation of speed. Specify 0 to disable drawing -// of tick marks. -//////////////////////////////////////////////////////////////////// -void ParametricCurveDrawer:: -set_num_ticks(float num_ticks) { - _num_ticks = num_ticks; - redraw(); -} - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::get_num_ticks -// Access: Published -// Description: Returns the number of time tick marks per unit of -// time drawn. -//////////////////////////////////////////////////////////////////// -float ParametricCurveDrawer:: -get_num_ticks() const { - return _num_ticks; -} - - - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::set_color -// Access: Published -// Description: Specifies the color of the curve when it is drawn. -// The default is white. -//////////////////////////////////////////////////////////////////// -void ParametricCurveDrawer:: -set_color(float r, float g, float b) { - _lines.set_color(r, g, b); - redraw(); -} - - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::set_color -// Access: Published -// Description: Specifies the color of the time tick marks drawn on -// the curve. The default is red. -//////////////////////////////////////////////////////////////////// -void ParametricCurveDrawer:: -set_tick_color(float r, float g, float b) { - _ticks.set_color(r, g, b); - redraw(); -} - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::set_thickness -// Access: Public -// Description: Specifies the thickness of the line in pixels drawn -// to represent the curve. Note that pixel thickness of -// a line segment is not supported by DirectX. -//////////////////////////////////////////////////////////////////// -void ParametricCurveDrawer:: -set_thickness(float thick) { - _lines.set_thickness(thick); - redraw(); -} - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::set_frame_accurate -// Access: Published -// Description: Specifies whether the curve drawn is to be -// frame-accurate. If true, then changes made to the -// curve dynamically after it has been drawn will be -// reflected correctly in the render window. If false, -// dynamic updates may be drawn before the rest of the -// scene has updated. -//////////////////////////////////////////////////////////////////// -void ParametricCurveDrawer:: -set_frame_accurate(bool frame_accurate) { - _frame_accurate = frame_accurate; - redraw(); -} - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::get_frame_accurate -// Access: Published -// Description: Returns whether the curve is drawn in frame-accurate -// mode. -//////////////////////////////////////////////////////////////////// -bool ParametricCurveDrawer:: -get_frame_accurate() const { - return _frame_accurate; -} - - - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::draw -// Access: Published, Virtual -// Description: Creates a series of line segments that approximates -// the curve. These line segments may be made visible -// by parenting the node returned by get_geom_node() -// into the scene graph. -//////////////////////////////////////////////////////////////////// -bool ParametricCurveDrawer:: -draw() { - // First, remove the old drawing, if any. - hide(); - - _drawn = true; - - // If there's no curve, draw nothing and return false. - if (_curves == (ParametricCurveCollection *)NULL) { - return false; - } - - ParametricCurve *xyz_curve = _curves->get_default_curve(); - if (xyz_curve == (ParametricCurve *)NULL) { - return false; - } - - // Otherwise, let's go to town! - - // Make sure the curve(s) are fresh. - _curves->recompute(); - - int total_segs = (int)cfloor(_curves->get_max_t() * _num_segs + 0.5); - - float max_t = xyz_curve->get_max_t(); - float scale = max_t / (float)(total_segs-1); - float t; - LVecBase3f point; - bool last_in, next_in; - - last_in = false; - int i; - - for (i = 0; i < total_segs; i++) { - t = (float)i * scale; - - next_in = xyz_curve->get_point(t, point); - - if (!next_in || !last_in) { - _lines.move_to(point); - } else { - _lines.draw_to(point); - } - last_in = next_in; - } - - _lines.create(_geom_node, _frame_accurate); - - max_t = get_max_t(); - scale = max_t / (float)(total_segs-1); - - // Now draw the time tick marks. - if (_num_ticks > 0.0f) { - int total_ticks = (int)cfloor(max_t * _num_ticks + 0.5); - ParametricCurve *xyz_curve = _curves->get_default_curve(); - // ParametricCurve *hpr_curve = _curves->get_hpr_curve(); - - scale = max_t / (float)total_ticks; - - for (i = 0; i <= total_ticks; i++) { - t = (float)i * scale; - float t0 = _curves->evaluate_t(t); - LVecBase3f tangent; - - if (xyz_curve->get_pt(t0, point, tangent)) { - // Draw crosses. - LVecBase3f t1, t2; - get_tick_marks(tangent, t1, t2); - - _ticks.move_to(point - t1 * _tick_scale); - _ticks.draw_to(point + t1 * _tick_scale); - _ticks.move_to(point - t2 * _tick_scale); - _ticks.draw_to(point + t2 * _tick_scale); - } - } - _ticks.create(_geom_node, _frame_accurate); - } - - return true; -} - - - - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::hide -// Access: Published -// Description: Removes the lines that were created by a previous -// call to draw(). -//////////////////////////////////////////////////////////////////// -void ParametricCurveDrawer:: -hide() { - _geom_node->remove_all_geoms(); - _drawn = false; -} - - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::set_tick_scale -// Access: Published -// Description: Sets the visible size of the time tick marks or -// geometry. -//////////////////////////////////////////////////////////////////// -void ParametricCurveDrawer:: -set_tick_scale(float scale) { - _tick_scale = scale; - redraw(); -} - - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::get_tick_scale -// Access: Published -// Description: Returns the size of the time tick marks or geometry. -//////////////////////////////////////////////////////////////////// -float ParametricCurveDrawer:: -get_tick_scale() const { - return _tick_scale; -} - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveDrawer::get_tick_marks -// Access: Private, Static -// Description: Given a tangent vector, computes two vectors at right -// angles to the tangent and to each other, suitable for -// drawing as tick marks. -//////////////////////////////////////////////////////////////////// -void ParametricCurveDrawer:: -get_tick_marks(const LVecBase3f &tangent, LVecBase3f &t1, LVecBase3f &t2) { - LVector3f tn = tangent; - tn.normalize(); - - // Decide the smallest axis of tn and cross with the corresponding - // unit vector. - if (fabs(tn[0]) <= fabs(tn[1]) && fabs(tn[0]) <= fabs(tn[2])) { - // X is smallest. - t1 = tn.cross(LVector3f(1.0f, 0.0f, 0.0f)); - - } else if (fabs(tn[1]) <= fabs(tn[2])) { - // Y is smallest. - t1 = tn.cross(LVector3f(0.0f, 1.0f, 0.0f)); - - } else { - // Z is smallest. - t1 = tn.cross(LVector3f(0.0f, 0.0f, 1.0f)); - } - - t2 = tn.cross(t1); -} diff --git a/panda/src/parametrics/parametricCurveDrawer.h b/panda/src/parametrics/parametricCurveDrawer.h deleted file mode 100644 index 7f8832cd00..0000000000 --- a/panda/src/parametrics/parametricCurveDrawer.h +++ /dev/null @@ -1,105 +0,0 @@ -// Filename: parametricCurveDrawer.h -// Created by: drose (14Mar97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -#ifndef PARAMETRICCURVEDRAWER_H -#define PARAMETRICCURVEDRAWER_H - -#include "parametricCurveCollection.h" - -#include "lineSegs.h" -#include "pandaNode.h" - -#include "typedObject.h" - -//////////////////////////////////////////////////////////////////// -// Class : ParametricCurveDrawer -// Description : Draws a 3-d parametric curve in the scene by creating -// a series of line segments to approximate the curve. -//////////////////////////////////////////////////////////////////// -class EXPCL_PANDA ParametricCurveDrawer : public TypedObject { -PUBLISHED: - ParametricCurveDrawer(); - virtual ~ParametricCurveDrawer(); - - void set_curve(ParametricCurve *curve); - void set_curves(ParametricCurveCollection *curves); - void clear_curves(); - ParametricCurveCollection *get_curves(); - - GeomNode *get_geom_node(); - PT(GeomNode) detach_geom_node(); - - void set_num_segs(float num_segs); - float get_num_segs() const; - - void set_num_ticks(float num_ticks); - float get_num_ticks() const; - - void set_color(float r, float g, float b); - void set_tick_color(float r, float g, float b); - - void set_thickness(float thick); - - void set_frame_accurate(bool frame_accurate); - bool get_frame_accurate() const; - - virtual bool draw(); - void hide(); - - void set_tick_scale(float scale); - float get_tick_scale() const; - -public: - INLINE float get_max_t() const; - INLINE void redraw(); - -private: - static void get_tick_marks(const LVecBase3f &tangent, LVecBase3f &t1, LVecBase3f &t2); - -protected: - PT(GeomNode) _geom_node; - PT(ParametricCurveCollection) _curves; - bool _frame_accurate; - -private: - float _num_segs; - LineSegs _lines, _ticks; - bool _drawn; - float _num_ticks; - float _tick_scale; - -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - register_type(_type_handle, "ParametricCurveDrawer", - TypedObject::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - -private: - static TypeHandle _type_handle; -}; - -#include "parametricCurveDrawer.I" - -#endif diff --git a/panda/src/parametrics/parametrics_composite1.cxx b/panda/src/parametrics/parametrics_composite1.cxx index c9e755fd80..38c990f860 100644 --- a/panda/src/parametrics/parametrics_composite1.cxx +++ b/panda/src/parametrics/parametrics_composite1.cxx @@ -2,5 +2,4 @@ #include "cubicCurveseg.cxx" #include "curveFitter.cxx" #include "hermiteCurve.cxx" -#include "nurbsCurveDrawer.cxx" #include "nurbsCurveInterface.cxx" diff --git a/panda/src/parametrics/parametrics_composite2.cxx b/panda/src/parametrics/parametrics_composite2.cxx index 68cd45c912..b4cfb235bf 100644 --- a/panda/src/parametrics/parametrics_composite2.cxx +++ b/panda/src/parametrics/parametrics_composite2.cxx @@ -2,7 +2,6 @@ #include "piecewiseCurve.cxx" #include "parametricCurve.cxx" #include "parametricCurveCollection.cxx" -#include "parametricCurveDrawer.cxx" #include "nurbsCurveEvaluator.cxx" #include "nurbsCurveResult.cxx" #include "nurbsSurfaceEvaluator.cxx"