00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef NODEPATHCOLLECTION_H
00016 #define NODEPATHCOLLECTION_H
00017
00018 #include "pandabase.h"
00019
00020 #include "parametricCurve.h"
00021
00022 #include "referenceCount.h"
00023 #include "pointerTo.h"
00024 #include "luse.h"
00025
00026 #include "pvector.h"
00027 #include "plist.h"
00028
00029 class ParametricCurveDrawer;
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 class EXPCL_PANDA_PARAMETRICS ParametricCurveCollection : public ReferenceCount {
00042 PUBLISHED:
00043 ParametricCurveCollection();
00044 INLINE ~ParametricCurveCollection();
00045
00046 void add_curve(ParametricCurve *curve);
00047 void add_curve(ParametricCurve *curve, int index);
00048 int add_curves(PandaNode *node);
00049 bool remove_curve(ParametricCurve *curve);
00050 void remove_curve(int index);
00051 bool has_curve(ParametricCurve *curve) const;
00052 void clear();
00053 void clear_timewarps();
00054
00055 INLINE int get_num_curves() const;
00056 INLINE ParametricCurve *get_curve(int index) const;
00057 MAKE_SEQ(get_curves, get_num_curves, get_curve);
00058
00059 ParametricCurve *get_xyz_curve() const;
00060 ParametricCurve *get_hpr_curve() const;
00061 ParametricCurve *get_default_curve() const;
00062 int get_num_timewarps() const;
00063 ParametricCurve *get_timewarp_curve(int n) const;
00064 MAKE_SEQ(get_timewarp_curves, get_num_timewarps, get_timewarp_curve);
00065
00066 INLINE PN_stdfloat get_max_t() const;
00067
00068 void make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit);
00069 void face_forward(PN_stdfloat segments_per_unit);
00070 void reset_max_t(PN_stdfloat max_t);
00071
00072 bool evaluate(PN_stdfloat t, LVecBase3 &xyz, LVecBase3 &hpr) const;
00073 bool evaluate(PN_stdfloat t, LMatrix4 &result, CoordinateSystem cs = CS_default) const;
00074
00075 PN_stdfloat evaluate_t(PN_stdfloat t) const;
00076 INLINE bool evaluate_xyz(PN_stdfloat t, LVecBase3 &xyz) const;
00077 INLINE bool evaluate_hpr(PN_stdfloat t, LVecBase3 &hpr) const;
00078
00079 INLINE bool adjust_xyz(PN_stdfloat t, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
00080 bool adjust_xyz(PN_stdfloat t, const LVecBase3 &xyz);
00081 INLINE bool adjust_hpr(PN_stdfloat t, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r);
00082 bool adjust_hpr(PN_stdfloat t, const LVecBase3 &xyz);
00083
00084 bool recompute();
00085
00086 bool stitch(const ParametricCurveCollection *a,
00087 const ParametricCurveCollection *b);
00088
00089 void output(ostream &out) const;
00090 void write(ostream &out, int indent_level = 0) const;
00091
00092 bool write_egg(Filename filename, CoordinateSystem cs = CS_default);
00093 bool write_egg(ostream &out, const Filename &filename, CoordinateSystem cs);
00094
00095 public:
00096 int r_add_curves(PandaNode *node);
00097 void register_drawer(ParametricCurveDrawer *drawer);
00098 void unregister_drawer(ParametricCurveDrawer *drawer);
00099
00100 private:
00101 bool determine_hpr(PN_stdfloat t, ParametricCurve *xyz_curve, LVecBase3 &hpr) const;
00102 void prepare_add_curve(ParametricCurve *curve);
00103 void prepare_remove_curve(ParametricCurve *curve);
00104 void redraw();
00105
00106 private:
00107 typedef pvector< PT(ParametricCurve) > ParametricCurves;
00108 ParametricCurves _curves;
00109 typedef plist<ParametricCurveDrawer *> DrawerList;
00110 DrawerList _drawers;
00111 };
00112
00113 INLINE ostream &
00114 operator << (ostream &out, const ParametricCurveCollection &col) {
00115 col.output(out);
00116 return out;
00117 }
00118
00119 #include "parametricCurveCollection.I"
00120
00121 #endif
00122
00123