Panda3D
|
A CubicCurveseg is any curve that can be completely described by four 4-valued basis vectors, one for each dimension in three-space, and one for the homogeneous coordinate. More...
#include "cubicCurveseg.h"
Public Member Functions | |
CubicCurveseg (int order, const PN_stdfloat knots[], const LVecBase4 cvs[]) | |
Creates the curveseg as a NURBS segment. | |
CubicCurveseg (const LMatrix4 &basis) | |
Creates the curveseg given the four basis vectors (the columns of the matrix) explicitly. | |
CubicCurveseg (const BezierSeg &seg) | |
Creates the curveseg as a Bezier segment. | |
void | bezier_basis (const BezierSeg &seg) |
Defines the curve segment as a Bezier. | |
void | evaluate_point (const LVecBase4 &tv, LVecBase3 &result) const |
void | evaluate_vector (const LVecBase4 &tv, LVecBase3 &result) const |
virtual TypeHandle | force_init_type () |
virtual bool | get_2ndtangent (PN_stdfloat t, LVecBase3 &tangent2) const |
Computes the surface 2nd-order tangent at a given parametric point t. | |
virtual bool | get_bezier_seg (BezierSeg &seg) const |
Fills the BezierSeg structure with a description of the curve segment as a Bezier, if possible, but does not change the _t member of the structure. | |
virtual bool | get_point (PN_stdfloat t, LVecBase3 &point) const |
Computes the surface point at a given parametric point t. | |
virtual bool | get_pt (PN_stdfloat t, LVecBase3 &point, LVecBase3 &tangent) const |
Simultaneously computes the point and the tangent at the given parametric point. | |
virtual bool | get_tangent (PN_stdfloat t, LVecBase3 &tangent) const |
Computes the surface tangent at a given parametric point t. | |
virtual TypeHandle | get_type () const |
void | hermite_basis (const HermiteCurveCV &cv0, const HermiteCurveCV &cv1, PN_stdfloat tlength=1.0f) |
Defines the curve segment as a Hermite. | |
void | nurbs_basis (int order, const PN_stdfloat knots[], const LVecBase4 cvs[]) |
Defines the curve segment as a NURBS. | |
Static Public Member Functions | |
static bool | compute_seg (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, const LMatrix4 &B, const LMatrix4 &Bi, LMatrix4 &G) |
Given a set of four properties of a curve segment (e.g. | |
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. | |
Public Attributes | |
LVecBase4 | Bw |
LVecBase4 | Bx |
LVecBase4 | By |
LVecBase4 | Bz |
bool | rational |
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. | |
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_CubicCurveseg (const FactoryParams ¶ms) |
Factory method to generate an object of this type. |
A CubicCurveseg is any curve that can be completely described by four 4-valued basis vectors, one for each dimension in three-space, and one for the homogeneous coordinate.
This includes Beziers, Hermites, and NURBS.
This class encapsulates a single curve segment of the cubic curve. Normally, when we think of Bezier and Hermite curves, we think of a piecewise collection of such segments.
Although this class includes methods such as hermite_basis() and nurbs_basis(), to generate a Hermite and NURBS curve segment, respectively, only the final basis vectors are stored: the product of the basis matrix of the corresponding curve type, and its geometry vectors. This is the minimum information needed to evaluate the curve. However, the individual CV's that were used to compute these basis vectors are not retained; this might be handled in a subclass (for instance, HermiteCurve).
Definition at line 58 of file cubicCurveseg.h.
CubicCurveseg::CubicCurveseg | ( | const LMatrix4 & | basis | ) |
Creates the curveseg given the four basis vectors (the columns of the matrix) explicitly.
Definition at line 43 of file cubicCurveseg.cxx.
References LMatrix4f::get_col().
CubicCurveseg::CubicCurveseg | ( | const BezierSeg & | seg | ) |
Creates the curveseg as a Bezier segment.
Definition at line 58 of file cubicCurveseg.cxx.
References bezier_basis().
CubicCurveseg::CubicCurveseg | ( | int | order, |
const PN_stdfloat | knots[], | ||
const LVecBase4 | cvs[] | ||
) |
Creates the curveseg as a NURBS segment.
See nurbs_basis for a description of the parameters.
Definition at line 70 of file cubicCurveseg.cxx.
References nurbs_basis().
void CubicCurveseg::bezier_basis | ( | const BezierSeg & | seg | ) |
Defines the curve segment as a Bezier.
This only sets up the basis vectors, so the curve will be computed correctly; it does not retain the CV's.
Definition at line 175 of file cubicCurveseg.cxx.
Referenced by CubicCurveseg().
bool CubicCurveseg::compute_seg | ( | 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, | ||
const LMatrix4 & | B, | ||
const LMatrix4 & | Bi, | ||
LMatrix4 & | G | ||
) | [static] |
Given a set of four properties of a curve segment (e.g.
four points, four tangent values, four control points, or any combination), and a basis matrix, computes the corresponding geometry matrix that (together with the basis matrix) represents the curve that satisfies the four properties.
The basis matrix is passed in as B, and its inverse must be precomputed and passed in as Bi.
The result is returned in the matrix G, each column of which represents the cth control vertex. If any of the four properties has RT_KEEP_ORIG set (see below), G's input value is used to define the original shape of the curve; otherwise, G's input value is ignored.
Each property is defined by an rtype, which may be any of RT_POINT, RT_TANGENT, or RT_CV, and may or may not be or'ed with RT_KEEP_ORIG. The meanings of the types are as follows:
RT_POINT defines a specific point which the curve segment must pass through. t is in the range [0,1] and represents the parametric value at which the curve segment will intersect the given point. If RT_KEEP_ORIG is not set, v defines the point; otherwise, v is ignored and the original curve at point t defines the point.
RT_TANGENT defines a specific tangent value which the curve segment must have at point t. As with RT_POINT, if RT_KEEP_ORIG is not set, v defines the tangent; otherwise, v is ignored and the original curve defines the tangent.
RT_CV defines a specific control vertex which the curve segment must have. In this case, t is ignored. The position within the argument list determines which control vertex is applicable; e.g. rtype0 = RT_CV defines control vertex 0, and rtype2 = RT_CV defines control vertex 2. If RT_KEEP_ORIG is not set, v defines the new control vertex; otherwise, the control vertex is taken from G.
The return value is true if all the parameters are sensible, or false if there is some error.
Definition at line 506 of file cubicCurveseg.cxx.
Referenced by NurbsCurve::rebuild_curveseg().
void CubicCurveseg::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 ParametricCurve.
Definition at line 615 of file cubicCurveseg.cxx.
References DatagramIterator::get_bool(), and LVecBase4f::read_datagram().
Referenced by make_CubicCurveseg().
bool CubicCurveseg::get_2ndtangent | ( | PN_stdfloat | t, |
LVecBase3 & | tangent2 | ||
) | const [virtual] |
Computes the surface 2nd-order tangent at a given parametric point t.
Implements ParametricCurve.
Definition at line 131 of file cubicCurveseg.cxx.
bool CubicCurveseg::get_bezier_seg | ( | BezierSeg & | seg | ) | const [virtual] |
Fills the BezierSeg structure with a description of the curve segment as a Bezier, if possible, but does not change the _t member of the structure.
Returns true if successful, false otherwise.
Reimplemented from ParametricCurve.
Definition at line 328 of file cubicCurveseg.cxx.
bool CubicCurveseg::get_point | ( | PN_stdfloat | t, |
LVecBase3 & | point | ||
) | const [virtual] |
Computes the surface point at a given parametric point t.
Implements ParametricCurve.
Definition at line 92 of file cubicCurveseg.cxx.
bool CubicCurveseg::get_pt | ( | PN_stdfloat | t, |
LVecBase3 & | point, | ||
LVecBase3 & | tangent | ||
) | const [virtual] |
Simultaneously computes the point and the tangent at the given parametric point.
Implements ParametricCurve.
Definition at line 117 of file cubicCurveseg.cxx.
bool CubicCurveseg::get_tangent | ( | PN_stdfloat | t, |
LVecBase3 & | tangent | ||
) | const [virtual] |
Computes the surface tangent at a given parametric point t.
Implements ParametricCurve.
Definition at line 105 of file cubicCurveseg.cxx.
void CubicCurveseg::hermite_basis | ( | const HermiteCurveCV & | cv0, |
const HermiteCurveCV & | cv1, | ||
PN_stdfloat | tlength = 1.0f |
||
) |
Defines the curve segment as a Hermite.
This only sets up the basis vectors, so the curve will be computed correctly; it does not retain the CV's.
Definition at line 145 of file cubicCurveseg.cxx.
TypedWritable * CubicCurveseg::make_CubicCurveseg | ( | const FactoryParams & | params | ) | [static, protected] |
Factory method to generate an object of this type.
Definition at line 579 of file cubicCurveseg.cxx.
References fillin().
Referenced by register_with_read_factory().
void CubicCurveseg::nurbs_basis | ( | int | order, |
const PN_stdfloat | knots[], | ||
const LVecBase4 | cvs[] | ||
) |
Defines the curve segment as a NURBS.
Order is one more than the degree, and must be 1, 2, 3, or 4; knots is an array of order*2 values, and cvs is an array of order values.
Definition at line 298 of file cubicCurveseg.cxx.
Referenced by CubicCurveseg().
void CubicCurveseg::register_with_read_factory | ( | ) | [static] |
Initializes the factory for reading these things from Bam files.
Reimplemented from PandaNode.
Definition at line 569 of file cubicCurveseg.cxx.
References BamReader::get_factory(), make_CubicCurveseg(), and Factory< Type >::register_factory().
Function to write the important information in the particular object to a Datagram.
Reimplemented from ParametricCurve.
Definition at line 596 of file cubicCurveseg.cxx.
References Datagram::add_bool(), and LVecBase4f::write_datagram().