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