MaterialX 1.38.10
Loading...
Searching...
No Matches
TypeDesc Class Reference

A type descriptor for MaterialX data types. More...

#include <TypeDesc.h>

Public Types

enum  BaseType {
  BASETYPE_NONE , BASETYPE_BOOLEAN , BASETYPE_INTEGER , BASETYPE_FLOAT ,
  BASETYPE_STRING , BASETYPE_STRUCT , BASETYPE_LAST
}
 
enum  Semantic {
  SEMANTIC_NONE , SEMANTIC_COLOR , SEMANTIC_VECTOR , SEMANTIC_MATRIX ,
  SEMANTIC_FILENAME , SEMANTIC_CLOSURE , SEMANTIC_SHADER , SEMANTIC_MATERIAL ,
  SEMANTIC_ENUM , SEMANTIC_LAST
}
 

Public Member Functions

bool operator== (const TypeDesc &rhs) const
 Equality operator overload.
 
bool operator!= (const TypeDesc &rhs) const
 Inequality operator overload.
 
const string & getName () const
 Return the name of the type.
 
unsigned char getBaseType () const
 Return the basetype for the type.
 
int getChannelIndex (char channel) const
 Returns the channel index for the supplied channel name. More...
 
unsigned char getSemantic () const
 Return the semantic for the type.
 
size_t getSize () const
 Return the number of elements the type is composed of. More...
 
bool isEditable () const
 Returns true if the type is editable by users. More...
 
bool isScalar () const
 Return true if the type is a scalar type.
 
bool isAggregate () const
 Return true if the type is an aggregate type.
 
bool isArray () const
 Return true if the type is an array type.
 
bool isFloat2 () const
 Return true if the type is an aggregate of 2 floats.
 
bool isFloat3 () const
 Return true if the type is an aggregate of 3 floats.
 
bool isFloat4 () const
 Return true if the type is an aggregate of 4 floats.
 
bool isClosure () const
 Return true if the type represents a closure.
 

Static Public Member Functions

static const TypeDescregisterType (const string &name, unsigned char basetype, unsigned char semantic=SEMANTIC_NONE, size_t size=1, bool editable=true, const ChannelMap &channelMapping=ChannelMap())
 Register a type descriptor for a MaterialX data type. More...
 
static const TypeDescget (const string &name)
 Get a type descriptor for given name. More...
 

Detailed Description

A type descriptor for MaterialX data types.

All types need to have a type descriptor registered in order for shader generators to know about the type. A unique type descriptor pointer is the identifier used for types, and can be used for type comparisons as well as getting more information about the type. All standard library data types are registered by default and their type descriptors can be accessed from the Type namespace, e.g. MaterialX::Type::FLOAT. If custom types are used they must be registered by calling TypeDesc::registerType(). Descriptors for registered types can be retreived using TypeDesc::get(), see below.

Member Function Documentation

◆ get()

const TypeDesc * get ( const string &  name)
static

Get a type descriptor for given name.

Returns an empty shared pointer if no type with the given name is found.

◆ getChannelIndex()

int getChannelIndex ( char  channel) const

Returns the channel index for the supplied channel name.

Will return -1 on failure to find a matching index.

◆ getSize()

size_t getSize ( ) const
inline

Return the number of elements the type is composed of.

Will return 1 for scalar types and a size greater than 1 for aggregate type. For array types 0 is returned since the number of elements is undefined until an array is instantiated.

◆ isEditable()

bool isEditable ( ) const
inline

Returns true if the type is editable by users.

Editable types are allowed to be published as shader uniforms and hence must be presentable in a user interface.

◆ registerType()

const TypeDesc * registerType ( const string &  name,
unsigned char  basetype,
unsigned char  semantic = SEMANTIC_NONE,
size_t  size = 1,
bool  editable = true,
const ChannelMap &  channelMapping = ChannelMap() 
)
static

Register a type descriptor for a MaterialX data type.

Throws an exception if a type with the same name is already registered.


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