Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/parametrics/piecewiseCurve.h

Go to the documentation of this file.
00001 // Filename: piecewiseCurve.h
00002 // Created by:  drose (04Mar01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef PIECEWISECURVE_H
00020 #define PIECEWISECURVE_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "parametricCurve.h"
00025 #include "pointerTo.h"
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //       Class : PiecewiseCurve
00029 // Description : A PiecewiseCurve is a curve made up of several curve
00030 //               segments, connected in a head-to-tail fashion.  The
00031 //               length of each curve segment in parametric space is
00032 //               definable.
00033 ////////////////////////////////////////////////////////////////////
00034 class EXPCL_PANDA PiecewiseCurve : public ParametricCurve {
00035 PUBLISHED:
00036   PiecewiseCurve();
00037   ~PiecewiseCurve();
00038 
00039 public:
00040   // These functions are all inherited from ParametricCurve, and need
00041   // not be re-published.
00042   virtual bool is_valid() const;
00043   virtual float get_max_t() const;
00044 
00045   virtual bool get_point(float t, LVecBase3f &point) const;
00046   virtual bool get_tangent(float t, LVecBase3f &tangent) const;
00047   virtual bool get_pt(float t, LVecBase3f &point, LVecBase3f &tangent) const;
00048   virtual bool get_2ndtangent(float t, LVecBase3f &tangent2) const;
00049 
00050   virtual bool adjust_point(float t, float px, float py, float pz);
00051   virtual bool adjust_tangent(float t, float tx, float ty, float tz);
00052   virtual bool adjust_pt(float t,
00053                          float px, float py, float pz,
00054                          float tx, float ty, float tz);
00055 
00056 public:
00057   int get_num_segs() const;
00058 
00059   ParametricCurve *get_curveseg(int ti);
00060   bool insert_curveseg(int ti, ParametricCurve *seg, float tlength);
00061 
00062   bool remove_curveseg(int ti);
00063   void remove_all_curvesegs();
00064 
00065   float get_tlength(int ti) const;
00066   float get_tstart(int ti) const;
00067   float get_tend(int ti) const;
00068   bool set_tlength(int ti, float tlength);
00069 
00070   void make_nurbs(int order, int num_cvs,
00071                   const float knots[], const LVecBase4f cvs[]);
00072 
00073   virtual bool get_bezier_segs(BezierSegs &bz_segs) const;
00074 
00075   virtual bool
00076   rebuild_curveseg(int rtype0, float t0, const LVecBase4f &v0,
00077                    int rtype1, float t1, const LVecBase4f &v1,
00078                    int rtype2, float t2, const LVecBase4f &v2,
00079                    int rtype3, float t3, const LVecBase4f &v3);
00080 
00081 protected:
00082   bool find_curve(const ParametricCurve *&curve, float &t) const;
00083   float current_seg_range(float t) const;
00084 
00085   class Curveseg {
00086   public:
00087     Curveseg() {}
00088     Curveseg(ParametricCurve *c, float t) : _curve(c), _tend(t) {}
00089 
00090     PT(ParametricCurve) _curve;
00091     float _tend;
00092   };
00093 
00094   pvector<Curveseg> _segs;
00095   int _last_ti;
00096 
00097 
00098 // TypedWritable stuff
00099 protected:
00100   virtual void write_datagram(BamWriter *manager, Datagram &me);
00101   void fillin(DatagramIterator &scan, BamReader *manager);
00102   virtual int complete_pointers(TypedWritable **plist,
00103                                 BamReader *manager);
00104 
00105 public:
00106   static TypeHandle get_class_type() {
00107     return _type_handle;
00108   }
00109   static void init_type() {
00110     ParametricCurve::init_type();
00111     register_type(_type_handle, "PiecewiseCurve",
00112                   ParametricCurve::get_class_type());
00113   }
00114   virtual TypeHandle get_type() const {
00115     return get_class_type();
00116   }
00117   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00118 
00119 private:
00120   static TypeHandle _type_handle;
00121 };
00122 
00123 
00124 #endif

Generated on Fri May 2 00:40:52 2003 for Panda by doxygen1.3