Panda3D
|
A parametric curve defined by a sequence of control vertices, each with an in and out tangent. More...
#include "hermiteCurve.h"
Public Member Functions | |
HermiteCurve (const ParametricCurve &pc) | |
Constructs a Hermite from the indicated (possibly non-hermite) curve. | |
int | append_cv (int type, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) |
Adds a new CV to the end of the curve. | |
int | append_cv (int type, const LVecBase3 &v) |
virtual TypeHandle | force_init_type () |
CubicCurveseg * | get_curveseg (int ti) |
Returns the curve segment corresponding to the given index. | |
const LVecBase3 & | get_cv_in (int n) const |
Returns the in tangent of the given CV. | |
void | get_cv_in (int n, LVecBase3 &v) const |
string | get_cv_name (int n) const |
Returns the name of the given CV, or NULL. | |
const LVecBase3 & | get_cv_out (int n) const |
Returns the out tangent of the given CV. | |
void | get_cv_out (int n, LVecBase3 &v) const |
void | get_cv_point (int n, LVecBase3 &v) const |
const LVecBase3 & | get_cv_point (int n) const |
Returns the position of the given CV. | |
PN_stdfloat | get_cv_tstart (int n) const |
Returns the starting point in parametric space of the given CV. | |
int | get_cv_type (int n) const |
Returns the given CV's continuity type, HC_CUT, HC_FREE, HC_G1, or HC_SMOOTH, or 0 if there is no such CV. | |
int | get_num_cvs () const |
Returns the number of CV's in the curve. | |
virtual TypeHandle | get_type () const |
int | insert_cv (PN_stdfloat t) |
Inserts a new CV at the given parametric point along the curve. | |
virtual void | output (ostream &out) const |
Outputs the Namable. | |
virtual bool | rebuild_curveseg (int rtype0, PN_stdfloat t0, const LVecBase4 &v0, int rtype1, PN_stdfloat t1, const LVecBase4 &v1, int rtype2, PN_stdfloat t2, const LVecBase4 &v2, int rtype3, PN_stdfloat t3, const LVecBase4 &v3) |
Rebuilds the current curve segment (as selected by the most recent call to find_curve()) according to the specified properties (see CubicCurveseg::compute_seg). | |
void | remove_all_cvs () |
Removes all CV's from the curve. | |
bool | remove_cv (int n) |
Removes the given CV from the curve. | |
bool | set_cv_in (int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) |
Changes the given CV's in tangent. | |
bool | set_cv_in (int n, const LVecBase3 &v) |
bool | set_cv_name (int n, const char *name) |
Changes the name associated with a particular CV. | |
bool | set_cv_out (int n, const LVecBase3 &v) |
bool | set_cv_out (int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) |
Changes the given CV's out tangent. | |
bool | set_cv_point (int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) |
Changes the given CV's position. | |
bool | set_cv_point (int n, const LVecBase3 &v) |
bool | set_cv_tstart (int n, PN_stdfloat tstart) |
Changes the given CV's parametric starting time. | |
bool | set_cv_type (int n, int type) |
Changes the given CV's continuity type. | |
void | write_cv (ostream &out, int n) const |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
static void | register_with_read_factory () |
Initializes the factory for reading these things from Bam files. | |
Protected Member Functions | |
void | fillin (DatagramIterator &scan, BamReader *manager) |
Function that reads out of the datagram (or asks manager to read) all of the data that is needed to re-create this object and stores it in the appropiate place. | |
int | find_cv (PN_stdfloat t) |
Finds the CV immediately preceding the given value of t. | |
virtual bool | format_egg (ostream &out, const string &name, const string &curve_type, int indent_level) const |
Formats the Hermite curve for output to an Egg file. | |
void | invalidate_cv (int n, bool redo_all) |
Recomputes the CV and its neighbors appropriately after a change. | |
void | recompute_basis () |
Recomputes the coefficients for all the CV's in the curve. | |
virtual void | write_datagram (BamWriter *manager, Datagram &me) |
Function to write the important information in the particular object to a Datagram. | |
Static Protected Member Functions | |
static TypedWritable * | make_HermiteCurve (const FactoryParams ¶ms) |
Factory method to generate an object of this type. | |
Protected Attributes | |
pvector< HermiteCurveCV > | _points |
A parametric curve defined by a sequence of control vertices, each with an in and out tangent.
This class is actually implemented as a PiecewiseCurve made up of several CubicCurvesegs, each of which is created using the hermite_basis() method. The HermiteCurve class itself keeps its own list of the CV's that are used to define the curve (since the CubicCurveseg class doesn't retain these).
Definition at line 88 of file hermiteCurve.h.
HermiteCurve::HermiteCurve | ( | const ParametricCurve & | pc | ) |
Constructs a Hermite from the indicated (possibly non-hermite) curve.
Definition at line 275 of file hermiteCurve.cxx.
References ParametricCurve::convert_to_hermite().
int HermiteCurve::append_cv | ( | int | type, |
PN_stdfloat | x, | ||
PN_stdfloat | y, | ||
PN_stdfloat | z | ||
) |
Adds a new CV to the end of the curve.
The new CV is given initial in/out tangents of 0. The return value is the index of the new CV.
Definition at line 364 of file hermiteCurve.cxx.
References HermiteCurveCV::set_in(), HermiteCurveCV::set_out(), and HermiteCurveCV::set_type().
Referenced by ParametricCurve::convert_to_hermite().
void HermiteCurve::fillin | ( | DatagramIterator & | scan, |
BamReader * | manager | ||
) | [protected, virtual] |
Function that reads out of the datagram (or asks manager to read) all of the data that is needed to re-create this object and stores it in the appropiate place.
Reimplemented from PiecewiseCurve.
Definition at line 960 of file hermiteCurve.cxx.
References HermiteCurveCV::fillin(), PiecewiseCurve::fillin(), and DatagramIterator::get_uint32().
Referenced by make_HermiteCurve().
int HermiteCurve::find_cv | ( | PN_stdfloat | t | ) | [protected] |
Finds the CV immediately preceding the given value of t.
Definition at line 865 of file hermiteCurve.cxx.
bool HermiteCurve::format_egg | ( | ostream & | out, |
const string & | name, | ||
const string & | curve_type, | ||
int | indent_level | ||
) | const [protected, virtual] |
Formats the Hermite curve for output to an Egg file.
Reimplemented from ParametricCurve.
Definition at line 745 of file hermiteCurve.cxx.
CubicCurveseg* HermiteCurve::get_curveseg | ( | int | ti | ) | [inline] |
Returns the curve segment corresponding to the given index.
Reimplemented from PiecewiseCurve.
Definition at line 137 of file hermiteCurve.h.
const LVecBase3 & HermiteCurve::get_cv_in | ( | int | n | ) | const |
Returns the in tangent of the given CV.
Definition at line 585 of file hermiteCurve.cxx.
Referenced by ParametricCurve::convert_to_hermite().
string HermiteCurve::get_cv_name | ( | int | n | ) | const |
Returns the name of the given CV, or NULL.
Definition at line 640 of file hermiteCurve.cxx.
const LVecBase3 & HermiteCurve::get_cv_out | ( | int | n | ) | const |
Returns the out tangent of the given CV.
Definition at line 604 of file hermiteCurve.cxx.
Referenced by ParametricCurve::convert_to_hermite().
const LVecBase3 & HermiteCurve::get_cv_point | ( | int | n | ) | const |
Returns the position of the given CV.
Definition at line 566 of file hermiteCurve.cxx.
PN_stdfloat HermiteCurve::get_cv_tstart | ( | int | n | ) | const |
Returns the starting point in parametric space of the given CV.
Definition at line 624 of file hermiteCurve.cxx.
int HermiteCurve::get_cv_type | ( | int | n | ) | const |
Returns the given CV's continuity type, HC_CUT, HC_FREE, HC_G1, or HC_SMOOTH, or 0 if there is no such CV.
Definition at line 551 of file hermiteCurve.cxx.
Referenced by ParametricCurve::convert_to_hermite().
int HermiteCurve::get_num_cvs | ( | ) | const |
Returns the number of CV's in the curve.
Definition at line 304 of file hermiteCurve.cxx.
Referenced by ParametricCurve::convert_to_hermite().
int HermiteCurve::insert_cv | ( | PN_stdfloat | t | ) |
Inserts a new CV at the given parametric point along the curve.
If this parametric point is already on the curve, the CV is assigned an index between its two neighbors and the indices of all following CV's are incremented by 1; its in and out tangents are chosen to keep the curve consistent. If the new parametric point is beyond the end of the existing curve, the curve is extended to meet it and the new CV's position, in tangent, and out tangent are set to zero.
The index number of the new CV is returned.
Definition at line 326 of file hermiteCurve.cxx.
void HermiteCurve::invalidate_cv | ( | int | n, |
bool | redo_all | ||
) | [protected] |
Recomputes the CV and its neighbors appropriately after a change.
Definition at line 819 of file hermiteCurve.cxx.
References CurveFitter::wrap_hpr().
TypedWritable * HermiteCurve::make_HermiteCurve | ( | const FactoryParams & | params | ) | [static, protected] |
Factory method to generate an object of this type.
Definition at line 924 of file hermiteCurve.cxx.
References fillin().
void HermiteCurve::output | ( | ostream & | out | ) | const [virtual] |
Outputs the Namable.
This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.
Reimplemented from PandaNode.
Definition at line 655 of file hermiteCurve.cxx.
References PandaNode::output().
bool HermiteCurve::rebuild_curveseg | ( | int | rtype0, |
PN_stdfloat | t0, | ||
const LVecBase4 & | v0, | ||
int | rtype1, | ||
PN_stdfloat | t1, | ||
const LVecBase4 & | v1, | ||
int | rtype2, | ||
PN_stdfloat | t2, | ||
const LVecBase4 & | v2, | ||
int | rtype3, | ||
PN_stdfloat | t3, | ||
const LVecBase4 & | v3 | ||
) | [virtual] |
Rebuilds the current curve segment (as selected by the most recent call to find_curve()) according to the specified properties (see CubicCurveseg::compute_seg).
Returns true if possible, false if something goes horribly wrong.
Reimplemented from PiecewiseCurve.
Definition at line 731 of file hermiteCurve.cxx.
void HermiteCurve::recompute_basis | ( | ) | [protected] |
Recomputes the coefficients for all the CV's in the curve.
This is intended to be called whenever the CV's have been changed in some drastic way, and it's safest just to recompute everything.
Definition at line 888 of file hermiteCurve.cxx.
References CurveFitter::wrap_hpr().
void HermiteCurve::register_with_read_factory | ( | ) | [static] |
Initializes the factory for reading these things from Bam files.
Reimplemented from PandaNode.
Definition at line 914 of file hermiteCurve.cxx.
References BamReader::get_factory(), and Factory< Type >::register_factory().
void HermiteCurve::remove_all_cvs | ( | ) |
Removes all CV's from the curve.
Definition at line 413 of file hermiteCurve.cxx.
Referenced by ParametricCurve::convert_to_hermite().
bool HermiteCurve::remove_cv | ( | int | n | ) |
Removes the given CV from the curve.
Returns true if the CV existed, false otherwise.
Definition at line 391 of file hermiteCurve.cxx.
bool HermiteCurve::set_cv_in | ( | int | n, |
PN_stdfloat | x, | ||
PN_stdfloat | y, | ||
PN_stdfloat | z | ||
) |
Changes the given CV's in tangent.
Depending on the continuity type, this may also adjust the out tangent.
Definition at line 481 of file hermiteCurve.cxx.
Referenced by ParametricCurve::convert_to_hermite().
bool HermiteCurve::set_cv_name | ( | int | n, |
const char * | name | ||
) |
Changes the name associated with a particular CV.
Definition at line 533 of file hermiteCurve.cxx.
bool HermiteCurve::set_cv_out | ( | int | n, |
PN_stdfloat | x, | ||
PN_stdfloat | y, | ||
PN_stdfloat | z | ||
) |
Changes the given CV's out tangent.
Depending on the continuity type, this may also adjust the in tangent.
Definition at line 498 of file hermiteCurve.cxx.
Referenced by ParametricCurve::convert_to_hermite().
bool HermiteCurve::set_cv_point | ( | int | n, |
PN_stdfloat | x, | ||
PN_stdfloat | y, | ||
PN_stdfloat | z | ||
) |
Changes the given CV's position.
Definition at line 464 of file hermiteCurve.cxx.
bool HermiteCurve::set_cv_tstart | ( | int | n, |
PN_stdfloat | tstart | ||
) |
Changes the given CV's parametric starting time.
This may affect the shape of the curve.
Definition at line 514 of file hermiteCurve.cxx.
Referenced by ParametricCurve::convert_to_hermite().
bool HermiteCurve::set_cv_type | ( | int | n, |
int | type | ||
) |
Changes the given CV's continuity type.
Legal values are HC_CUT, HC_FREE, HC_G1, or HC_SMOOTH.
Other than HC_CUT, these have no effect on the actual curve; it remains up to user software to impose the constraints these imply.
HC_CUT implies a disconnection of the curve; HC_FREE imposes no constraints on the tangents; HC_G1 forces the tangents to be collinear, and HC_SMOOTH forces the tangents to be identical. Setting type type to HC_G1 or HC_SMOOTH may adjust the out tangent to match the in tangent.
Definition at line 441 of file hermiteCurve.cxx.
Referenced by ParametricCurve::convert_to_hermite().
Function to write the important information in the particular object to a Datagram.
Reimplemented from PiecewiseCurve.
Definition at line 941 of file hermiteCurve.cxx.
References Datagram::add_uint32(), and PiecewiseCurve::write_datagram().