# panda3d.core.ParametricCurveCollection¶

from panda3d.core import ParametricCurveCollection

class ParametricCurveCollection

Bases: ReferenceCount

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.

Inheritance diagram

__init__() → None
__init__(param0: ParametricCurveCollection) → None
addCurve(curve: ParametricCurve) → None

Adds a new ParametricCurve to the collection.

addCurve(curve: ParametricCurve, index: int) → None

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

addCurves(node: PandaNode) → int

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

adjustHpr(t: float, xyz: LVecBase3) → bool

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.

adjustHpr(t: float, h: float, p: float, r: float) → bool

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.

adjustXyz(t: float, xyz: LVecBase3) → bool

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.

adjustXyz(t: float, x: float, y: float, z: float) → bool

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.

clear() → None

Removes all ParametricCurves from the collection.

clearTimewarps() → None

Removes all the timewarp curves from the collection.

property curves
Getter

Returns the nth ParametricCurve in the collection.

Setter

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

Return type
property 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.

Return type

ParametricCurve

evaluate(t: float, result: LMatrix4, cs: CoordinateSystem) → bool

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.

evaluate(t: float, xyz: LVecBase3, hpr: LVecBase3) → bool

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.

evaluateHpr(t: float, hpr: LVecBase3) → bool

Computes only the HPR part of the curves. See evaluate().

evaluateT(t: float) → float

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.

evaluateXyz(t: float, xyz: LVecBase3) → bool

Computes only the XYZ part of the curves. See evaluate().

faceForward(segments_per_unit: float) → None

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.

getCurve(index: int) → ParametricCurve

Returns the nth ParametricCurve in the collection.

Return type

ParametricCurve

getCurves() → list
getDefaultCurve() → ParametricCurve

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.

Return type

ParametricCurve

getHprCurve() → ParametricCurve

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

Return type

ParametricCurve

getMaxT() → float

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.

getNumCurves() → int

Returns the number of ParametricCurves in the collection.

getNumTimewarps() → int

Returns the number of timewarp curves in the collection.

getTimewarpCurve(n: int) → ParametricCurve

Returns the nth timewarp curve in the collection.

Return type

ParametricCurve

getTimewarpCurves() → list
getXyzCurve() → ParametricCurve

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

Return type

ParametricCurve

hasCurve(curve: ParametricCurve) → bool

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

property hpr_curve

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

Return type

ParametricCurve

insertCurve(index: size_t, curve: ParametricCurve) → None

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

makeEven(max_t: float, segments_per_unit: float) → None

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.

property max_t

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.

Return type

float

output(out: ostream) → None

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

recompute() → bool

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.

removeCurve(curve: ParametricCurve) → bool

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

removeCurve(index: size_t) → None

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

resetMaxT(max_t: float) → None

Adjusts the apparent length of the curve by applying a new timewarp that maps the range [0..max_t] to the range [0..:meth:~ParametricCurveCollection.getMaxT]. After this call, the curve collection will contain one more timewarp curve, and getMaxT() will return the given max_t value.

setCurve(index: size_t, curve: ParametricCurve) → None

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

stitch(a: ParametricCurveCollection, b: ParametricCurveCollection) → bool

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.

property timewarp_curves

Returns the nth timewarp curve in the collection.

Return type
write(out: ostream, indent_level: int) → None

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

writeEgg(filename: Filename, cs: CoordinateSystem) → bool

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.

writeEgg(out: ostream, filename: Filename, cs: CoordinateSystem) → bool

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.

property xyz_curve

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

Return type

ParametricCurve