HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Manipulating Attributes inside SOPs

Points, primitives, and vertices all can have custom attributes assigned to them. These attributes are accessed by name and are the same for all entities in a class. For example, if one point has a Cd attribute, all points will have the Cd attribute.

One special class of attribute is the Detail attribute. There is only one copy of a detail attribute per GU_Detail (hence the name) so is useful for storing global detail for that geometry.

While attributes are uniform within a GU_Detail, separate GU_Details can have different attributes of different types.

To simplify the handling of attributes the GEO_AttributeHandle class should be used to bind references to attributes. The GEO_Detail::getPointAttribute, GEO_Detail::getPrimAttribute, GEO_Detail::getVertexAttribute, and GEO_Detail::getDetailAttribute methods can be used to look up an attribute by name on a GU_Detail.

Creation of attributes is done with the GEO_Detail::addAttrib, GEO_Detail::addPointAttrib, GEO_Detail::addPrimAttrib, GEO_Detail::addVertexAttrib methods. Note these methods take the size of the attribute in bytes!

You may see code which uses the GA_GBElement::castAttribData method. This is deprecated and should be avoided, the GEO_AttributeHandle approach being preferred (see getsetAttributes, handleAccessAttributes).

An example on creating and modifying point attributes is found in SOP/SOP_TimeCompare.C and SOP/SOP_TimeCompare.h.

An example on creating a detail attribute is found in SOP/SOP_DetailAttrib.C and SOP/SOP_DetailAttrib.h.