Panda3D
parametricCurveCollection.I
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.I
10  * @author drose
11  * @date 2001-03-04
12  */
13 
14 /**
15  *
16  */
17 INLINE ParametricCurveCollection::
18 ~ParametricCurveCollection() {
19 }
20 
21 /**
22  * Returns the number of ParametricCurves in the collection.
23  */
24 INLINE int ParametricCurveCollection::
25 get_num_curves() const {
26  return _curves.size();
27 }
28 
29 /**
30  * Returns the nth ParametricCurve in the collection.
31  */
33 get_curve(int index) const {
34  nassertr(index >= 0 && index < (int)_curves.size(), nullptr);
35 
36  return _curves[index];
37 }
38 
39 /**
40  * Adds a new ParametricCurve to the collection at the indicated index.
41  * @deprecated Use insert_curve(index, curve) instead.
42  */
44 add_curve(ParametricCurve *curve, int index) {
45  insert_curve(std::max(index, 0), curve);
46 }
47 
48 /**
49  * Returns the maximum T value associated with the *last* curve in the
50  * collection. Normally, this will be either the XYZ or HPR curve, or a
51  * timewarp curve.
52  */
53 INLINE PN_stdfloat ParametricCurveCollection::
54 get_max_t() const {
55  if (_curves.empty()) {
56  return 0.0f;
57  }
58  return _curves.back()->get_max_t();
59 }
60 
61 /**
62  * Computes only the XYZ part of the curves. See evaluate().
63  */
65 evaluate_xyz(PN_stdfloat t, LVecBase3 &xyz) const {
66  LVecBase3 hpr;
67  return evaluate(t, xyz, hpr);
68 }
69 
70 /**
71  * Computes only the HPR part of the curves. See evaluate().
72  */
74 evaluate_hpr(PN_stdfloat t, LVecBase3 &hpr) const {
75  LVecBase3 xyz;
76  return evaluate(t, xyz, hpr);
77 }
78 
79 /**
80  * Adjust the XYZ curve at the indicated time to the new value. The curve
81  * shape will change correspondingly. Returns true if successful, false if
82  * unable to make the adjustment for some reason.
83  */
85 adjust_xyz(PN_stdfloat t, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
86  return adjust_xyz(t, LVecBase3(x, y, z));
87 }
88 
89 /**
90  * Adjust the HPR curve at the indicated time to the new value. The curve
91  * shape will change correspondingly. Returns true if successful, false if
92  * unable to make the adjustment for some reason.
93  */
95 adjust_hpr(PN_stdfloat t, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
96  return adjust_hpr(t, LVecBase3(h, p, r));
97 }
bool adjust_hpr(PN_stdfloat t, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r)
Adjust the HPR curve at the indicated time to the new value.
void insert_curve(size_t index, ParametricCurve *curve)
Adds a new ParametricCurve to the collection at the indicated index.
A virtual base class for parametric curves.
bool evaluate(PN_stdfloat t, LVecBase3 &xyz, LVecBase3 &hpr) const
Computes the position and rotation represented by the first XYZ and HPR curves in the collection at t...
bool evaluate_hpr(PN_stdfloat t, LVecBase3 &hpr) const
Computes only the HPR part of the curves.
get_curve
Returns the nth ParametricCurve in the collection.
bool adjust_xyz(PN_stdfloat t, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Adjust the XYZ curve at the indicated time to the new value.
bool evaluate_xyz(PN_stdfloat t, LVecBase3 &xyz) const
Computes only the XYZ part of the curves.
void add_curve(ParametricCurve *curve)
Adds a new ParametricCurve to the collection.