6#ifndef MATERIALX_TYPEDESC_H
7#define MATERIALX_TYPEDESC_H
14MATERIALX_NAMESPACE_BEGIN
16using ChannelMap = std::unordered_map<char, int>;
57 static const TypeDesc* registerType(
const string& name,
unsigned char basetype,
unsigned char semantic = SEMANTIC_NONE,
58 size_t size = 1,
bool editable =
true,
const ChannelMap& channelMapping = ChannelMap());
61 bool operator==(
const TypeDesc& rhs)
const;
64 bool operator!=(
const TypeDesc& rhs)
const;
68 static const TypeDesc* get(
const string& name);
71 const string&
getName()
const {
return _name; }
78 int getChannelIndex(
char channel)
const;
104 bool isFloat2()
const {
return _size == 2 && (_semantic == SEMANTIC_COLOR || _semantic == SEMANTIC_VECTOR); }
107 bool isFloat3()
const {
return _size == 3 && (_semantic == SEMANTIC_COLOR || _semantic == SEMANTIC_VECTOR); }
110 bool isFloat4()
const {
return _size == 4 && (_semantic == SEMANTIC_COLOR || _semantic == SEMANTIC_VECTOR); }
113 bool isClosure()
const {
return (_semantic == SEMANTIC_CLOSURE || _semantic == SEMANTIC_SHADER || _semantic == SEMANTIC_MATERIAL); }
116 TypeDesc(
const string& name,
unsigned char basetype,
unsigned char semantic,
size_t size,
117 bool editable,
const ChannelMap& channelMapping);
120 const unsigned char _basetype;
121 const unsigned char _semantic;
123 const bool _editable;
124 const ChannelMap _channelMapping;
135extern MX_GENSHADER_API
const TypeDesc* NONE;
136extern MX_GENSHADER_API
const TypeDesc* BOOLEAN;
137extern MX_GENSHADER_API
const TypeDesc* INTEGER;
138extern MX_GENSHADER_API
const TypeDesc* INTEGERARRAY;
139extern MX_GENSHADER_API
const TypeDesc* FLOAT;
140extern MX_GENSHADER_API
const TypeDesc* FLOATARRAY;
141extern MX_GENSHADER_API
const TypeDesc* VECTOR2;
142extern MX_GENSHADER_API
const TypeDesc* VECTOR3;
143extern MX_GENSHADER_API
const TypeDesc* VECTOR4;
144extern MX_GENSHADER_API
const TypeDesc* COLOR3;
145extern MX_GENSHADER_API
const TypeDesc* COLOR4;
146extern MX_GENSHADER_API
const TypeDesc* MATRIX33;
147extern MX_GENSHADER_API
const TypeDesc* MATRIX44;
148extern MX_GENSHADER_API
const TypeDesc* STRING;
149extern MX_GENSHADER_API
const TypeDesc* FILENAME;
150extern MX_GENSHADER_API
const TypeDesc* BSDF;
151extern MX_GENSHADER_API
const TypeDesc* EDF;
152extern MX_GENSHADER_API
const TypeDesc* VDF;
153extern MX_GENSHADER_API
const TypeDesc* SURFACESHADER;
154extern MX_GENSHADER_API
const TypeDesc* VOLUMESHADER;
155extern MX_GENSHADER_API
const TypeDesc* DISPLACEMENTSHADER;
156extern MX_GENSHADER_API
const TypeDesc* LIGHTSHADER;
157extern MX_GENSHADER_API
const TypeDesc* MATERIAL;
161MATERIALX_NAMESPACE_END
Macros for declaring imported and exported symbols.
A type descriptor for MaterialX data types.
Definition: TypeDesc.h:28
bool isEditable() const
Returns true if the type is editable by users.
Definition: TypeDesc.h:92
const string & getName() const
Return the name of the type.
Definition: TypeDesc.h:71
bool isClosure() const
Return true if the type represents a closure.
Definition: TypeDesc.h:113
bool isScalar() const
Return true if the type is a scalar type.
Definition: TypeDesc.h:95
size_t getSize() const
Return the number of elements the type is composed of.
Definition: TypeDesc.h:87
bool isFloat3() const
Return true if the type is an aggregate of 3 floats.
Definition: TypeDesc.h:107
unsigned char getSemantic() const
Return the semantic for the type.
Definition: TypeDesc.h:81
bool isAggregate() const
Return true if the type is an aggregate type.
Definition: TypeDesc.h:98
bool isFloat2() const
Return true if the type is an aggregate of 2 floats.
Definition: TypeDesc.h:104
bool isArray() const
Return true if the type is an array type.
Definition: TypeDesc.h:101
bool isFloat4() const
Return true if the type is an aggregate of 4 floats.
Definition: TypeDesc.h:110
unsigned char getBaseType() const
Return the basetype for the type.
Definition: TypeDesc.h:74