DescID Manual

内容表

关于

Parameters of C4DAtom based elements are identified using a DescID object. Such a DescID object is composed of several levels of DescLevel objects. In this way DescIDs can reflect the structure of complex data types. For example a 向量 consists of three Float values. With the first DescLevel the 向量 is accessed as a whole, with the second DescLevel the three Float components can be accessed individually.

// This example reads two parameters from the given "Landscape" object.
GeData data;

// get the "Scale" parameter

const DescID scaleID = DescLevel { PRIM_FRACTAL_SCALE , DTYPE_REAL , 0 };

// read the "Scale" parameter if (!landscape->GetParameter(scaleID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); const Float scale = data. GetFloat (); ApplicationOutput ( "Scale: " + String::FloatToString (scale));

// get the x component of the "Size" parameter const DescLevel fractalLenLevel( PRIM_FRACTAL_LEN , DTYPE_VECTOR , 0); const DescLevel vectorXLevel( VECTOR_X , DTYPE_REAL , 0); const DescID sizeXID = DescID (fractalLenLevel, vectorXLevel);

// read the x-component of the "Size" parameter if (!landscape->GetParameter(sizeXID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); const Float sizeX = data. GetFloat (); ApplicationOutput ( "Size X: " + String::FloatToString (sizeX));

User data parameters are stored in a sub-container with the ID ID_USERDATA .

// This example reads the user data parameters 1 and 2 of the given object. GeData data; const DescLevel userDataLevel( ID_USERDATA , DTYPE_SUBCONTAINER , 0); const DescLevel firstParameter(1, DTYPE_REAL , 0); const DescID floatParameterID = DescID (userDataLevel, firstParameter);

// read the user data parameter 1 if (object-> GetParameter (floatParameterID, data, DESCFLAGS_GET::NONE )) { const String floatStr = String::FloatToString (data. GetFloat ()); ApplicationOutput ( "Float value: " + floatStr); } const DescLevel secondParameter(2, DTYPE_VECTOR , 0); const DescLevel vectorXLevel( VECTOR_X , DTYPE_REAL , 0); const DescID vectorSubParameterID = DescID (userDataLevel, secondParameter, vectorXLevel);

// read the x-component of the user data parameter 2 if (object-> GetParameter (vectorSubParameterID, data, DESCFLAGS_GET::NONE )) { const String floatStr = String::FloatToString (data. GetFloat ()); ApplicationOutput ( "Vector X value: " + floatStr); }

DescID

A DescID object identifies a parameter.

注意
A DescID can be stored in a GeData or BaseContainer using the custom data type CUSTOMDATATYPE_DESCID .

创建

DescID objects can be created with different constructors:

// This example reads the "Radius" parameter of the given sphere object // with differently constructed DescIDs. GeData data; DescID radiusID = DescID ( PRIM_SPHERE_RAD );

// read "Radius" parameter if (!sphere-> GetParameter (radiusID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); MAXON_SCOPE { const Float radius = data. GetFloat (); ApplicationOutput ( "Radius: " + String::FloatToString (radius)); } radiusID = DescID ( DescLevel ( PRIM_SPHERE_RAD , DTYPE_REAL , 0));

// read "Radius" parameter if (!sphere-> GetParameter (radiusID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); MAXON_SCOPE { const Float radius = data. GetFloat (); ApplicationOutput ( "Radius: " + String::FloatToString (radius)); }

注意
Typically a DescID constructed by using only the parameter ID is sufficient. For specialized uses like animation tracks or takes the fully constructed DescID might be needed.

Functionality

A complex DescID object with several levels can be constructed with these tools:

// This example constructs a DescID and uses it to access a parameter. GeData data; DescID sizeXID; sizeXID. PushId ( DescLevel ( PRIM_FRACTAL_LEN , DTYPE_VECTOR , 0)); sizeXID. PushId ( DescLevel ( VECTOR_X , DTYPE_REAL , 0));

// read the x-component of the "Size" parameter if (!landscape->GetParameter(sizeXID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); const Float sizeX = data. GetFloat (); ApplicationOutput ( "Size X: " + String::FloatToString (sizeX));

The levels of a DescID object can also be edited with these operators:

// This example constructs a DescID and uses it to access a parameter. GeData data; DescID sizeXID; sizeXID += DescLevel ( PRIM_FRACTAL_LEN , DTYPE_VECTOR , 0); sizeXID += DescLevel ( VECTOR_X , DTYPE_REAL , 0);

// read the x-component of the "Size" parameter if (!landscape->GetParameter(sizeXID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); const Float sizeX = data. GetFloat (); ApplicationOutput ( "Size X: " + String::FloatToString (sizeX));

注意
The + operator does not work like an integer addition. Important, when constructing parameter IDs dynamically.

Further functions are:

// This example loops through the levels of the given DescID. const Int32 depth = descID. GetDepth (); for ( Int32 i = 0; i < depth; ++i) { const DescLevel level = descID[i]; ApplicationOutput ( "ID: " + String::IntToString (level. id )); }

Disc I/O

DescID objects can be stored in a HyperFile .

DescLevel

A DescLevel represents a level of a DescID parameter ID.

创建

DescLevel objects can be created with different constructors:

// This example reads the "Radius" parameter of the given sphere object // with differently constructed DescLevels. GeData data; DescID radiusID = DescID ( DescLevel ( PRIM_SPHERE_RAD ));

// read the "Radius" parameter if (!sphere-> GetParameter (radiusID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); MAXON_SCOPE { const Float radius = data. GetFloat (); ApplicationOutput ( "Radius: " + String::FloatToString (radius)); } radiusID = DescID ( DescLevel ( PRIM_SPHERE_RAD , DTYPE_REAL , 0));

// read the "Radius" parameter if (!sphere-> GetParameter (radiusID, data, DESCFLAGS_GET::NONE )) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); MAXON_SCOPE { const Float radius = data. GetFloat (); ApplicationOutput ( "Radius: " + String::FloatToString (radius)); }

属性

The public attributes of a DescLevel are:

// This example prints the components of the first level of the given DescID. // GetObjectName() assumes that the creator ID is the ID of a BaseObject. const DescLevel level = descID[0]; const String levelIdStr = String::IntToString (level. id ); ApplicationOutput ( "ID: " + levelIdStr); const String levelDtypeStr = String::IntToString (level. dtype ); ApplicationOutput ( "Type: " + levelDtypeStr); const String levelCreatorStr = String::IntToString (level. creator ); const String levelCreatorName = GetObjectName (level. creator ); ApplicationOutput ( "Creator: " + levelCreatorStr + " (" + levelCreatorName + ")" );

比较

Two DescLevel objects can be compared with:

延伸阅读

String::FloatToString
static String FloatToString(Float32 v, Int32 vvk=-1, Int32 nnk=-3)
定义: c4d_string.h:529
DescID
定义: lib_description.h:327
DTYPE_SUBCONTAINER
@ DTYPE_SUBCONTAINER
Sub-container.
定义: lib_description.h:58
VECTOR_X
@ VECTOR_X
X component.
定义: lib_description.h:267
Float
maxon::Float Float
定义: ge_sys_math.h:64
DescID::GetDepth
Int32 GetDepth() const
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
PRIM_SPHERE_RAD
@ PRIM_SPHERE_RAD
定义: osphere.h:6
DescLevel::id
Int32 id
ID of the level.
定义: lib_description.h:288
ID_USERDATA
#define ID_USERDATA
User data ID.
定义: lib_description.h:25
DescLevel::dtype
Int32 dtype
Data type. Either a custom ID or one of these: DTYPE.
定义: lib_description.h:289
String
定义: c4d_string.h:38
String::IntToString
static String IntToString(Int32 v)
定义: c4d_string.h:495
GetObjectName
String GetObjectName(Int32 type)
DTYPE_VECTOR
@ DTYPE_VECTOR
向量
定义: lib_description.h:70
DescLevel
Represents a level within a DescID.
定义: lib_description.h:286
GeData
定义: c4d_gedata.h:82
DescID::PushId
void PushId(const DescLevel &subid)
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
PRIM_FRACTAL_SCALE
@ PRIM_FRACTAL_SCALE
定义: ofractal.h:12
PRIM_FRACTAL_LEN
@ PRIM_FRACTAL_LEN
定义: ofractal.h:7
DESCFLAGS_GET::NONE
@ NONE
None.
DescLevel::creator
Int32 creator
Creator ID.
定义: lib_description.h:290
DTYPE_REAL
@ DTYPE_REAL
Float
定义: lib_description.h:68
C4DAtom::GetParameter
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
MAXON_SCOPE
#define MAXON_SCOPE
定义: apibase.h:2645
GeData::GetFloat
Float GetFloat(void) const
定义: c4d_gedata.h:439

Copyright  © 2014-2025 乐数软件    

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