FieldData Manual

内容表

关于

FieldData is the base class for custom field objects (see FieldObject Manual ).

A new FieldData based class is registered with RegisterFieldPlugin() .

FieldData

In a FieldData based class the following functions can be implemented:

For related data types see FieldObject Manual .

范例

// This example shows the implementation of a custom field object.

// ------------------------------------------------------------------------------ // This example field defines the field value based on the global space position. // ------------------------------------------------------------------------------ class ExampleField : public FieldData { INSTANCEOF (ExampleField, FieldData )

public : // ------------------------------------------------------------------------------ // Allocation of a new instance // @return New ExampleField instance or nullptr. // ------------------------------------------------------------------------------ static NodeData * Alloc() { iferr ( NodeData * const result = NewObj (ExampleField)) { DebugStop (); return nullptr ; } return result; }
virtual maxon::Result<void> InitSampling ( FieldObject & op, const FieldInfo & info, FieldShared & shared) { // calculation done before sampling return maxon::OK ; } virtual void FreeSampling ( FieldObject & op, const FieldInfo & info, FieldShared & shared) { // freeing internal data after sampling } virtual maxon::Result<void> Sample ( const FieldObject & op, const FieldInput & inputs, FieldOutputBlock & outputs, const FieldInfo & info) const { // handle each input position for ( Int i = inputs. _blockCount - 1; i >= 0; --i) { // get position const 向量 pos = inputs. _position [i];

// calculate value const Float distance = pos. GetLength (); const Float value = distance / 1000.0;

// set value outputs. _value [i] = value; } return maxon::OK ; } virtual FIELDOBJECT_FLAG GetFieldFlags ( const FieldObject & op, BaseDocument * doc) const { return FIELDOBJECT_FLAG::NONE ; } };

// This example registeres the given FieldData plugin. const Bool registerFieldSuccess = RegisterFieldPlugin (fieldPluginID, "Example Field" _s, "Global Falloff" _s, 0, ExampleField::Alloc, "fexample" _s, nullptr , 0); if (registerFieldSuccess == false ) return maxon::UnknownError( MAXON_SOURCE_LOCATION );

延伸阅读

DebugStop
#define DebugStop(...)
定义: debugdiagnostics.h:228
FieldObject
定义: c4d_fielddata.h:1086
Int
maxon::Int Int
定义: ge_sys_math.h:62
maxon::Vec3::GetLength
constexpr T GetLength() const
Returns the length of the vector.
定义: vec.h:405
FieldOutputBlock
定义: c4d_fielddata.h:342
Float
maxon::Float Float
定义: ge_sys_math.h:64
FieldData::Sample
virtual maxon::Result< void > Sample(const FieldObject &op, const FieldInput &inputs, FieldOutputBlock &outputs, const FieldInfo &info) const =0
maxon::OK
return OK
定义: apibase.h:2532
FieldInput::_blockCount
Int _blockCount
The number of elements in the array to be processed (for this processing block, this should be treate...
定义: c4d_fielddata.h:709
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
FieldInfo
Thread local information for this field sample invocation.
定义: c4d_fielddata.h:904
NodeData
定义: c4d_nodedata.h:38
FieldInput::_position
maxon::Block< const Vector > _position
The position values for the array of points, if this is a sub-block then element 0 is at _blockOffset...
定义: c4d_fielddata.h:706
FIELDOBJECT_FLAG::NONE
@ NONE
No flags.
FieldData::FreeSampling
virtual void FreeSampling(FieldObject &op, const FieldInfo &info, FieldShared &shared)
定义: c4d_fieldplugin.h:82
maxon::Result< void >
maxon::Vec3< maxon::Float64, 1 >
FIELDOBJECT_FLAG
FIELDOBJECT_FLAG
定义: ge_prepass.h:5497
FieldData::InitSampling
virtual maxon::Result< void > InitSampling(FieldObject &op, const FieldInfo &info, FieldShared &shared)
定义: c4d_fieldplugin.h:74
FieldShared
定义: c4d_fielddata.h:478
RegisterFieldPlugin
Bool RegisterFieldPlugin(Int32 id, const maxon::String &name, const maxon::String &help, Int32 info, DataAllocator *g, const maxon::String &description, BaseBitmap *icon, Int32 disklevel)
INSTANCEOF
#define INSTANCEOF(X, Y)
定义: c4d_baselist.h:38
FieldData::GetFieldFlags
virtual FIELDOBJECT_FLAG GetFieldFlags(const FieldObject &op, BaseDocument *doc) const
定义: c4d_fieldplugin.h:105
FieldInput
定义: c4d_fielddata.h:537
NewObj
#define NewObj(T,...)
定义: newobj.h:108
iferr
#define iferr(...)
定义: errorbase.h:380
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
FieldOutputBlock::_value
maxon::Block< Float > _value
定义: c4d_fielddata.h:461
BaseDocument
定义: c4d_basedocument.h:490
FieldData
定义: c4d_fieldplugin.h:20

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1