Panda3D

Public Member Functions | Public Attributes | List of all members
ParametricCurveCollection Class Reference

This is a set of zero or more ParametricCurves, which may or may not be related. More...

`#include "parametricCurveCollection.h"`

Inheritance diagram for ParametricCurveCollection:

## Public Member Functions
void | add_curve (ParametricCurve *curve)
| Adds a new ParametricCurve to the collection. More...
void | add_curve (ParametricCurve *curve, int index)
| Adds a new ParametricCurve to the collection at the indicated index. More...
int | add_curves (PandaNode *node)
| Adds all the curves found in the scene graph rooted at the given node. More...
bool | adjust_hpr (PN_stdfloat t, const LVecBase3 &xyz)
| Adjust the HPR curve at the indicated time to the new value. More...
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. More...
bool | adjust_xyz (PN_stdfloat t, const LVecBase3 &xyz)
| Adjust the XYZ curve at the indicated time to the new value. More...
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. More...
void | clear ()
| Removes all ParametricCurves from the collection. More...
void | clear_timewarps ()
| Removes all the timewarp curves from the collection. More...
bool | evaluate (PN_stdfloat t, LMatrix4 &result, CoordinateSystem cs=CS_default) const
| Computes the transform matrix representing translation to the position indicated by the first XYZ curve in the collection and the rotation indicated by the first HPR curve in the collection, after t has been modified by all the timewarp curves in the collection applied in sequence, from back to front. More...
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 the given point t, after t has been modified by all the timewarp curves in the collection applied in sequence, from back to front. More...
bool | evaluate_hpr (PN_stdfloat t, LVecBase3 &hpr) const
| Computes only the HPR part of the curves. More...
PN_stdfloat | evaluate_t (PN_stdfloat t) const
| Determines the value of t that should be passed to the XYZ and HPR curves, after applying the given value of t to all the timewarps. More...
bool | evaluate_xyz (PN_stdfloat t, LVecBase3 &xyz) const
| Computes only the XYZ part of the curves. More...
void | face_forward (PN_stdfloat segments_per_unit)
| Discards the existing HPR curve and generates a new one that looks in the direction of travel along the XYZ curve, based on the XYZ curve's tangent at each point. More...
ParametricCurve * | get_curve (int index) const
ParametricCurve * | get_default_curve () const
ParametricCurve * | get_hpr_curve () const
PN_stdfloat | get_max_t () const
int | get_num_curves () const
int | get_num_timewarps () const
ParametricCurve * | get_timewarp_curve (int n) const
ParametricCurve * | get_xyz_curve () const
bool | has_curve (ParametricCurve *curve) const
| Returns true if the indicated ParametricCurve appears in this collection, false otherwise. More...
void | insert_curve (size_t index, ParametricCurve *curve)
| Adds a new ParametricCurve to the collection at the indicated index. More...
void | make_even (PN_stdfloat max_t, PN_stdfloat segments_per_unit)
| Discards all existing timewarp curves and recomputes a new timewarp curve that maps distance along the curve to parametric time, so that the distance between any two points in parametric time is proportional to the approximate distance of those same two points along the XYZ curve. More...
void | output (std::ostream &out) const
| Writes a brief one-line description of the ParametricCurveCollection to the indicated output stream. More...
int | r_add_curves (PandaNode *node)
| The recursive implementation of add_curves(). More...
bool | recompute ()
| Ensures all the curves are freshly computed and up-to-date. More...
void | register_drawer (ParametricCurveDrawer *drawer)
| Registers a Drawer with this curve collection that will automatically be updated whenever the collection is modified, so that the visible representation of the curve is kept up to date. More...
bool | remove_curve (ParametricCurve *curve)
void | remove_curve (size_t index)
void | reset_max_t (PN_stdfloat max_t)
| Adjusts the apparent length of the curve by applying a new timewarp that maps the range [0..max_t] to the range [0..get_max_t()]. More...
void | set_curve (size_t index, ParametricCurve *curve)
bool | stitch (const ParametricCurveCollection *a, const ParametricCurveCollection *b)
| Regenerates this curve as one long curve: the first curve connected end-to- end with the second one. More...
void | unregister_drawer (ParametricCurveDrawer *drawer)
| Removes a previously registered drawer from the list of automatically- refreshed drawers. More...
void | write (std::ostream &out, int indent_level=0) const
| Writes a complete multi-line description of the ParametricCurveCollection to the indicated output stream. More...
bool | write_egg (Filename filename, CoordinateSystem cs=CS_default)
| Writes an egg description of all the nurbs curves in the collection to the specified output file. More...
bool | write_egg (std::ostream &out, const Filename &filename, CoordinateSystem cs)
| Writes an egg description of all the nurbs curves in the collection to the specified output stream. More...
Public Member Functions inherited from ReferenceCount
int | get_ref_count () const
WeakReferenceList * | get_weak_list () const
| Returns the WeakReferenceList associated with this ReferenceCount object. More...
bool | has_weak_list () const
| Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
void | local_object ()
| This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
void | ref () const
| Explicitly increments the reference count. More...
bool | ref_if_nonzero () const
| Atomically increases the reference count of this object if it is not zero. More...
bool | test_ref_count_integrity () const
| Does some easy checks to make sure that the reference count isn't completely bogus. More...
bool | test_ref_count_nonzero () const
| Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
virtual bool | unref () const
| Explicitly decrements the reference count. More...
bool | unref_if_one () const
| Atomically decreases the reference count of this object if it is one. More...
WeakReferenceList * | weak_ref ()
| Adds the indicated PointerToVoid as a weak reference to this object. More...
void | weak_unref ()
| Removes the indicated PointerToVoid as a weak reference to this object. More...
Public Member Functions inherited from MemoryBase
void | operator delete (void *, void *)
void | operator delete (void *ptr)
void | operator delete[] (void *, void *)
void | operator delete[] (void *ptr)
void * | operator new (size_t size)
void * | operator new (size_t size, void *ptr)
void * | operator new[] (size_t size)
void * | operator new[] (size_t size, void *ptr)

## Public Attributes
| get_curve
| Returns the nth ParametricCurve in the collection. More...
| get_default_curve
| If there is an XYZ curve in the collection, returns it; otherwise, returns the first curve whose type is unspecified. More...
| get_hpr_curve
| Returns the first HPR curve in the collection, if any, or NULL if there are none. More...
| get_max_t
| Returns the maximum T value associated with the *last* curve in the collection. More...
| get_num_curves
| Returns the number of ParametricCurves in the collection. More...
| get_num_timewarps
| Returns the number of timewarp curves in the collection. More...
| get_timewarp_curve
| Returns the nth timewarp curve in the collection. More...
| get_xyz_curve
| Returns the first XYZ curve in the collection, if any, or NULL if there are none. More...
| remove_curve
| Removes the indicated ParametricCurve from the collection. More...
| set_curve
| Replaces the indicated ParametricCurve from the collection, by its index number. More...
Public Attributes inherited from ReferenceCount
| get_ref_count
| Returns the current reference count. More...

## Additional Inherited Members
Static Public Member Functions inherited from ReferenceCount
static TypeHandle | get_class_type ()
static void | init_type ()

## Detailed Description

This is a set of zero or more ParametricCurves, which may or may not be related.

If they are related, the set should contain no more than one XYZ curve, no more than one HPR curve, and zero or more Timewarp curves, which can then be evaluated as a unit to return a single transformation matrix for a given unit of time.

Definition at line 37 of file parametricCurveCollection.h.

## Member Function Documentation

## ◆ add_curve() [1/2]

void ParametricCurveCollection::add_curve | ( | ParametricCurve * | curve | ) |

Adds a new ParametricCurve to the collection.

Definition at line 34 of file parametricCurveCollection.cxx.

## ◆ add_curve() [2/2]

void ParametricCurveCollection::add_curve | ( | ParametricCurve * | curve,
|  | int | index
| ) |  |
| inline

Adds a new ParametricCurve to the collection at the indicated index.

Definition at line 43 of file parametricCurveCollection.I.

## ◆ add_curves()

int ParametricCurveCollection::add_curves | ( | PandaNode * | node | ) |

Adds all the curves found in the scene graph rooted at the given node.

Returns the number of curves found.

Definition at line 56 of file parametricCurveCollection.cxx.

References r_add_curves().

## ◆ adjust_hpr() [1/2]

bool ParametricCurveCollection::adjust_hpr | ( | PN_stdfloat | t,
|  | const LVecBase3 & | hpr
| ) |  |

Adjust the HPR curve at the indicated time to the new value.

The curve shape will change correspondingly. Returns true if successful, false if unable to make the adjustment for some reason.

Definition at line 583 of file parametricCurveCollection.cxx.

References ParametricCurve::adjust_point(), evaluate_t(), get_hpr_curve, and get_max_t.

## ◆ adjust_hpr() [2/2]

bool ParametricCurveCollection::adjust_hpr | ( | PN_stdfloat | t,
|  | PN_stdfloat | h,
|  | PN_stdfloat | p,
|  | PN_stdfloat | r
| ) |  |
| inline

Adjust the HPR curve at the indicated time to the new value.

The curve shape will change correspondingly. Returns true if successful, false if unable to make the adjustment for some reason.

Definition at line 94 of file parametricCurveCollection.I.

## ◆ adjust_xyz() [1/2]

bool ParametricCurveCollection::adjust_xyz | ( | PN_stdfloat | t,
|  | const LVecBase3 & | xyz
| ) |  |

Adjust the XYZ curve at the indicated time to the new value.

The curve shape will change correspondingly. Returns true if successful, false if unable to make the adjustment for some reason.

Definition at line 564 of file parametricCurveCollection.cxx.

References ParametricCurve::adjust_point(), evaluate_t(), get_max_t, and get_xyz_curve.

## ◆ adjust_xyz() [2/2]

bool ParametricCurveCollection::adjust_xyz | ( | PN_stdfloat | t,
|  | PN_stdfloat | x,
|  | PN_stdfloat | y,
|  | PN_stdfloat | z
| ) |  |
| inline

Adjust the XYZ curve at the indicated time to the new value.

The curve shape will change correspondingly. Returns true if successful, false if unable to make the adjustment for some reason.

Definition at line 84 of file parametricCurveCollection.I.

## ◆ clear()

void ParametricCurveCollection::clear | ( |  | ) |

Removes all ParametricCurves from the collection.

Definition at line 136 of file parametricCurveCollection.cxx.

## ◆ clear_timewarps()

void ParametricCurveCollection::clear_timewarps | ( |  | ) |

Removes all the timewarp curves from the collection.

Definition at line 151 of file parametricCurveCollection.cxx.

Referenced by make_even().

## ◆ evaluate() [1/2]

bool ParametricCurveCollection::evaluate | ( | PN_stdfloat | t,
|  | LMatrix4 & | result,
|  | CoordinateSystem | cs = `CS_default`
| ) |  | const

Computes the transform matrix representing translation to the position indicated by the first XYZ curve in the collection and the rotation indicated by the first HPR curve in the collection, after t has been modified by all the timewarp curves in the collection applied in sequence, from back to front.

Returns true if the point is valid (i.e. t is within the bounds indicated by all the timewarp curves and within the bounds of the curves themselves), or false otherwise.

Definition at line 518 of file parametricCurveCollection.cxx.

## ◆ evaluate() [2/2]

bool ParametricCurveCollection::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 the given point t, after t has been modified by all the timewarp curves in the collection applied in sequence, from back to front.

Returns true if the point is valid (i.e. t is within the bounds indicated by all the timewarp curves and within the bounds of the curves themselves), or false otherwise.

Definition at line 451 of file parametricCurveCollection.cxx.

References ParametricCurve::get_curve_type().

## ◆ evaluate_hpr()

bool ParametricCurveCollection::evaluate_hpr | ( | PN_stdfloat | t,
|  | LVecBase3 & | hpr
| ) |  | const
| inline

Computes only the HPR part of the curves.

See evaluate().

Definition at line 73 of file parametricCurveCollection.I.

## ◆ evaluate_t()

PN_stdfloat ParametricCurveCollection::evaluate_t | ( | PN_stdfloat | t | ) | const

Determines the value of t that should be passed to the XYZ and HPR curves, after applying the given value of t to all the timewarps.

Return -1.0f if the value of t exceeds one of the timewarps' ranges.

Definition at line 539 of file parametricCurveCollection.cxx.

References ParametricCurve::get_curve_type().

Referenced by adjust_hpr(), and adjust_xyz().

## ◆ evaluate_xyz()

bool ParametricCurveCollection::evaluate_xyz | ( | PN_stdfloat | t,
|  | LVecBase3 & | xyz
| ) |  | const
| inline

Computes only the XYZ part of the curves.

See evaluate().

Definition at line 64 of file parametricCurveCollection.I.

## ◆ face_forward()

void ParametricCurveCollection::face_forward | ( | PN_stdfloat | segments_per_unit | ) |

Discards the existing HPR curve and generates a new one that looks in the direction of travel along the XYZ curve, based on the XYZ curve's tangent at each point.

Definition at line 362 of file parametricCurveCollection.cxx.

References ParametricCurve::get_curve_type(), and get_xyz_curve.

## ◆ has_curve()

bool ParametricCurveCollection::has_curve | ( | ParametricCurve * | curve | ) | const

Returns true if the indicated ParametricCurve appears in this collection, false otherwise.

Definition at line 122 of file parametricCurveCollection.cxx.

## ◆ insert_curve()

void ParametricCurveCollection::insert_curve | ( | size_t | index,
|  | ParametricCurve * | curve
| ) |  |

Adds a new ParametricCurve to the collection at the indicated index.

Definition at line 44 of file parametricCurveCollection.cxx.

## ◆ make_even()

void ParametricCurveCollection::make_even | ( | PN_stdfloat | max_t,
|  | PN_stdfloat | segments_per_unit
| ) |  |

Discards all existing timewarp curves and recomputes a new timewarp curve that maps distance along the curve to parametric time, so that the distance between any two points in parametric time is proportional to the approximate distance of those same two points along the XYZ curve.

segments_per_unit represents the number of segments to take per each unit of parametric time of the original XYZ curve.

The new timewarp curve (and thus, the apparent range of the collection) will range from 0 to max_t.

Definition at line 295 of file parametricCurveCollection.cxx.

References clear_timewarps(), and get_xyz_curve.

## ◆ output()

void ParametricCurveCollection::output | ( | std::ostream & | out | ) | const

Writes a brief one-line description of the ParametricCurveCollection to the indicated output stream.

Definition at line 659 of file parametricCurveCollection.cxx.

References get_num_curves.

## ◆ r_add_curves()

int ParametricCurveCollection::r_add_curves | ( | PandaNode * | node | ) |

The recursive implementation of add_curves().

Definition at line 785 of file parametricCurveCollection.cxx.

References TypedObject::is_of_type().

Referenced by add_curves().

## ◆ recompute()

bool ParametricCurveCollection::recompute | ( |  | ) |

Ensures all the curves are freshly computed and up-to-date.

Returns true if everything is valid, false if at least one curve is incorrect.

Definition at line 601 of file parametricCurveCollection.cxx.

References ParametricCurve::recompute().

## ◆ register_drawer()

void ParametricCurveCollection::register_drawer | ( | ParametricCurveDrawer * | drawer | ) |

Registers a Drawer with this curve collection that will automatically be updated whenever the collection is modified, so that the visible representation of the curve is kept up to date.

This is called automatically by the ParametricCurveDrawer.

Any number of Drawers may be registered with a particular curve collection.

Definition at line 813 of file parametricCurveCollection.cxx.

References ParametricCurve::register_drawer().

## ◆ reset_max_t()

void ParametricCurveCollection::reset_max_t | ( | PN_stdfloat | max_t | ) |

Adjusts the apparent length of the curve by applying a new timewarp that maps the range [0..max_t] to the range [0..get_max_t()].

After this call, the curve collection will contain one more timewarp curve, and get_max_t() will return the given max_t value.

Definition at line 425 of file parametricCurveCollection.cxx.

## ◆ stitch()

bool ParametricCurveCollection::stitch | ( | const ParametricCurveCollection * | a,
|  | const ParametricCurveCollection * | b
| ) |  |

Regenerates this curve as one long curve: the first curve connected end-to- end with the second one.

Either a or b may be the same as 'this'. This will lose any timewarps on the input curves.

Returns true if successful, false on failure.

Definition at line 623 of file parametricCurveCollection.cxx.

## ◆ unregister_drawer()

void ParametricCurveCollection::unregister_drawer | ( | ParametricCurveDrawer * | drawer | ) |

Removes a previously registered drawer from the list of automatically- refreshed drawers.

This is called automatically by the ParametricCurveDrawer.

Definition at line 829 of file parametricCurveCollection.cxx.

References ParametricCurve::unregister_drawer().

## ◆ write()

void ParametricCurveCollection::write | ( | std::ostream & | out,
|  | int | indent_level = `0`
| ) |  | const

Writes a complete multi-line description of the ParametricCurveCollection to the indicated output stream.

Definition at line 672 of file parametricCurveCollection.cxx.

References indent().

## ◆ write_egg() [1/2]

bool ParametricCurveCollection::write_egg | ( | Filename | filename,
|  | CoordinateSystem | cs = `CS_default`
| ) |  |

Writes an egg description of all the nurbs curves in the collection to the specified output file.

Returns true if the file is successfully written.

Definition at line 685 of file parametricCurveCollection.cxx.

## ◆ write_egg() [2/2]

bool ParametricCurveCollection::write_egg | ( | std::ostream & | out,
|  | const Filename & | filename,
|  | CoordinateSystem | cs
| ) |  |

Writes an egg description of all the nurbs curves in the collection to the specified output stream.

Returns true if the file is successfully written.

Definition at line 702 of file parametricCurveCollection.cxx.

## Member Data Documentation

## ◆ get_curve

ParametricCurve * ParametricCurveCollection::get_curve
| inline

Returns the nth ParametricCurve in the collection.

Definition at line 55 of file parametricCurveCollection.h.

## ◆ get_default_curve

ParametricCurve * ParametricCurveCollection::get_default_curve

If there is an XYZ curve in the collection, returns it; otherwise, returns the first curve whose type is unspecified.

Returns NULL if no curve meets the criteria.

Definition at line 69 of file parametricCurveCollection.h.

## ◆ get_hpr_curve

ParametricCurve * ParametricCurveCollection::get_hpr_curve

Returns the first HPR curve in the collection, if any, or NULL if there are none.

Definition at line 68 of file parametricCurveCollection.h.

Referenced by adjust_hpr().

## ◆ get_max_t

PN_stdfloat ParametricCurveCollection::get_max_t
| inline

Returns the maximum T value associated with the *last* curve in the collection.

Normally, this will be either the XYZ or HPR curve, or a timewarp curve.

Definition at line 71 of file parametricCurveCollection.h.

Referenced by adjust_hpr(), and adjust_xyz().

## ◆ get_num_curves

int ParametricCurveCollection::get_num_curves
| inline

Returns the number of ParametricCurves in the collection.

Definition at line 55 of file parametricCurveCollection.h.

Referenced by output().

## ◆ get_num_timewarps

int ParametricCurveCollection::get_num_timewarps

Returns the number of timewarp curves in the collection.

Definition at line 62 of file parametricCurveCollection.h.

## ◆ get_timewarp_curve

ParametricCurve * ParametricCurveCollection::get_timewarp_curve

Returns the nth timewarp curve in the collection.

Definition at line 62 of file parametricCurveCollection.h.

## ◆ get_xyz_curve

ParametricCurve * ParametricCurveCollection::get_xyz_curve

Returns the first XYZ curve in the collection, if any, or NULL if there are none.

Definition at line 67 of file parametricCurveCollection.h.

Referenced by adjust_xyz(), face_forward(), and make_even().

## ◆ remove_curve

void ParametricCurveCollection::remove_curve

Removes the indicated ParametricCurve from the collection.

Removes the indicated ParametricCurve from the collection, by its index number.

Returns true if the curve was removed, false if it was not a member of the collection.

Definition at line 66 of file parametricCurveCollection.h.

## ◆ set_curve

void ParametricCurveCollection::set_curve

Replaces the indicated ParametricCurve from the collection, by its index number.

Definition at line 66 of file parametricCurveCollection.h.

The documentation for this class was generated from the following files:

- panda/src/parametrics/parametricCurveCollection.h
- panda/src/parametrics/parametricCurveCollection.cxx
- panda/src/parametrics/parametricCurveCollection.I