CustomDataTag Manual

内容表

关于

A CustomDataTag is a BaseTag that stores custom point or polygon data. It is a generalized tag type to store mesh-based data like normals, UVs, vertex colors etc. It can replace dedicated tags like NormalTag , UVWTag or VertexColorTag .

A CustomDataTag gives access to data and functionality implemented with maxon::MeshAttribute , maxon::MeshAttributeClassInterface , maxon::CustomDataTagClassInterface and maxon::CustomDataTagDisplayInterface (见 Mesh Attributes Interfaces ).

Creation

A CustomDataTag object is created using the usual tools and the specific data type ID:

// This example creates a CustomDataTag of the given type, adds // it to the given polygon object and sets it to vertex mode.

// create tag BaseTag * const tag = CustomDataTag::Alloc (ID_VERTEXSCALARTAG); if (tag == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

// insert tag polygonObject-> InsertTag (tag);

// init tag CustomDataTag * const customDataTag = static_cast< CustomDataTag * > (tag); customDataTag-> InitData () iferr_return ; customDataTag-> SetMode ( CUSTOMDATATAG_MODE::VERTEX );

数据类型

The data type stored in a given CustomDataTag is obtained with:

数据

A CustomDataTag can stores either point data ( CUSTOMDATATAG_MODE::VERTEX ) or polygon point data ( CUSTOMDATATAG_MODE::POLYVERTEX ):

The number of stored elements is returned with:

The stored vertex data is accessed with these functions:

// This example fills the given CustomDataTag with random values for each point.

// get number of components const Int count = customDataTag-> GetComponentCount ();

// for each component, set a random value maxon::LinearCongruentialRandom<maxon::Float32> random; for ( Int32 i = 0; i < count; ++i) { Float value = random. Get01 (); customDataTag-> SetVertexData < Float >(i, std::move(value)); }

The stored polygon data is accessed with:

// This example fills the given CustomDataTag with random values for each polygon vertex.

// get number for components const Int count = customDataTag-> GetComponentCount ();

// for each polygon set random values maxon::LinearCongruentialRandom<maxon::Float32> random; for ( Int32 i = 0; i < count; ++i) { // create polygon value maxon::Float value = random. Get01 ();

// set each point of the given polygon to that value for ( Int32 polyvertexIndex = 0; polyvertexIndex < 4; ++polyvertexIndex) { customDataTag-> SetPolyVertexData < maxon::Float >(i, polyvertexIndex, std::move(value)); } }

The maxon::PolyData template class stores data for either a triangle or quad:

// This example accesses the polygon point values of the // given CustomDataTag within MeshAttributeDisplay::DisplayControl().

// for each polygon of the object set the polygon vertex colors for ( Int32 polygonIndex = 0; polygonIndex < polyCount; ++polygonIndex) { // get polygon vertex data for the given polygon maxon::PolyData<Float> polygonData = customDataTag-> GetPolygonData < Float >(polygonIndex);

// set the color of each polygon vertex // the CustomDataTag always stores four point values for each polygon for ( Int32 pointIndex = 0; pointIndex < 4; ++pointIndex) { // get polygon vertex color // float value dispalyed in the red channel Color32 color { 0.0 }; color.r = maxon::Float32 (polygonData[pointIndex]);

// store polygon vertex color // "cds" is the ControlDisplayStruct argument const maxon::Int colorIndex = 4 * polygonIndex + pointIndex; cds.vertex_color[colorIndex] = static_cast< Color32 > (color); } }

// show polygon vertex color cds.perPolygonVertexColor = true ;

延伸阅读

Int
maxon::Int Int
定义: ge_sys_math.h:62
Float
maxon::Float Float
定义: ge_sys_math.h:64
maxon::Float32
float Float32
32 bit floating point value (float)
定义: apibase.h:178
maxon::Color32
Col3< Float32, 1 > Color32
定义: vector.h:74
BaseTag
定义: c4d_basetag.h:46
iferr_return
#define iferr_return
定义: resultbase.h:1434
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
maxon::Float
Float64 Float
定义: apibase.h:193
CUSTOMDATATAG_MODE::VERTEX
@ VERTEX
CustomDataTag::InitData
maxon::Result< void > InitData()
CustomDataTag::SetVertexData
void SetVertexData(Int32 vertexIndex, TYPE &&value)
定义: lib_customdatatag.h:279
CustomDataTag::GetComponentCount
Int GetComponentCount() const
maxon::Int
Int64 Int
signed 32/64 bit int, size depends on the platform
定义: apibase.h:184
CustomDataTag::SetMode
void SetMode(CUSTOMDATATAG_MODE mode)
maxon::LinearCongruentialRandom
定义: lib_math.h:18
CustomDataTag
定义: lib_customdatatag.h:47
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
CustomDataTag::SetPolyVertexData
void SetPolyVertexData(Int32 polygonIndex, Int32 polyVertexIndex, TYPE &&value)
定义: lib_customdatatag.h:327
maxon::PolyData
定义: mesh_attribute_utilities.h:13
CustomDataTag::GetPolygonData
const maxon::PolyData< TYPE > & GetPolygonData(Int32 polygonIndex) const
定义: lib_customdatatag.h:345
maxon::LinearCongruentialRandom::Get01
FLOAT Get01()
Returns the next random value in the range of [0..1].
BaseObject::InsertTag
void InsertTag(BaseTag *tp, BaseTag *pred=nullptr)
CustomDataTag::Alloc
static CustomDataTag * Alloc(Int32 tagId)

Copyright  © 2014-2025 乐数软件    

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