FieldObject Manual

About

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.

FieldObject

A new FieldObjects is created with the usual tools:

// This example creates a new "Random" field object.
// 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);
Definition: c4d_fielddata.h:1022
static FieldObject * Alloc(Int32 type)
Definition: c4d_fielddata.h:1034
static const Int32 Frandom
Random/noise field.
Definition: c4d_fielddata.h:55
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
const char * doc
Definition: pyerrors.h:226

Sampling Fields

A FieldObject can be sampled using FieldObject::Sample(). How the field is sampled is defined using the classes FieldInfo, FieldShared, FieldInput and FieldOutput.

// This example samples the given FieldObject.
// prepare arrays for sample points
positions.Resize(sampleCnt) iferr_return;
uvws.Resize(sampleCnt) iferr_return;
directions.Resize(sampleCnt) iferr_return;
// set positions
Float64 xOffset = 0.0;
for (maxon::Vector& pos : positions)
{
pos.x = xOffset;
xOffset += stepSize;
}
// prepare results
FieldOutput results;
FieldOutputBlock block = results.GetBlock();
// define points to sample
FieldInput points(positions.GetFirst(),
directions.GetFirst(),
uvws.GetFirst(),
sampleCnt,
Matrix());
// context
maxon::GenericData extraData;
// sample the object
fieldObject->Sample(points, block, info, extraData) iferr_return;
fieldObject->FreeSampling(info, extraData);
maxon::Result< void > Sample(const FieldInput &inputs, FieldOutputBlock &outputs, const FieldInfo &info, const maxon::GenericData &extraData, const FIELDOBJECTSAMPLE_FLAG &objectSampleFlags=FIELDOBJECTSAMPLE_FLAG::NONE) const
Definition: c4d_fielddata.h:1074
void FreeSampling(const FieldInfo &info, maxon::GenericData &extraData) const
Definition: c4d_fielddata.h:1062
maxon::Result< maxon::GenericData > InitSampling(const FieldInfo &info) const
Definition: c4d_fielddata.h:1055
Definition: basearray.h:415
MAXON_ATTRIBUTE_FORCE_INLINE const T * GetFirst() const
Definition: basearray.h:1166
ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
Definition: basearray.h:1209
void Py_ssize_t * pos
Definition: dictobject.h:50
maxon::Float64 Float64
Definition: ge_sys_math.h:67
@ VALUE
Sample only the value at the current point (minimum must still sample the value)
_Py_clock_info_t * info
Definition: pytime.h:197
#define iferr_return
Definition: resultbase.h:1521
Thread local information for this field sample invocation.
Definition: c4d_fielddata.h:840
static maxon::Result< FieldInfo > Create(const BaseList2D *caller, FIELDSAMPLE_FLAG callingFlags=FIELDSAMPLE_FLAG::VALUE)
Definition: c4d_fielddata.h:472
Definition: c4d_fielddata.h:345
Definition: c4d_fielddata.h:115
FieldOutputBlock GetBlock()
maxon::Result< void > Resize(Int newSize, FIELDSAMPLE_FLAG sampleFlags=FIELDSAMPLE_FLAG::ALL, maxon::COLLECTION_RESIZE_FLAGS resizeFlags=maxon::COLLECTION_RESIZE_FLAGS::DEFAULT)

FieldInfo

A FieldInfo object provides information on the context of the sampling operation.

A FieldInfo object is created with:

Members:

Flags FIELDSAMPLE_FLAG:

FieldShared

FieldShared is the object reponsible to share data between fields.

  • FieldShared::Flush(): Flushes the data.
  • FieldShared::CopyFrom(): Copies the data from the given FieldShared object.
  • FieldShared::ResetDirty(): Resets the dirty count.

The public members are:

  • FieldShared::_finalOutput
  • FieldShared::_finalOutputDirty
  • FieldShared::_customData: Custom data (BaseContainer) to be used.
  • FieldShared::_customDataDirty: Dirty state of the custom data.

FieldInput

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:

FieldOutput

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:

FieldCallerStack

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:

Further Reading