Graph View Data Format (XPresso) Manual

Currently there are two ways to store data of variable type. The first one is GeData , the class that is used in most of the SDK for example in BaseContainer . The second one is the void* data that is used in Graph View. This document describes how the Graph View data type system works.

注意: Types registered with CustomDataTypeClass are automatically included in the Graph View type system as well.

Value vs. Data

The actual format of the data stored in the void* pointer is determined by its value, described by a GvValueID. This is all you need to know to be able to perform calculations with the data or convert it to other types.

Similar kinds of data can share a common value. The combination of a symbol/name and a value is called a data , described by a GvDataID. For example both the normal color data types could be implemented as a vector 值。

The different data types are grouped in value groups . However, currently there is only one group, so you can ignore this feature most of the time.

注意
FindCustomDataTypePlugin() will always return a valid plugin when fed a GvValueID. You cannot convert a GvValueID to a GvDataID directly, though you can do CallCustomDataType(pl, GetDataID).

Raw Format

For the common built-in types (Int32, Float, Vector, Matrix, BaseTime and String ) the void* pointer simply points to the data type in question. For custom data types it instead points to the GvHelper structure. Please observe that generally these pointers are to an array that you should index with the current CPU ID.

注意
Normally you should not need to manipulate these raw values.

Dynamic Data

GvDynamicData is a convenience structure that stores both the void* data pointer and a GvDataInfo structure with the handlers. There are several ways to get a dynamic data structure:

Many of these functions are implemented in clear code in c4d_graphview.h and c4d_graphview.cpp , so you can see how they work.

范例

Getting a GeData from a calculated port:

GeData GvGetPortGeData( GvNode * node, GvPort * port, GvRun * run, Bool * success) { if (success) *success = false ;
if (!node || !port) return GeData ();
GvPortDescription pd; if (!node-> GetPortDescription (port-> GetIO (), port-> GetMainID (), &pd)) return GeData (); GvDataInfo * info = GvGetWorld ()-> GetDataTypeInfo (pd. data_id ); if (!info) return GeData (); GvDynamicData data; GvAllocDynamicData (node, data, info); GeData result; if (port-> GetData (data. data , data. info -> value_handler -> value_id , run)) { CUSTOMDATATYPEPLUGIN* pl = FindCustomDataTypePlugin (data. info -> data_handler -> data_id ); if (pl && CallCustomDataType(pl, ConvertGvToGeData)(data. data , 0, result)) { if (success) *success = true ; } } GvFreeDynamicData (data); return result; }

Setting the port data from a GeData :

Bool GvSetPortGeData( const GeData & ge_data, GvNode * node, GvPort * port, GvRun * run) { if (!node || !port || !run) return false ; GvPortDescription pd; if (!node-> GetPortDescription (port-> GetIO (), port-> GetMainID (), &pd)) return false ; GvDataInfo * info = GvGetWorld ()-> GetDataTypeInfo (pd. data_id ); if (info== nullptr ) return false ; GvDynamicData data; GvAllocDynamicData (node, data, info); CUSTOMDATATYPEPLUGIN* pl = FindCustomDataTypePlugin (data. info -> data_handler -> data_id ); if (pl== nullptr ) return false ; if (!CallCustomDataType(pl, ConvertGeDataToGv)(ge_data, data. data , 0)) return false ; if (!port-> SetData (data. data , data. info -> value_handler -> value_id , run)) return false GvFreeDynamicData (data); return true ; }

Getting a Thinking Particles particle ID from a port:

Int32 GvGetParticleID( GvNode * node, GvPort * port, GvRun * run) { if (!port || !node || !run) return NOTOK ; GeData p = GvGetPortGeData(node, port, run); if (p. GetType () != ID_TP_DATA_TYPE_PARTICLE ) return NOTOK ; struct GvParticleHelper : public CustomDataType { Int32 * pid; }* helper = static_cast< GvParticleHelper* > (p. GetCustomDataType ( ID_TP_DATA_TYPE_PARTICLE )); if (!helper || !helper->pid) return NOTOK ; return *(helper->pid); } Setting a Thinking Particles particle ID in a port: Bool GvSetParticleID( Int32 pid, GvNode * node, GvPort * port, GvRun * run) { if (!port || !node || !run) return NOTOK ; struct GvParticleHelper : public CustomDataType { Int32 * pid; } helper; helper.pid = &pid; GeData p( ID_TP_DATA_TYPE_PARTICLE , helper); return GvSetPortGeData(p, node, port, run); }
GvPort::GetData
Bool GetData(void *d, GvValueID type, GvRun *r)
定义: c4d_graphview.h:1177
GvRun
Contains helper functions for controlling node evaluation. Cannot be instantiated.
定义: c4d_graphview.h:313
GvDynamicData
Represents a GV data and information about its data type.
定义: c4d_graphview_def.h:1243
FindCustomDataTypePlugin
CUSTOMDATATYPEPLUGIN * FindCustomDataTypePlugin(Int32 type)
GeData::GetType
Int32 GetType(void) const
定义: c4d_gedata.h:407
GvPortDescription
Port description data.
定义: c4d_graphview_def.h:1145
GvDataInfo::value_handler
GV_VALUE_HANDLER * value_handler
定义: c4d_graphview_def.h:1077
GvPortDescription::data_id
GvDataID data_id
Data type ID: GvDataID.
定义: c4d_graphview_def.h:1154
GvDynamicData::info
GvDataInfo * info
Data type information.
定义: c4d_graphview_def.h:1251
GvGetWorld
GvWorld * GvGetWorld(void)
GvDynamicData::data
void * data
Data pointer.
定义: c4d_graphview_def.h:1250
GV_DATA_HANDLER::data_id
GvDataID data_id
The data ID.
定义: c4d_graphview_def.h:1015
GvNode::GetPortDescription
Bool GetPortDescription(GvPortIO port, Int32 id, GvPortDescription *pd)
定义: c4d_graphview.h:618
GvAllocDynamicData
Bool GvAllocDynamicData(GvNode *bn, GvDynamicData &data, GvCalc *c, Int32 id)
定义: c4d_graphview.h:2697
GvPort::GetMainID
Int32 GetMainID(void)
定义: c4d_graphview.h:1006
GvDataInfo::data_handler
GV_DATA_HANDLER * data_handler
定义: c4d_graphview_def.h:1076
GvFreeDynamicData
void GvFreeDynamicData(GvDynamicData &data)
定义: c4d_graphview.h:2708
NOTOK
#define NOTOK
定义: ge_sys_math.h:265
GeData
定义: c4d_gedata.h:82
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
GvPort::GetIO
GvPortIO GetIO(void)
定义: c4d_graphview.h:994
GV_VALUE_HANDLER::value_id
GvValueID value_id
Value ID.
定义: c4d_graphview_def.h:858
CustomDataType
Base class for custom data types.
定义: c4d_customdatatype.h:50
GvPort::SetData
Bool SetData(const void *d, GvValueID type, GvRun *r)
定义: c4d_graphview.h:1274
ID_TP_DATA_TYPE_PARTICLE
#define ID_TP_DATA_TYPE_PARTICLE
Particle data type ID.
定义: c4d_particles.h:31
GeData::GetCustomDataType
CustomDataType * GetCustomDataType(Int32 datatype) const
定义: c4d_gedata.h:507
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
GvDataInfo
定义: c4d_graphview_def.h:1074
GvPort
定义: c4d_graphview.h:937
GvWorld::GetDataTypeInfo
GvDataInfo * GetDataTypeInfo(GvDataID id)
定义: c4d_graphview.h:2386
GvNode
定义: c4d_graphview.h:428

Copyright  © 2014-2025 乐数软件    

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