-
首页
-
C4D R23.110 C++ SDK
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
);
延伸阅读
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)
#define DebugStop(...)
定义:
debugdiagnostics.h:228
定义:
c4d_fieldplugin.h:108
virtual void FreeSampling(FieldLayer &layer, const FieldInfo &info, FieldShared &shared)
定义:
c4d_fieldplugin.h:162
maxon::Int Int
定义:
ge_sys_math.h:62
virtual maxon::Result< void > InitSampling(FieldLayer &layer, const FieldInfo &info, FieldShared &shared)
定义:
c4d_fieldplugin.h:126
#define FIELDLAYER_NOVALUEOUT
The FieldLayer doesn't calculate values.
定义:
ge_prepass.h:925
#define FIELDLAYER_NOROTATIONOUT
The FieldLayer doesn't calculate rotational velocities.
定义:
ge_prepass.h:931
virtual Bool IsEqual(const FieldLayer &layer, const FieldLayerData &comp) const
定义:
c4d_fieldplugin.h:171
maxon::Float Float
定义:
ge_sys_math.h:64
Float32 FMod(Float32 v1, Float32 v2)
定义:
apibasemath.h:183
#define FIELDLAYER_PREMULTIPLIED
The FieldLayer will receive FieldOutputBlock data premultiplied by alpha values.
定义:
ge_prepass.h:930
return OK
定义:
apibase.h:2532
virtual maxon::Result< void > Sample(const FieldLayer &layer, const FieldInput &inputs, FieldOutputBlock &outputs, const FieldInfo &info) const =0
#define MAXON_SOURCE_LOCATION
定义:
memoryallocationbase.h:66
Thread local information for this field sample invocation.
定义:
c4d_fielddata.h:904
Bool GetParameter(const DescID &id, GeData &t_data) const
定义:
c4d_basecontainer.h:628
const BaseContainer & GetDataInstanceRef() const
定义:
c4d_baselist.h:2299
#define INSTANCEOF(X, Y)
定义:
c4d_baselist.h:38
#define NewObj(T,...)
定义:
newobj.h:108
#define iferr(...)
定义:
errorbase.h:380
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
maxon::Bool Bool
定义:
ge_sys_math.h:53
#define FIELDLAYER_NODIRECTIONOUT
The FieldLayer doesn't calculate directions.
定义:
ge_prepass.h:927
定义:
c4d_basecontainer.h:46
#define FIELDLAYER_DIRECT
The FieldLayer will have access to directly manipulate the 'result' data in ModifyValues rather than ...
定义:
ge_prepass.h:923
Float GetFloat(void) const