Helper class for SplineObject. Designed to allow you to get positions along splines form real world units as well as get non flipping/non gimbal locked matrices and vectors from the spline. Must be inited before use. All values returned are in global space. The slow part is SplineHelp.InitSpline(); other access is pretty fast.
- c4d.utils.SplineHelp
Return type: | SplineHelp |
---|---|
Returns: | A new spline help object. |
Call before using the spline help class. (Must be called before any other command.)
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if successful, otherwise False. |
Called to free the spline data. Recalling InitSpline() or calling SplineHelp.__free__ will automatically call this.
Gets the number of segments in the spline.
Note
Unlike the way CINEMA 4D handles segments where a segmenet count of 0 means there’s either no segments or 1 segment, this returns 1 segment if there is 1 and 0 if there are 0.
Return type: | int |
---|---|
Returns: | Segment count. |
Useful check to see if the spline helper contains data and has been inited.
Return type: | bool |
---|---|
Returns: | True if the spline helper is ready to use. |
Get the segment count of the spline.
Return type: | int |
---|---|
Returns: | The count. |
Retrieves a full matrix for a specific point of the line.
Note
This is not the spline vertex, but instead the line object’s vertex. (Calculated with LOD=1.0.)
Parameters: | index (int) – Line object vertex. |
---|---|
Raises IndexError: | |
index must be 0<=index< GetPointCount() | |
Return type: | Matrix |
Returns: | Coordinate system matrix at index. |
Converts a natural offset value to a real percentage offset value.
Note
This percentage uses the realworld units for its offset, so regardless of how the spline’s points and interpolation is set, a gap of 2% on a 100m long spline will always be 2m whereas normally in spline natural space, a gap of 2% can vary a great deal depending on the spline’s interpolation etc.
Parameters: |
|
---|---|
Raises IndexError: | |
index must be 0<=index< GetSegmentCount() |
|
Return type: |
float |
Returns: |
The realworld percentage offset. |
Retrieves the nearest line point index to the given real offset.
Parameters: |
|
---|---|
Raises IndexError: | |
index must be 0<=index< GetSegmentCount() |
|
Return type: |
int |
Returns: |
The nearest line object point index, rounded down. |
Retrieves the nearest line point index to the given real offset.
Parameters: |
|
---|---|
Raises IndexError: | |
index must be 0<=index< GetSegmentCount() |
|
Return type: | |
Returns: |
The position given by offset in global space. |
Gets a tangent vector for any point along the spline.
Parameters: |
|
---|---|
Raises IndexError: | |
index must be 0<=index< GetSegmentCount() |
|
Return type: | |
Returns: |
The tangent given by offset in global space. |
Gets a normal vector for any point along the spline.
Parameters: |
|
---|---|
Raises IndexError: | |
index must be 0<=index< GetSegmentCount() |
|
Return type: | |
Returns: |
The normal given by offset in global space. |
Gets a cross normal vector (i.e. perpendicular to the normal and the tangent) for any point along the spline.
Parameters: |
|
---|---|
Raises IndexError: | |
index must be 0<=index< GetSegmentCount() |
|
Return type: | |
Returns: |
The cross normal given by offset in global space. |
Returns a specific segment’s realworld unit length.
Parameters: | segment (int) – Segment index. |
---|---|
Raises IndexError: | |
segment must be 0<=segment< GetSegmentCount() | |
Return type: | float |
Returns: | The length of the specified segment. |
Returns the spline’s realworld unit length uncluding all segments.
Return type: | float |
---|---|
Returns: | Spline length. |
Convert a percentage offset into a natural offset. Percentage offsets ignore spline interpolation etc. and are always x% along the spline.
Parameters: |
|
---|---|
Raises IndexError: | |
index must be 0<=index< GetSegmentCount() |
|
Return type: |
float |
Returns: |
The natural offset. |
Retrieve an offset from a realworld unit. For example, if a spline is 50 units long, 25 would be 50% of the length, i.e. 0.5
Parameters: |
|
---|---|
Raises IndexError: | |
index must be 0<=index< GetSegmentCount() |
|
Return type: |
float |
Returns: |
The offset in spline space. |
Converts a spline vertex index to its corresponding line object vertex index.
Parameters: | index (int) – The spline vertex index. |
---|---|
Return type: | int |
Returns: | The line object vertex index. |
Get the distance to an existing rail spline for any point along the spline.
Parameters: |
|
---|---|
Return type: |
float |
Returns: |
The distance given by offset. |
Retrieve a full matrix for any point along the spline, constructed as a local coordinate system at that point. Optionally use realworld percentage rather than spline natural space for the offset.
Parameters: |
|
---|---|
Return type: | |
Returns: |
Coordinate system matrix at offset. |
Get the number of vertices for a spline segment.
Parameters: | segment (int) – The segment index. |
---|---|
Raises IndexError: | |
index must be 0<=index< GetSegmentCount() | |
Return type: | int |
Returns: | The number of vertices. |
Get the distance to an existing rail spline for a spline vertex specified by index.
Parameters: | segment (int) – The segment index. |
---|---|
Raises IndexError: | |
index must be 0<=index< GetVertexCount() | |
Return type: | int |
Returns: | The distance given by index. |