Panda3D
parametricCurveCollection.I
1 // Filename: parametricCurveCollection.I
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: ParametricCurveCollection::Destructor
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE ParametricCurveCollection::
22 ~ParametricCurveCollection() {
23 }
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function: ParametricCurveCollection::get_num_curves
27 // Access: Published
28 // Description: Returns the number of ParametricCurves in the collection.
29 ////////////////////////////////////////////////////////////////////
31 get_num_curves() const {
32  return _curves.size();
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function: ParametricCurveCollection::get_curve
37 // Access: Published
38 // Description: Returns the nth ParametricCurve in the collection.
39 ////////////////////////////////////////////////////////////////////
41 get_curve(int index) const {
42  nassertr(index >= 0 && index < (int)_curves.size(), (ParametricCurve *)NULL);
43 
44  return _curves[index];
45 }
46 
47 ////////////////////////////////////////////////////////////////////
48 // Function: ParametricCurveCollection::get_max_t
49 // Access: Published
50 // Description: Returns the maximum T value associated with the
51 // *last* curve in the collection. Normally, this will
52 // be either the XYZ or HPR curve, or a timewarp curve.
53 ////////////////////////////////////////////////////////////////////
54 INLINE PN_stdfloat ParametricCurveCollection::
55 get_max_t() const {
56  if (_curves.empty()) {
57  return 0.0f;
58  }
59  return _curves.back()->get_max_t();
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: ParametricCurveCollection::evaluate_xyz
64 // Access: Published
65 // Description: Computes only the XYZ part of the curves. See
66 // evaluate().
67 ////////////////////////////////////////////////////////////////////
69 evaluate_xyz(PN_stdfloat t, LVecBase3 &xyz) const {
70  LVecBase3 hpr;
71  return evaluate(t, xyz, hpr);
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: ParametricCurveCollection::evaluate_hpr
76 // Access: Published
77 // Description: Computes only the HPR part of the curves. See
78 // evaluate().
79 ////////////////////////////////////////////////////////////////////
81 evaluate_hpr(PN_stdfloat t, LVecBase3 &hpr) const {
82  LVecBase3 xyz;
83  return evaluate(t, xyz, hpr);
84 }
85 
86 ////////////////////////////////////////////////////////////////////
87 // Function: ParametricCurveCollection::adjust_xyz
88 // Access: Published
89 // Description: Adjust the XYZ curve at the indicated time to the new
90 // value. The curve shape will change correspondingly.
91 // Returns true if successful, false if unable to make
92 // the adjustment for some reason.
93 ////////////////////////////////////////////////////////////////////
95 adjust_xyz(PN_stdfloat t, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
96  return adjust_xyz(t, LVecBase3(x, y, z));
97 }
98 
99 ////////////////////////////////////////////////////////////////////
100 // Function: ParametricCurveCollection::adjust_hpr
101 // Access: Published
102 // Description: Adjust the HPR curve at the indicated time to the new
103 // value. The curve shape will change correspondingly.
104 // Returns true if successful, false if unable to make
105 // the adjustment for some reason.
106 ////////////////////////////////////////////////////////////////////
107 INLINE bool ParametricCurveCollection::
108 adjust_hpr(PN_stdfloat t, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
109  return adjust_hpr(t, LVecBase3(h, p, r));
110 }
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.
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
ParametricCurve * get_curve(int index) const
Returns the nth ParametricCurve in the collection.
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.
PN_stdfloat get_max_t() const
Returns the maximum T value associated with the last* curve 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.
int get_num_curves() const
Returns the number of ParametricCurves in the collection.