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

panda/src/parametrics/parametricCurveCollection.h

Go to the documentation of this file.
00001 // Filename: parametricCurveCollection.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 NODEPATHCOLLECTION_H
00020 #define NODEPATHCOLLECTION_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "parametricCurve.h"
00025 
00026 #include <referenceCount.h>
00027 #include <pointerTo.h>
00028 #include <luse.h>
00029 
00030 #include "pvector.h"
00031 #include "plist.h"
00032 
00033 class ParametricCurveDrawer;
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //       Class : ParametricCurveCollection
00037 // Description : This is a set of zero or more ParametricCurves, which
00038 //               may or may not be related.  If they are related, the
00039 //               set should contain no more than one XYZ curve, no
00040 //               more than one HPR curve, and zero or more Timewarp
00041 //               curves, which can then be evaluated as a unit to
00042 //               return a single transformation matrix for a given
00043 //               unit of time.
00044 ////////////////////////////////////////////////////////////////////
00045 class EXPCL_PANDA ParametricCurveCollection : public ReferenceCount {
00046 PUBLISHED:
00047   ParametricCurveCollection();
00048   INLINE ~ParametricCurveCollection();
00049 
00050   void add_curve(ParametricCurve *curve);
00051   void add_curve(ParametricCurve *curve, int index);
00052   int add_curves(PandaNode *node);
00053   bool remove_curve(ParametricCurve *curve);
00054   void remove_curve(int index);
00055   bool has_curve(ParametricCurve *curve) const;
00056   void clear();
00057   void clear_timewarps();
00058 
00059   INLINE int get_num_curves() const;
00060   INLINE ParametricCurve *get_curve(int index) const;
00061 
00062   ParametricCurve *get_xyz_curve() const;
00063   ParametricCurve *get_hpr_curve() const;
00064   ParametricCurve *get_default_curve() const;
00065   int get_num_timewarps() const;
00066   ParametricCurve *get_timewarp_curve(int n) const;
00067 
00068   INLINE float get_max_t() const;
00069 
00070   void make_even(float max_t, float segments_per_unit);
00071   void face_forward(float segments_per_unit);
00072   void reset_max_t(float max_t);
00073 
00074   bool evaluate(float t, LVecBase3f &xyz, LVecBase3f &hpr) const;
00075   bool evaluate(float t, LMatrix4f &result, CoordinateSystem cs = CS_default) const;
00076 
00077   float evaluate_t(float t) const;
00078   INLINE bool evaluate_xyz(float t, LVecBase3f &xyz) const;
00079   INLINE bool evaluate_hpr(float t, LVecBase3f &hpr) const;
00080 
00081   INLINE bool adjust_xyz(float t, float x, float y, float z);
00082   bool adjust_xyz(float t, const LVecBase3f &xyz);
00083   INLINE bool adjust_hpr(float t, float h, float p, float r);
00084   bool adjust_hpr(float t, const LVecBase3f &xyz);
00085 
00086   bool recompute();
00087 
00088   bool stitch(const ParametricCurveCollection *a,
00089               const ParametricCurveCollection *b);
00090 
00091   void output(ostream &out) const;
00092   void write(ostream &out, int indent_level = 0) const;
00093 
00094   bool write_egg(Filename filename, CoordinateSystem cs = CS_default);
00095   bool write_egg(ostream &out, const Filename &filename, CoordinateSystem cs);
00096 
00097 public:
00098   int r_add_curves(PandaNode *node);
00099   void register_drawer(ParametricCurveDrawer *drawer);
00100   void unregister_drawer(ParametricCurveDrawer *drawer);
00101 
00102 private:
00103   bool determine_hpr(float t, ParametricCurve *xyz_curve, LVecBase3f &hpr) const;
00104   void prepare_add_curve(ParametricCurve *curve);
00105   void prepare_remove_curve(ParametricCurve *curve);
00106   void redraw();
00107 
00108 private:
00109   typedef pvector< PT(ParametricCurve) > ParametricCurves;
00110   ParametricCurves _curves;
00111   typedef plist<ParametricCurveDrawer *> DrawerList;
00112   DrawerList _drawers;
00113 };
00114 
00115 INLINE ostream &
00116 operator << (ostream &out, const ParametricCurveCollection &col) {
00117   col.output(out);
00118   return out;
00119 }
00120 
00121 #include "parametricCurveCollection.I"
00122 
00123 #endif
00124 
00125 

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