FieldLayerData Manual

内容表

关于

FieldLayerData is the base class for custom field layers ( FieldLayer )

A new FieldLayerData based class is registered with RegisterFieldLayerPlugin() .

FieldLayerData

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

注册

A FieldLayerData based class has to be registered with RegisterFieldLayerPlugin() . The flags are:

注意
Modifier layers are registered with FIELDLAYER_DIRECT .

范例

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

// ------------------------------------------------------------------------------ // This example field layer shifts the hue of the sample color. // ------------------------------------------------------------------------------ class HueShiftFieldLayer : public FieldLayerData { INSTANCEOF (HueShiftFieldLayer, FieldLayerData )

public : // ------------------------------------------------------------------------------ // Allocation of a new instance // @return New HueShiftFieldLayer instance or nullptr. // ------------------------------------------------------------------------------ static NodeData * Alloc() { iferr ( NodeData * const result = NewObj (HueShiftFieldLayer)) { DebugStop (); return nullptr ; } return result; }
virtual maxon::Result<void> InitSampling ( FieldLayer & layer, const FieldInfo & info, FieldShared & shared) { // store data for faster access during sampling const BaseContainer & layerBc = layer. GetDataInstanceRef (); GeData data; if (layerBc. GetParameter (FIELDLAYER_HUESHIFT_OFFSET, data) == false ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); _offset = data. GetFloat (); return maxon::OK ; } virtual maxon::Result<void> Sample ( const FieldLayer & layer, const FieldInput & inputs, FieldOutputBlock & outputs, const FieldInfo & info) const { // handle each input position for ( Int i = inputs. _blockCount - 1; i >= 0; --i) { // get the color hue const 向量 color = outputs. _color [i]; 向量 hsv = RGBToHSV (color); Float hue = hsv. x ;

// hue shift hue = FMod (hue + _offset, 1.0);

// store new color hsv. x = hue; outputs. _color [i] = HSVToRGB (hsv); } return maxon::OK ; } virtual void FreeSampling ( FieldLayer & layer, const FieldInfo & info, FieldShared & shared) { // free internal data after sampling } virtual Bool IsEqual ( const FieldLayer & layer, const FieldLayerData & comp) const { return true ; } private : Float _offset = 0.0_f; };

// This example registeres the given FieldLayerData plugin. const Bool registerFieldLayerSuccess = RegisterFieldLayerPlugin (fieldLayerPluginID, "Hue Shift Layer" _s, "Changes the color hue." _s, "Hue Shift Layer" _s, FIELDLAYER_PREMULTIPLIED | FIELDLAYER_DIRECT | FIELDLAYER_NOVALUEOUT | FIELDLAYER_NODIRECTIONOUT | FIELDLAYER_NOROTATIONOUT , HueShiftFieldLayer::Alloc, "Flhueshift" _s, nullptr , 0, nullptr ); if (registerFieldLayerSuccess == false ) return maxon::UnknownError( MAXON_SOURCE_LOCATION );

延伸阅读

RegisterFieldLayerPlugin
Bool RegisterFieldLayerPlugin(Int32 id, const maxon::String &name, const maxon::String &help, const maxon::String &pickInstruction, Int32 info, DataAllocator *g, const maxon::String &description, BaseBitmap *icon, Int32 disklevel, FieldLayerAcceptDragFunction *dragFunc=nullptr)
DebugStop
#define DebugStop(...)
定义: debugdiagnostics.h:228
FieldLayer
定义: c4d_fielddata.h:1151
FieldLayerData
定义: c4d_fieldplugin.h:108
FieldLayerData::FreeSampling
virtual void FreeSampling(FieldLayer &layer, const FieldInfo &info, FieldShared &shared)
定义: c4d_fieldplugin.h:162
Int
maxon::Int Int
定义: ge_sys_math.h:62
FieldLayerData::InitSampling
virtual maxon::Result< void > InitSampling(FieldLayer &layer, const FieldInfo &info, FieldShared &shared)
定义: c4d_fieldplugin.h:126
FIELDLAYER_NOVALUEOUT
#define FIELDLAYER_NOVALUEOUT
The FieldLayer doesn't calculate values.
定义: ge_prepass.h:925
FIELDLAYER_NOROTATIONOUT
#define FIELDLAYER_NOROTATIONOUT
The FieldLayer doesn't calculate rotational velocities.
定义: ge_prepass.h:931
FieldOutputBlock
定义: c4d_fielddata.h:342
FieldLayerData::IsEqual
virtual Bool IsEqual(const FieldLayer &layer, const FieldLayerData &comp) const
定义: c4d_fieldplugin.h:171
Float
maxon::Float Float
定义: ge_sys_math.h:64
FMod
Float32 FMod(Float32 v1, Float32 v2)
定义: apibasemath.h:183
FIELDLAYER_PREMULTIPLIED
#define FIELDLAYER_PREMULTIPLIED
The FieldLayer will receive FieldOutputBlock data premultiplied by alpha values.
定义: ge_prepass.h:930
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
FieldLayerData::Sample
virtual maxon::Result< void > Sample(const FieldLayer &layer, const FieldInput &inputs, FieldOutputBlock &outputs, const FieldInfo &info) const =0
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
HSVToRGB
Vector HSVToRGB(const Vector &col)
FieldInfo
Thread local information for this field sample invocation.
定义: c4d_fielddata.h:904
NodeData
定义: c4d_nodedata.h:38
maxon::Result< void >
BaseContainer::GetParameter
Bool GetParameter(const DescID &id, GeData &t_data) const
定义: c4d_basecontainer.h:628
maxon::Vec3< maxon::Float64, 1 >
BaseList2D::GetDataInstanceRef
const BaseContainer & GetDataInstanceRef() const
定义: c4d_baselist.h:2299
maxon::Vec3::x
T x
定义: vec.h:32
RGBToHSV
Vector RGBToHSV(const Vector &col)
FieldShared
定义: c4d_fielddata.h:478
GeData
定义: c4d_gedata.h:82
INSTANCEOF
#define INSTANCEOF(X, Y)
定义: c4d_baselist.h:38
FieldInput
定义: c4d_fielddata.h:537
NewObj
#define NewObj(T,...)
定义: newobj.h:108
iferr
#define iferr(...)
定义: errorbase.h:380
FieldOutputBlock::_color
maxon::Block< Vector > _color
The alpha value for color and direction at this point in space, only available when color or directio...
定义: c4d_fielddata.h:463
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
FIELDLAYER_NODIRECTIONOUT
#define FIELDLAYER_NODIRECTIONOUT
The FieldLayer doesn't calculate directions.
定义: ge_prepass.h:927
BaseContainer
定义: c4d_basecontainer.h:46
FIELDLAYER_DIRECT
#define FIELDLAYER_DIRECT
The FieldLayer will have access to directly manipulate the 'result' data in ModifyValues rather than ...
定义: ge_prepass.h:923
GeData::GetFloat
Float GetFloat(void) const
定义: c4d_gedata.h:439

Copyright  © 2014-2025 乐数软件    

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