-
首页
-
C4D R23.110 C++ SDK
SplineHelp Class Reference
Library
»
SplineHelp Library
#include <lib_splinehelp.h>
详细描述
Class for helping to deal with splines. Defines routines to get positions along splines from real-world units, non flipping/non gimbal locked matrices and vectors from splines.
Must be initialized before use. All values returned are in global space. The slow part is the
InitSpline()
routine; other access is pretty fast.
-
注意
-
Has to be created with
Alloc()
and destroyed with
Free()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
Init/Free Spline
|
Bool
|
InitSplineEx
(
BaseObject
*op,
向量
upvector=
向量
(0.0),
BaseObject
*rail=nullptr,
Bool
target_rail=true,
Bool
use_deformed_points=false,
Bool
force_update=false,
Bool
use_global_space=true)
|
void
|
FreeSpline
(void)
|
Bool
|
InitSpline
(
BaseObject
*op,
SPLINEHELPFLAGS
flags=
SPLINEHELPFLAGS::GLOBALSPACE
|
SPLINEHELPFLAGS::CONTINUECURVE
)
|
Bool
|
InitSpline
(
BaseObject
*op,
向量
upvector,
SPLINEHELPFLAGS
flags=
SPLINEHELPFLAGS::GLOBALSPACE
|
SPLINEHELPFLAGS::CONTINUECURVE
)
|
Bool
|
InitSpline
(
BaseObject
*op,
BaseObject
*rail,
SPLINEHELPFLAGS
flags=
SPLINEHELPFLAGS::TARGETRAIL
|
SPLINEHELPFLAGS::GLOBALSPACE
|
SPLINEHELPFLAGS::CONTINUECURVE
)
|
Operations
|
Float
|
GetSplineLength
(void)
|
Float
|
GetSegmentLength
(
Int32
segment)
|
矩阵
|
GetVertexMatrix
(
Int32
index)
|
Float
|
GetPointValue
(
Float
offset,
Int32
segment)
|
Int32
|
GetPointIndex
(
Float
offset,
Int32
segment)
|
向量
|
GetPosition
(
Float
offset,
Int32
segment=0,
Bool
smooth=true,
Bool
realoffset=false)
|
向量
|
GetTangent
(
Float
offset,
Int32
segment=0,
Bool
smooth=true,
Bool
realoffset=false)
|
向量
|
GetNormal
(
Float
offset,
Int32
segment=0,
Bool
smooth=true,
Bool
realoffset=false)
|
向量
|
GetCrossNormal
(
Float
offset,
Int32
segment=0,
Bool
smooth=true,
Bool
realoffset=false)
|
Float
|
GetOffsetFromUnit
(
Float
unitoffset,
Int32
segment=0)
|
Float
|
GetOffsetFromReal
(
Float
offset,
Int32
segment=0)
|
矩阵
|
GetMatrix
(
Float
offset,
Int32
segment=0,
Bool
smooth=true,
Bool
realoffset=false)
|
void
|
GetLinePointSegment
(
Int32
index,
Float
*offset,
Int32
*ind,
Int32
*segment)
|
void
|
GetSplinePointSegment
(
Int32
index,
Float
*offset,
Int32
*ind,
Int32
*segment)
|
void
|
GlobalToLocal
(
Float
offset,
Float
*off,
Int32
*segment,
Bool
realoffset=false)
|
Int32
|
SplineToLineIndex
(
Int32
index)
|
Int32
|
LineToSplineIndex
(
Int32
index)
|
Float
|
GetSize
(
Float
offset,
Int32
segment=0,
Bool
smooth=true,
Bool
realoffset=false)
|
Float
|
GetVertexSize
(
Int32
index)
|
矩阵
|
GetVertexMatrix
(
Int32
segment,
Int32
index)
|
构造函数 & 析构函数文档编制
◆
SplineHelp()
◆
~SplineHelp()
成员函数文档编制
◆
Alloc()
Allocates a spline help. Destroy the allocated spline help with
Free()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
-
返回
-
The allocated spline help, or
nullptr
if the allocation failed.
◆
Free()
Destructs spline help instances allocated with
Alloc()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
-
参数
-
[in]
|
node
|
The spline help to destruct. If the pointer is
nullptr
nothing happens. The pointer is assigned
nullptr
afterwards.
|
◆
InitSplineEx()
Initializes the spline data.
Deprecated
since R17.
-
警告
-
Must be called before any other access.
-
参数
-
[in]
|
op
|
The spline object to use. The caller owns the pointed spline object.
|
[in]
|
upvector
|
An optional up-vector for the spline normals generation. This is only used at the start of splines/segments; this way it avoids gimbal lock if at all possible.
|
[in]
|
rail
|
An optional rail spline object for the spline normals generation. The caller owns the pointed spline object.
|
[in]
|
target_rail
|
若
true
the optional rail spline is not only used as up-vector but also as target.
This is used for instance in MoGraph's Rail options (Cloner, Spline effector, Spline Wrap etc.).
|
[in]
|
use_deformed_points
|
若
true
uses the deformed point positions of the spline.
|
[in]
|
force_update
|
若
true
forces a full initialization.
The spline help class internally caches its own content. Thus it will be much faster if the same splines are used for initialization.
.
|
[in]
|
use_global_space
|
若
false
the resulting matrices are in local space rather than in the spline objects' global space.
|
-
返回
-
true
if successful, otherwise
false
.
◆
FreeSpline()
Frees the spline data. Recalling
InitSpline()
or calling
Free()
will automatically call this.
◆
GetSegmentCount()
Int32
GetSegmentCount
|
(
|
void
|
|
)
|
|
Gets the number of segments in the spline.
-
注意
-
Unlike the way
Cinema 4D
handles segments where a segment count of
0
means there is either no segments or
1
segment, this returns
1
segment if there is
1
and
0
if there are
0
.
-
返回
-
The segment count.
◆
GetVertexCount()
Gets the number of vertices for a spline segment.
-
参数
-
-
返回
-
The number of vertices.
◆
GetPointCount()
Int32
GetPointCount
|
(
|
void
|
|
)
|
|
Retrieves the number of spline points.
-
返回
-
The number of spline points.
◆
GetSplineLength()
Float
GetSplineLength
|
(
|
void
|
|
)
|
|
Retrieves the spline's real-world unit length including all segments.
-
返回
-
The spline length.
◆
GetSegmentLength()
Retrieves a specific segment's real-world unit length.
-
参数
-
-
返回
-
The length of the specified
segment
.
◆
GetVertexMatrix()
[1/2]
Retrieves a full matrix for a specific point of the line.
-
注意
-
This is not the spline vertex, but instead the line object's vertex. (Calculated with LOD =
1.0
.)
-
参数
-
[in]
|
index
|
The index of the line object vertex:
0
<=
index
<
op
->
GetPointCount()
|
-
返回
-
The coordinate system matrix at
index
.
◆
GetPointValue()
Converts a natural offset value to a real percentage offset value.
-
注意
-
The percentage uses the real-world 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.
-
参数
-
[in]
|
offset
|
The offset given in spline space.
|
[in]
|
segment
|
The segment index:
0
<=
segment
<
GetSegmentCount()
|
-
返回
-
The real-world percentage offset.
◆
GetPointIndex()
Retrieves the nearest line point index to the given real
offset
.
-
参数
-
[in]
|
offset
|
The spline space offset.
|
[in]
|
segment
|
The segment index:
0
<=
segment
<
GetSegmentCount()
|
-
返回
-
The nearest line object point index, rounded down.
◆
GetPosition()
Gets a position along the spline.
-
参数
-
[in]
|
offset
|
The spline offset.
|
[in]
|
segment
|
The segment index:
0
<=
segment
<
GetSegmentCount()
|
[in]
|
smooth
|
若
true
the position is smoothed.
|
[in]
|
realoffset
|
若
true
uses uniform spline distribution.
|
-
返回
-
The position given by
offset
in global space.
◆
GetTangent()
Gets a tangent vector for any point along the spline.
-
参数
-
[in]
|
offset
|
The spline offset.
|
[in]
|
segment
|
The segment index:
0
<=
segment
<
GetSegmentCount()
|
[in]
|
smooth
|
若
true
the position is smoothed.
|
[in]
|
realoffset
|
若
true
uses uniform spline distribution.
|
-
返回
-
The tangent given by
offset
in global space.
◆
GetNormal()
Gets a normal vector for any point along the spline.
-
参数
-
[in]
|
offset
|
The spline offset.
|
[in]
|
segment
|
The segment index:
0
<=
segment
<
GetSegmentCount()
|
[in]
|
smooth
|
若
true
the position is smoothed.
|
[in]
|
realoffset
|
若
true
uses uniform spline distribution.
|
-
返回
-
The normal given by
offset
in global space.
◆
GetCrossNormal()
向量
GetCrossNormal
|
(
|
Float
|
offset
,
|
|
|
Int32
|
segment
=
0
,
|
|
|
Bool
|
smooth
=
true
,
|
|
|
Bool
|
realoffset
=
false
|
|
)
|
|
|
Gets a cross normal vector (i.e. perpendicular to the normal and the tangent) for any point along the spline.
-
参数
-
[in]
|
offset
|
The spline offset.
|
[in]
|
segment
|
The segment index:
0
<=
segment
<
GetSegmentCount()
|
[in]
|
smooth
|
若
true
the position is smoothed.
|
[in]
|
realoffset
|
若
true
uses uniform spline distribution.
|
-
返回
-
The cross normal given by
offset
in global space.
◆
GetOffsetFromUnit()
Converts a percentage offset into a natural offset. Percentage offsets ignore spline interpolation etc and are always
x%
along the spline.
-
参数
-
[in]
|
unitoffset
|
A percentage offset:
0
<=
unitoffset
<=
1.0
.
|
[in]
|
segment
|
The segment index:
0
<=
segment
<
GetSegmentCount()
|
-
返回
-
The natural offset.
◆
GetOffsetFromReal()
Retrieves an offset from a real-world unit.
For example, if a spline is
50
units long,
25
would be
50%
of the length, i.e.
0.5
.
-
参数
-
[in]
|
offset
|
The real unit offset to convert.
|
[in]
|
segment
|
The segment index:
0
<=
segment
<
GetSegmentCount()
|
-
返回
-
The offset in spline space.
◆
GetMatrix()
Retrieves a full matrix for any point along the spline, constructed as a local coordinate system at that point.
Optionally uses real-world percentage rather than spline natural space for the
offset
.
-
参数
-
[in]
|
offset
|
The spline offset.
|
[in]
|
segment
|
The segment index:
0
<=
segment
<
GetSegmentCount()
|
[in]
|
smooth
|
若
true
the position is smoothed.
|
[in]
|
realoffset
|
若
true
uses uniform spline distribution.
|
-
返回
-
The coordinate system matrix at
offset
.
◆
GetLinePointSegment()
Converts a global point
index
in a line (i.e. from
0
to the number of points in the line object) to a local set of values within a single segment returning the segment the point is in, the offset along the segment and the point index within the segment (
0
to the segment point count).
-
参数
-
[in]
|
index
|
The line object vertex index:
0
<=
index
<
op
->
GetPointCount()
(Using LOD =
1.0
for the line object.)
|
[out]
|
offset
|
Assigned the offset along the segment.
|
[out]
|
ind
|
Assigned the point index within the segment.
|
[out]
|
segment
|
Assigned the segment index.
|
◆
GetSplinePointSegment()
Converts a global point index in (i.e. from
0
to the number of points in the spline) to a local set of values within a single segment returning the segment the point is in, the offset along the segment and the point index within the segment (
0
0 to the segment point count).
-
注意
-
This is the same as
GetLinePointSegment()
, but uses the spline's set of indexes.
-
参数
-
[in]
|
index
|
The global spline point index:
0
<=
index
<
op
->
GetPointCount()
|
[out]
|
offset
|
Assigned the offset along the segment.
|
[out]
|
ind
|
Assigned the point index within the segment.
|
[out]
|
segment
|
Assigned the segment index.
|
◆
GlobalToLocal()
Turns a percentage along the whole spline to local segment info, offset along segment, the segment the point exists in.
Optionally uses a real
%
offset rather than the spline natural offset.
-
参数
-
[in]
|
offset
|
The percentage along the whole spline.
|
[out]
|
off
|
Assigned the offset along the segment.
|
[out]
|
segment
|
Assigned the segment index.
|
[in]
|
realoffset
|
若
true
a real-world percentage is used, rather than the natural spline space.
|
◆
SplineToLineIndex()
Converts a spline vertex
index
to its corresponding line object vertex index.
-
参数
-
-
返回
-
The line object vertex index:
0
<=
index
<
op
->
GetPointCount()
◆
LineToSplineIndex()
Converts a line object vertex
index
to its corresponding spline vertex index.
-
参数
-
[in]
|
index
|
The line object vertex index:
0
<=
index
<
op
->
GetPointCount()
|
-
返回
-
The spline vertex index:
0
<=
index
<
op
->
GetPointCount()
◆
GetSize()
Gets the distance to an existing rail spline for any point along the spline.
-
参数
-
[in]
|
offset
|
The spline offset.
|
[in]
|
segment
|
The segment index:
0
<=
segment
<
GetSegmentCount()
|
[in]
|
smooth
|
若
true
the position is smoothed.
|
[in]
|
realoffset
|
若
true
uses uniform spline distribution.
|
-
返回
-
The distance given by
offset
.
◆
GetVertexSize()
Gets the distance to an existing rail spline for a spline vertex specified by
index
.
-
参数
-
-
返回
-
The distance given by
index
.
◆
GetVertexMatrix()
[2/2]
Gets the matrix for a spline vertex specified by
segment
and
index
.
-
参数
-
-
返回
-
The matrix given by
segment
and
index
.
◆
CopyTo()
Copies the spline helper data to another
SplineHelp
.
-
参数
-
[in,out]
|
dest
|
The destination spline help. The caller owns the pointed spline help.
|
-
返回
-
true
if successful, otherwise
false
.
◆
Exists()
Checks if the spline helper contains data and has been initialized.
-
返回
-
true
if the spline helper is ready to use, otherwise
false
.
◆
IsClosed()
Checks if a spline segment is closed.
-
参数
-
-
返回
-
true
if the spline segment is closed, otherwise
false
.
◆
GetType()
Retrieves the spline interpolation type.
-
返回
-
The spline interpolation type:
SPLINETYPE
◆
SetOwner()
Prevents recursion lock crashes when
SplineHelp
needs to create the cache of the passed spline.
This is the case if for instance the developer has no control over the placement of a spline object in relation to its node.
For instance prevents infinite recursion in an object generator linking to itself using link fields.
范例:
class
MyBaseObject :
public
ObjectData
{
INSTANCEOF
(MyBaseObject,
ObjectData
)
public
:
AutoAlloc<SplineHelp>
shelp;
virtual
Bool
Init(
GeListNode
*node)
{
if
(!shelp)
return
false
;
shelp->
SetOwner
((
BaseObject
*)node);
// Only needs to be set once so NodeData::Init is a good place
return
true
;
}
...
// In some other function
if
(shelp->
InitSpline
(spline))
// etc.
...
};
It is also possible to call
shelp->
SetOwner
(thisobject);
shelp->
InitSpline
(spline);
ObjectData::GetVirtualObjects()
rather than in
ObjectData::Init()
.
SetOwner()
is not very costly to call.
-
警告
-
Must be called before
InitSpline()
.
-
参数
-
[in]
|
op
|
The object owning the current node data.
If called from within a tag plugin pass the tag's parent object:
shelp->
SetOwner
(tag->
GetObject
())
If called from within an object plugin use:
shelp->
SetOwner
((
BaseObject
*)node->Get())
|
◆
GetDirty()
Gets the dirty value for the
SplineHelp
which indicates how often the help has been updated with new values. i.e. how often the source spline has changed, and or the spline has been cleared.
-
由于
-
R17.032
-
返回
-
The dirty checksum.
◆
GetPointMatrix()
矩阵
GetPointMatrix
|
(
|
Int32
|
splineVertexIndex
|
)
|
|
Gets the matrix for a spline vertex.
-
由于
-
R17.032
-
参数
-
[in]
|
splineVertexIndex
|
The zero-based index of the spline vertex.
|
-
返回
-
The resulting
矩阵
for that point along the spline.
◆
GetLineObject()
Gets a
LineObject
from
SplineHelp
函数。
-
警告
-
Call
InitSpline()
with
SPLINEHELPFLAGS::RETAINLINEOBJECT
for this method to return a line object.
-
由于
-
R17.032
-
返回
-
The line object.
nullptr
if it fails or if the
SplineHelp
was not initialized with
SPLINEHELPFLAGS::RETAINLINEOBJECT
.
◆
GetSplineObjectCache()
Get the cached
SplineObject
。
SplineHelp
owns the pointed
SplineObject
.
-
注意
-
Deformations are already computed on this
SplineObject
.
-
警告
-
Call
InitSpline()
before.
-
返回
-
The cache object.
nullptr
if it fails or if the
SplineHelp
was not initialized.
◆
InitSpline()
[1/3]
Initializes the
SplineHelp
with the passed spline
op
, must be called before any other functions can be utilized.
-
警告
-
Must be called before any other access.
-
由于
-
R17.032
-
参数
-
[in]
|
op
|
The spline object to initialize from. The caller owns the pointed spline object.
|
[in]
|
flags
|
The optional flags used to control how the
SplineHelp
is setup:
SPLINEHELPFLAGS
|
-
返回
-
true
若
SplineHelp
was successfully initialized, otherwise
false
.
◆
InitSpline()
[2/3]
Initializes the
SplineHelp
with the passed spline
op
, must be called before any other functions can be utilized.
-
警告
-
Must be called before any other access.
-
由于
-
R17.032
-
参数
-
[in]
|
op
|
The spline object to initialize from. The caller owns the pointed spline object.
|
[in]
|
upvector
|
The initial up-vector for the spline if no rail spline is passed.
|
[in]
|
flags
|
The optional flags used to control how the
SplineHelp
is setup:
SPLINEHELPFLAGS
|
-
返回
-
true
若
SplineHelp
was successfully initialized, otherwise
false
.
◆
InitSpline()
[3/3]
Initializes the
SplineHelp
with the passed spline
op
, must be called before any other functions can be utilized.
-
警告
-
Must be called before any other access.
-
由于
-
R17.032
-
参数
-
[in]
|
op
|
The
SplineObject
to initialize from. The caller owns the pointed spline object.
|
[in]
|
rail
|
The rail spline. The caller owns the pointed spline object.
|
[in]
|
flags
|
The optional flags used to control how the
SplineHelp
is setup:
SPLINEHELPFLAGS
|
-
返回
-
true
若
SplineHelp
was successfully initialized, otherwise
false
.
void SetOwner(BaseObject *op)
Represents a C4DAtom that resides in a 4D list.
定义:
c4d_baselist.h:1767
Bool InitSpline(BaseObject *op, SPLINEHELPFLAGS flags=SPLINEHELPFLAGS::GLOBALSPACE|SPLINEHELPFLAGS::CONTINUECURVE)
#define INSTANCEOF(X, Y)
定义:
c4d_baselist.h:38
BaseObject * GetObject(void)
定义:
c4d_basetag.h:95
maxon::Bool Bool
定义:
ge_sys_math.h:53