NodeData::GetDParameter() Manual

内容表

关于

NodeData based classic plugin classes can implement NodeData::GetDParameter() . This allows to define the values of parameters accessed with C4DAtom::GetParameter() . This is done to handle data that is not stored in the object's BaseContainer . It is also used to create parameters that depend on the value of other parameters or element properties.

NodeData::GetDParameter() corresponds to C4DAtom::GetParameter() .

注意
In most cases, when implementing NodeData::GetDParameter() , one will also need to implement NodeData::SetDParameter() . For example, if the value is stored in a member variable.

用法

NodeData::GetDParameter() is called when the value of a parameter is accessed with C4DAtom::GetParameter() . It is possible to define or change the returned value.

Bool GetDParameter( GeListNode * node, const DescID & id , GeData & t_data, DESCFLAGS_GET & flags) { if (node == nullptr ) return false ;

// check parameter ID switch ( id [0]. id ) { // This parameter is not stored in the BaseContainer case EXAMPLE_GENERATOR_PARAMETER_NOT_BC: { // set the value from a member variable t_data. SetInt32 (_value);

// Parameter retrieved. flags |= DESCFLAGS_GET::PARAM_GET ;

return true ; } }
return SUPER::GetDParameter(node, id , t_data, flags); }
注意
Such member variables must also be handled in NodeData::Read() , NodeData::Write() , NodeData::CopyTo() and NodeData::SetDParameter() .

The arguments of the function are:

Certain cases have to be handled with special functions:

Further Examples

// This example of a TagData plugin defines the value of the // Tag's parameter by calculating the volume of the host object. Bool GetDParameter( GeListNode * node, const DescID & id , GeData & t_data, DESCFLAGS_GET & flags) { if (node == nullptr ) return false ;

// check parameter ID switch ( id [0]. id ) { case EXAMPLE_TAG_VOLUME: { Float volume = 0.0; GeData data; BaseTag * const tag = static_cast< BaseTag * > (node); if (tag != nullptr ) { BaseObject * const hostObject = tag-> GetObject (); if (hostObject != nullptr ) { // check the object type switch (hostObject-> GetType ()) { // calculate volume of sphere primitive case Osphere : { hostObject-> GetParameter ( PRIM_SPHERE_RAD , data, DESCFLAGS_GET::NONE ); const Float radius = data. GetFloat (); volume = (4.0 / 3.0) * maxon::PI * radius * radius * radius; break ; } // calculate volume of cylinder primitive case Ocylinder : { hostObject-> GetParameter ( PRIM_CYLINDER_RADIUS , data, DESCFLAGS_GET::NONE ); const Float radius = data. GetFloat (); hostObject-> GetParameter ( PRIM_CYLINDER_HEIGHT , data, DESCFLAGS_GET::NONE ); const Float height = data. GetFloat (); volume = maxon::PI * radius * radius * height; break ; } // etc. default : break ; } } } t_data. SetFloat (volume); flags |= DESCFLAGS_GET::PARAM_GET ; // don't forget to set this flag

return true ; } } return SUPER::GetDParameter(node, id , t_data, flags); }

延伸阅读

PRIM_CYLINDER_HEIGHT
@ PRIM_CYLINDER_HEIGHT
定义: ocylinder.h:13
BaseObject
定义: c4d_baseobject.h:224
DescID
定义: lib_description.h:327
Float
maxon::Float Float
定义: ge_sys_math.h:64
BaseTag
定义: c4d_basetag.h:46
Ocylinder
#define Ocylinder
Cylinder.
定义: ge_prepass.h:1051
PRIM_SPHERE_RAD
@ PRIM_SPHERE_RAD
定义: osphere.h:6
maxon::PI
static constexpr Float64 PI
floating point constant: PI
定义: apibasemath.h:139
DESCFLAGS_GET
DESCFLAGS_GET
定义: ge_prepass.h:3099
GeListNode
Represents a C4DAtom that resides in a 4D list.
定义: c4d_baselist.h:1767
Osphere
#define Osphere
Sphere.
定义: ge_prepass.h:1041
GeData::SetFloat
void SetFloat(Float v)
定义: c4d_gedata.h:567
GeData
定义: c4d_gedata.h:82
GeData::SetInt32
void SetInt32(Int32 v)
定义: c4d_gedata.h:573
PRIM_CYLINDER_RADIUS
@ PRIM_CYLINDER_RADIUS
定义: ocylinder.h:8
DESCFLAGS_GET::NONE
@ NONE
None.
BaseTag::GetObject
BaseObject * GetObject(void)
定义: c4d_basetag.h:95
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
DESCFLAGS_GET::PARAM_GET
@ PARAM_GET
Parameter retrieved.
C4DAtom::GetType
Int32 GetType() const
定义: c4d_baselist.h:1348
C4DAtom::GetParameter
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
GeData::GetFloat
Float GetFloat(void) const
定义: c4d_gedata.h:439

Copyright  © 2014-2025 乐数软件    

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