Panda3D
 All Classes Functions Variables Enumerations
parametricCurveCollection.h
1 // Filename: parametricCurveCollection.h
2 // Created by: drose (04Mar01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef NODEPATHCOLLECTION_H
16 #define NODEPATHCOLLECTION_H
17 
18 #include "pandabase.h"
19 
20 #include "parametricCurve.h"
21 
22 #include "referenceCount.h"
23 #include "pointerTo.h"
24 #include "luse.h"
25 
26 #include "pvector.h"
27 #include "plist.h"
28 
29 class ParametricCurveDrawer;
30 
31 ////////////////////////////////////////////////////////////////////
32 // Class : ParametricCurveCollection
33 // Description : This is a set of zero or more ParametricCurves, which
34 // may or may not be related. If they are related, the
35 // set should contain no more than one XYZ curve, no
36 // more than one HPR curve, and zero or more Timewarp
37 // curves, which can then be evaluated as a unit to
38 // return a single transformation matrix for a given
39 // unit of time.
40 ////////////////////////////////////////////////////////////////////
41 class EXPCL_PANDA_PARAMETRICS ParametricCurveCollection : public ReferenceCount {
42 PUBLISHED:
44  INLINE ~ParametricCurveCollection();
45 
46  void add_curve(ParametricCurve *curve);
47  void add_curve(ParametricCurve *curve, int index);
48  int add_curves(PandaNode *node);
49  bool remove_curve(ParametricCurve *curve);
50  void remove_curve(int index);
51  bool has_curve(ParametricCurve *curve) const;
52  void clear();
53  void clear_timewarps();
54 
55  INLINE int get_num_curves() const;
56  INLINE ParametricCurve *get_curve(int index) const;
57  MAKE_SEQ(get_curves, get_num_curves, get_curve);
58 
59  ParametricCurve *get_xyz_curve() const;
60  ParametricCurve *get_hpr_curve() const;
61  ParametricCurve *get_default_curve() const;
62  int get_num_timewarps() const;
63  ParametricCurve *get_timewarp_curve(int n) const;
64  MAKE_SEQ(get_timewarp_curves, get_num_timewarps, get_timewarp_curve);
65 
66  INLINE PN_stdfloat get_max_t() const;
67 
68  void make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit);
69  void face_forward(PN_stdfloat segments_per_unit);
70  void reset_max_t(PN_stdfloat max_t);
71 
72  bool evaluate(PN_stdfloat t, LVecBase3 &xyz, LVecBase3 &hpr) const;
73  bool evaluate(PN_stdfloat t, LMatrix4 &result, CoordinateSystem cs = CS_default) const;
74 
75  PN_stdfloat evaluate_t(PN_stdfloat t) const;
76  INLINE bool evaluate_xyz(PN_stdfloat t, LVecBase3 &xyz) const;
77  INLINE bool evaluate_hpr(PN_stdfloat t, LVecBase3 &hpr) const;
78 
79  INLINE bool adjust_xyz(PN_stdfloat t, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
80  bool adjust_xyz(PN_stdfloat t, const LVecBase3 &xyz);
81  INLINE bool adjust_hpr(PN_stdfloat t, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r);
82  bool adjust_hpr(PN_stdfloat t, const LVecBase3 &xyz);
83 
84  bool recompute();
85 
86  bool stitch(const ParametricCurveCollection *a,
87  const ParametricCurveCollection *b);
88 
89  void output(ostream &out) const;
90  void write(ostream &out, int indent_level = 0) const;
91 
92  bool write_egg(Filename filename, CoordinateSystem cs = CS_default);
93  bool write_egg(ostream &out, const Filename &filename, CoordinateSystem cs);
94 
95 public:
96  int r_add_curves(PandaNode *node);
97  void register_drawer(ParametricCurveDrawer *drawer);
98  void unregister_drawer(ParametricCurveDrawer *drawer);
99 
100 private:
101  bool determine_hpr(PN_stdfloat t, ParametricCurve *xyz_curve, LVecBase3 &hpr) const;
102  void prepare_add_curve(ParametricCurve *curve);
103  void prepare_remove_curve(ParametricCurve *curve);
104  void redraw();
105 
106 private:
108  ParametricCurves _curves;
110  DrawerList _drawers;
111 };
112 
113 INLINE ostream &
114 operator << (ostream &out, const ParametricCurveCollection &col) {
115  col.output(out);
116  return out;
117 }
118 
119 #include "parametricCurveCollection.I"
120 
121 #endif
122 
123 
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
void output(ostream &out) const
Writes a brief one-line description of the ParametricCurveCollection to the indicated output stream...
A virtual base class for parametric curves.
This is a set of zero or more ParametricCurves, which may or may not be related.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
A base class for all things that want to be reference-counted.