00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00037
00038
00039
00040
00041
00042
00043
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