HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GT_AttributeBuilder Class Reference

#include <GT_AttributeBuilder.h>

Public Types

enum  { GT_BINDING_VERTEX, GT_BINDING_POINT, GT_BINDING_PRIMITIVE, GT_BINDING_DETAIL }
 

Public Member Functions

 GT_AttributeBuilder (GT_Size size)
 
 ~GT_AttributeBuilder ()
 
bool append (GT_BuilderStatus &status, const char *name, const GT_DataArrayHandle &h)
 
template<typename T_POD >
bool add (GT_BuilderStatus &status, const char *name, const T_POD *data, int tuple_size, GT_Type typeinfo=GT_TYPE_NONE)
 Add a named value to the attribute list. More...
 
bool addString (GT_BuilderStatus &status, const char *name, const char *const *data, int tuple_size)
 
GT_AttributeListHandle makeList ()
 Make an attribute list for the attributes defined by parsing. More...
 

Static Public Member Functions

static bool parse (GT_BuilderStatus &err, GT_AttributeBuilder &vertex, GT_AttributeBuilder &point, GT_AttributeBuilder &primitive, GT_AttributeBuilder &detail, const GT_VariadicAttributes &args)
 
static bool guessTypeInformation (GT_BuilderStatus &err, const char *token, UT_WorkBuffer &name, int &binding_class, GT_Storage &storage, GT_Type &type, GT_Size &tuple_size)
 

Detailed Description

Definition at line 29 of file GT_AttributeBuilder.h.

Member Enumeration Documentation

anonymous enum
Enumerator
GT_BINDING_VERTEX 
GT_BINDING_POINT 
GT_BINDING_PRIMITIVE 
GT_BINDING_DETAIL 

Definition at line 141 of file GT_AttributeBuilder.h.

Constructor & Destructor Documentation

GT_AttributeBuilder::GT_AttributeBuilder ( GT_Size  size)
GT_AttributeBuilder::~GT_AttributeBuilder ( )

Member Function Documentation

template<typename T_POD >
bool GT_AttributeBuilder::add ( GT_BuilderStatus status,
const char *  name,
const T_POD *  data,
int  tuple_size,
GT_Type  typeinfo = GT_TYPE_NONE 
)
inline

Add a named value to the attribute list.

Definition at line 112 of file GT_AttributeBuilder.h.

bool GT_AttributeBuilder::addString ( GT_BuilderStatus status,
const char *  name,
const char *const data,
int  tuple_size 
)
bool GT_AttributeBuilder::append ( GT_BuilderStatus status,
const char *  name,
const GT_DataArrayHandle h 
)
static bool GT_AttributeBuilder::guessTypeInformation ( GT_BuilderStatus err,
const char *  token,
UT_WorkBuffer name,
int binding_class,
GT_Storage storage,
GT_Type type,
GT_Size tuple_size 
)
static

Guess at the binding, storage and type information. The values passed in are not modified.

GT_AttributeListHandle GT_AttributeBuilder::makeList ( )

Make an attribute list for the attributes defined by parsing.

static bool GT_AttributeBuilder::parse ( GT_BuilderStatus err,
GT_AttributeBuilder vertex,
GT_AttributeBuilder point,
GT_AttributeBuilder primitive,
GT_AttributeBuilder detail,
const GT_VariadicAttributes args 
)
static

The parse method will take a NULL terminated argument list and parse attributes using a very simple heuristic. Attributes are specified by a name/value pair. The name includes binding class, storage and tuple size information (possibly type information). The value is an array which contains enough data to represent the data. A copy of the data is made.

The name consists of several parts: Binding Class The binding class is one of:

  • detail, constant
    a single value shared over all primitives
  • primitive, uniform
    a value for each primitive
  • point, varying
    a value for each shared point
  • vertex, facevarying
    a value for each vertex Storage Class
  • int32, int
    A 32 bit integer
  • int64, long
    A 64 bit integer
  • real16, fpreal16, float
    A 16 bit float
  • real32, fpreal32, float
    A 32 bit float
  • real64, fpreal64, double
    A 64 bit float
  • point16, point
    A 16 bit position value (3-tuple)
  • point32, point
    A 32 bit position value (3-tuple)
  • point64,
    A 64 bit position value (3-tuple)
  • vector16, vector
    A 16 bit direction vector value (3-tuple)
  • vector32, vector
    A 32 bit direction vector value (3-tuple)
  • vector64,
    A 64 bit direction vector value (3-tuple)
  • normal16/32/64, normal
    A 16/32/64 bit normal vector value (3-tuple)
  • color16/32/64, color
    A 16/32/64 bit color value (3-tuple)
  • matrix32
    A 32 bit transformation matrix (16-tuple)
  • matrix64, matrix
    A 64 bit transform matrix (16-tuple)
  • string
    An array of chars (i.e. const char *) Array Size Optionally, an array size can be specified by using [size] notation. Please note that a "point32[3]" would require 9 fpreal32 values per array entry.

For example:

parse(vertex, point, primitive, detail,
"varying point P", P,
"varying normal N", N,
"vertex float uv[2]", uv,
"uniform color Cd", Cd,
"constant matrix xform", xform);

It is possible to pass in the same GT_AttributeBuilder for different binding classes. For example, for a GT_PrimSphere, you might have something like:

parse(detail, detail, detail, detail, ...);

which will build all attributes in the same builder (detail) If a variable is specified multiple times, the value will be used for multi-segment motion blur. At the current time, all variables which have multiple segments should have the same number of segments specified. It is not necessary to specify segments for all variables, only ones which change over time. For example

parse(vertex, point, primitive, detail,
"vertex point P", P0, // P at time 0
"vertex point P", P1, // P at time 1
"vertex normal N", N0, // N at time 0
"vertex normal N", N1, // N at time 1
"vertex float uv[2]", uv,
"constant matrix xform", xform);

The documentation for this class was generated from the following file: