FieldObject Manual
A FieldObject represents a field in the Cinema 4D scene. Such a field can be sampled in 3D space to obtain values and colors. Field objects are typically used with MoGraph effectors.
A FieldObject is an instance of Ofield .
A new FieldObjects is created with the usual tools:
// allocate random field object FieldObject * const fieldObject = FieldObject::Alloc ( Frandom ); if (fieldObject == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
// insert into the document doc-> InsertObject (fieldObject, nullptr , nullptr );
A FieldObject can be sampled using FieldObject::Sample() . How the field is sampled is defined using the classes FieldInfo , FieldShared , FieldInput and FieldOutput .
// prepare arrays for sample points maxon::BaseArray<maxon::Vector> positions; positions. Resize (sampleCnt) iferr_return ;
// set positions Float64 xOffset = 0.0; for ( maxon::Vector & pos : positions) { pos. x = xOffset; xOffset += stepSize; }
// prepare results FieldOutput results; results. Resize (sampleCnt, FIELDSAMPLE_FLAG::VALUE ) iferr_return ; FieldOutputBlock block = results. GetBlock ();
// define points to sample FieldInput points(positions.GetFirst(), directions. GetFirst (), uvws. GetFirst (), sampleCnt, 矩阵 ());
// context const FieldInfo info = FieldInfo::Create (caller, points, FIELDSAMPLE_FLAG::VALUE ) iferr_return ;
// shared data FieldShared shared;
// sample the object fieldObject-> InitSampling (info, shared) iferr_return ; fieldObject-> Sample (points, block, info) iferr_return ; fieldObject-> FreeSampling (info, shared);
A FieldInfo object provides information on the context of the sampling operation.
A FieldInfo object is created with:
Members:
Flags FIELDSAMPLE_FLAG :
FieldShared is the object reponsible to share data between fields.
The public members are:
A FieldInput object defines points in space that should be sampled. Optionally further data like directions or UV-coordinates can be added.
The public members are:
A FieldOutput object stores the data generated by the sampling process.
A FieldOutput can be created with:
These functions are provided:
The public members are:
The FieldCallerStack defines the list of BaseList2D objects calling the sampling function. If no object is calling the sampling function, an unique ID (UInt) must be provided.
The stack data is accessed with:
Public members are: