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...

Inheritance diagram for ParametricCurveCollection:
ReferenceCount

Public Member Functions

 __init__ ()
 
 __init__ (const ParametricCurveCollection)
 
 addCurve (ParametricCurve curve)
 Adds a new ParametricCurve to the collection. More...
 
 addCurve (ParametricCurve curve, int index)
 Adds a new ParametricCurve to the collection at the indicated index. More...
 
int addCurves (PandaNode node)
 Adds all the curves found in the scene graph rooted at the given node. More...
 
bool adjustHpr (float t, const LVecBase3 xyz)
 Adjust the HPR curve at the indicated time to the new value. More...
 
bool adjustHpr (float t, float h, float p, float r)
 Adjust the HPR curve at the indicated time to the new value. More...
 
bool adjustXyz (float t, const LVecBase3 xyz)
 Adjust the XYZ curve at the indicated time to the new value. More...
 
bool adjustXyz (float t, float x, float y, float z)
 Adjust the XYZ curve at the indicated time to the new value. More...
 
 clear ()
 Removes all ParametricCurves from the collection. More...
 
 clearTimewarps ()
 Removes all the timewarp curves from the collection. More...
 
bool evaluate (float t, LMatrix4 result, CoordinateSystem cs)
 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 (float t, LVecBase3 xyz, LVecBase3 hpr)
 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 evaluateHpr (float t, LVecBase3 hpr)
 Computes only the HPR part of the curves. More...
 
float evaluateT (float t)
 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 evaluateXyz (float t, LVecBase3 xyz)
 Computes only the XYZ part of the curves. More...
 
 faceForward (float 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 getCurve (int index)
 Returns the nth ParametricCurve in the collection. More...
 
list getCurves ()
 
ParametricCurve getDefaultCurve ()
 If there is an XYZ curve in the collection, returns it; otherwise, returns the first curve whose type is unspecified. More...
 
ParametricCurve getHprCurve ()
 Returns the first HPR curve in the collection, if any, or NULL if there are none. More...
 
float getMaxT ()
 Returns the maximum T value associated with the last curve in the collection. More...
 
int getNumCurves ()
 Returns the number of ParametricCurves in the collection. More...
 
int getNumTimewarps ()
 Returns the number of timewarp curves in the collection. More...
 
ParametricCurve getTimewarpCurve (int n)
 Returns the nth timewarp curve in the collection. More...
 
list getTimewarpCurves ()
 
ParametricCurve getXyzCurve ()
 Returns the first XYZ curve in the collection, if any, or NULL if there are none. More...
 
bool hasCurve (ParametricCurve curve)
 Returns true if the indicated ParametricCurve appears in this collection, false otherwise. More...
 
 insertCurve (int index, ParametricCurve curve)
 Adds a new ParametricCurve to the collection at the indicated index. More...
 
 makeEven (float max_t, float 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...
 
 output (Ostream out)
 Writes a brief one-line description of the ParametricCurveCollection to the indicated output stream. More...
 
bool recompute ()
 Ensures all the curves are freshly computed and up-to-date. More...
 
bool removeCurve (ParametricCurve curve)
 Removes the indicated ParametricCurve from the collection. More...
 
 removeCurve (int index)
 Removes the indicated ParametricCurve from the collection, by its index number. More...
 
 resetMaxT (float 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...
 
 setCurve (int index, ParametricCurve curve)
 Replaces the indicated ParametricCurve from the collection, by its index number. More...
 
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...
 
 write (Ostream out, int indent_level)
 Writes a complete multi-line description of the ParametricCurveCollection to the indicated output stream. More...
 
bool writeEgg (Filename filename, CoordinateSystem cs)
 Writes an egg description of all the nurbs curves in the collection to the specified output file. More...
 
bool writeEgg (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 getRefCount ()
 Returns the current reference count. More...
 
 ref ()
 Explicitly increments the reference count. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
bool unref ()
 Explicitly decrements the reference count. More...
 

Public Attributes

ParametricCurve curves []
 
ParametricCurve default_curve
 If there is an XYZ curve in the collection, returns it; otherwise, returns the first curve whose type is unspecified. More...
 
ParametricCurve hpr_curve
 Returns the first HPR curve in the collection, if any, or NULL if there are none. More...
 
float max_t
 Returns the maximum T value associated with the last curve in the collection. More...
 
ParametricCurve timewarp_curves []
 
ParametricCurve xyz_curve
 Returns the first XYZ curve in the collection, if any, or NULL if there are none. More...
 
- Public Attributes inherited from ReferenceCount
int ref_count
 The current reference count. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ReferenceCount
static TypeHandle getClassType ()
 

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.

Member Function Documentation

◆ __init__() [1/2]

__init__ ( )

◆ __init__() [2/2]

__init__ ( const  ParametricCurveCollection)

◆ addCurve() [1/2]

addCurve ( ParametricCurve  curve)

Adds a new ParametricCurve to the collection.

◆ addCurve() [2/2]

addCurve ( ParametricCurve  curve,
int  index 
)

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

◆ addCurves()

int addCurves ( PandaNode  node)

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

Returns the number of curves found.

◆ adjustHpr() [1/2]

bool adjustHpr ( float  t,
const LVecBase3  xyz 
)

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() [2/2]

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

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() [1/2]

bool adjustXyz ( float  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.

◆ adjustXyz() [2/2]

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

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()

clear ( )

Removes all ParametricCurves from the collection.

◆ clearTimewarps()

clearTimewarps ( )

Removes all the timewarp curves from the collection.

◆ evaluate() [1/2]

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

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() [2/2]

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

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()

bool evaluateHpr ( float  t,
LVecBase3  hpr 
)

Computes only the HPR part of the curves.

See evaluate().

◆ evaluateT()

float evaluateT ( float  t)

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()

bool evaluateXyz ( float  t,
LVecBase3  xyz 
)

Computes only the XYZ part of the curves.

See evaluate().

◆ faceForward()

faceForward ( float  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.

◆ getCurve()

ParametricCurve getCurve ( int  index)

Returns the nth ParametricCurve in the collection.

◆ getCurves()

list getCurves ( )

◆ getDefaultCurve()

ParametricCurve getDefaultCurve ( )

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.

◆ getHprCurve()

ParametricCurve getHprCurve ( )

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

◆ getMaxT()

float getMaxT ( )

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 getNumCurves ( )

Returns the number of ParametricCurves in the collection.

◆ getNumTimewarps()

int getNumTimewarps ( )

Returns the number of timewarp curves in the collection.

◆ getTimewarpCurve()

ParametricCurve getTimewarpCurve ( int  n)

Returns the nth timewarp curve in the collection.

◆ getTimewarpCurves()

list getTimewarpCurves ( )

◆ getXyzCurve()

ParametricCurve getXyzCurve ( )

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

◆ hasCurve()

bool hasCurve ( ParametricCurve  curve)

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

◆ insertCurve()

insertCurve ( int  index,
ParametricCurve  curve 
)

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

◆ makeEven()

makeEven ( float  max_t,
float  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.

◆ output()

output ( Ostream  out)

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

◆ recompute()

bool 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.

◆ removeCurve() [1/2]

bool removeCurve ( ParametricCurve  curve)

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() [2/2]

removeCurve ( int  index)

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

◆ resetMaxT()

resetMaxT ( float  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.

◆ setCurve()

setCurve ( int  index,
ParametricCurve  curve 
)

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

◆ stitch()

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.

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.

◆ write()

write ( Ostream  out,
int  indent_level 
)

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

◆ writeEgg() [1/2]

bool writeEgg ( Filename  filename,
CoordinateSystem  cs 
)

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() [2/2]

bool writeEgg ( 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.

Member Data Documentation

◆ curves

ParametricCurve curves[]

◆ default_curve

ParametricCurve 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.

◆ hpr_curve

ParametricCurve hpr_curve

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

◆ max_t

float 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.

◆ timewarp_curves

ParametricCurve timewarp_curves[]

◆ xyz_curve

ParametricCurve xyz_curve

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