HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Types.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_TYPES_H
7 #define MATERIALX_TYPES_H
8 
9 /// @file
10 /// Data type classes
11 
12 #include <MaterialXCore/Export.h>
13 
14 #include <MaterialXCore/Util.h>
15 
16 #include <array>
17 #include <cmath>
18 
20 
21 extern MX_CORE_API const string DEFAULT_TYPE_STRING;
22 extern MX_CORE_API const string FILENAME_TYPE_STRING;
23 extern MX_CORE_API const string GEOMNAME_TYPE_STRING;
24 extern MX_CORE_API const string STRING_TYPE_STRING;
25 extern MX_CORE_API const string BSDF_TYPE_STRING;
26 extern MX_CORE_API const string EDF_TYPE_STRING;
27 extern MX_CORE_API const string VDF_TYPE_STRING;
28 extern MX_CORE_API const string SURFACE_SHADER_TYPE_STRING;
30 extern MX_CORE_API const string VOLUME_SHADER_TYPE_STRING;
31 extern MX_CORE_API const string LIGHT_SHADER_TYPE_STRING;
32 extern MX_CORE_API const string MATERIAL_TYPE_STRING;
33 extern MX_CORE_API const string SURFACE_MATERIAL_NODE_STRING;
34 extern MX_CORE_API const string VOLUME_MATERIAL_NODE_STRING;
35 extern MX_CORE_API const string MULTI_OUTPUT_TYPE_STRING;
36 extern MX_CORE_API const string NONE_TYPE_STRING;
37 extern MX_CORE_API const string VALUE_STRING_TRUE;
38 extern MX_CORE_API const string VALUE_STRING_FALSE;
39 extern MX_CORE_API const string NAME_PREFIX_SEPARATOR;
40 extern MX_CORE_API const string NAME_PATH_SEPARATOR;
41 extern MX_CORE_API const string ARRAY_VALID_SEPARATORS;
42 extern MX_CORE_API const string ARRAY_PREFERRED_SEPARATOR;
43 
44 /// The base class for vectors of scalar values
45 class VectorBase { };
46 
47 /// A tag class for constructing vectors and matrices without initialization
48 class Uninit { };
49 
50 /// The class template for vectors of scalar values. Inherited by Vector2,
51 /// Vector3, Vector4, Color3, and Color4.
52 ///
53 /// Template parameter V is the vector subclass, S is the scalar element type,
54 /// and N is the number of scalar elements in the vector.
55 template <class V, class S, size_t N> class VectorN : public VectorBase
56 {
57  public:
58  using Iterator = typename std::array<S, N>::iterator;
59  using ConstIterator = typename std::array<S, N>::const_iterator;
60 
61  public:
62  VectorN() : _arr{} { }
63  explicit VectorN(Uninit) { }
64  explicit VectorN(S s) { _arr.fill(s); }
65  explicit VectorN(const std::array<S, N>& arr) : _arr(arr) { }
66  explicit VectorN(const vector<S>& vec) { std::copy(vec.begin(), vec.end(), _arr.begin()); }
67  explicit VectorN(const S* begin, const S* end) { std::copy(begin, end, _arr.begin()); }
68 
69  /// @name Comparison Operators
70  /// @{
71 
72  /// Return true if the given vector is identical to this one.
73  bool operator==(const V& rhs) const { return _arr == rhs._arr; }
74 
75  /// Return true if the given vector differs from this one.
76  bool operator!=(const V& rhs) const { return _arr != rhs._arr; }
77 
78  /// Compare two vectors lexicographically.
79  bool operator<(const V& rhs) const
80  {
81  return _arr < rhs._arr;
82  }
83 
84  /// @}
85  /// @name Indexing Operators
86  /// @{
87 
88  /// Return the scalar value at the given index.
89  S& operator[](size_t i) { return _arr.at(i); }
90 
91  /// Return the const scalar value at the given index.
92  const S& operator[](size_t i) const { return _arr.at(i); }
93 
94  /// @}
95  /// @name Component-wise Operators
96  /// @{
97 
98  /// Component-wise addition of two vectors.
99  V operator+(const V& rhs) const
100  {
101  V res(Uninit{});
102  for (size_t i = 0; i < N; i++)
103  res[i] = _arr[i] + rhs[i];
104  return res;
105  }
106 
107  /// Component-wise addition of two vectors.
108  V& operator+=(const V& rhs)
109  {
110  for (size_t i = 0; i < N; i++)
111  _arr[i] += rhs[i];
112  return *static_cast<V*>(this);
113  }
114 
115  /// Component-wise subtraction of two vectors.
116  V operator-(const V& rhs) const
117  {
118  V res(Uninit{});
119  for (size_t i = 0; i < N; i++)
120  res[i] = _arr[i] - rhs[i];
121  return res;
122  }
123 
124  /// Component-wise subtraction of two vectors.
125  V& operator-=(const V& rhs)
126  {
127  for (size_t i = 0; i < N; i++)
128  _arr[i] -= rhs[i];
129  return *static_cast<V*>(this);
130  }
131 
132  /// Component-wise multiplication of two vectors.
133  V operator*(const V& rhs) const
134  {
135  V res(Uninit{});
136  for (size_t i = 0; i < N; i++)
137  res[i] = _arr[i] * rhs[i];
138  return res;
139  }
140 
141  /// Component-wise multiplication of two vectors.
142  V& operator*=(const V& rhs)
143  {
144  for (size_t i = 0; i < N; i++)
145  _arr[i] *= rhs[i];
146  return *static_cast<V*>(this);
147  }
148 
149  /// Component-wise division of two vectors.
150  V operator/(const V& rhs) const
151  {
152  V res(Uninit{});
153  for (size_t i = 0; i < N; i++)
154  res[i] = _arr[i] / rhs[i];
155  return res;
156  }
157 
158  /// Component-wise division of two vectors.
159  V& operator/=(const V& rhs)
160  {
161  for (size_t i = 0; i < N; i++)
162  _arr[i] /= rhs[i];
163  return *static_cast<V*>(this);
164  }
165 
166  /// Component-wise multiplication of a vector by a scalar.
167  V operator*(S s) const
168  {
169  V res(Uninit{});
170  for (size_t i = 0; i < N; i++)
171  res[i] = _arr[i] * s;
172  return res;
173  }
174 
175  /// Component-wise multiplication of a vector by a scalar.
177  {
178  for (size_t i = 0; i < N; i++)
179  _arr[i] *= s;
180  return *static_cast<V*>(this);
181  }
182 
183  /// Component-wise division of a vector by a scalar.
184  V operator/(S s) const
185  {
186  V res(Uninit{});
187  for (size_t i = 0; i < N; i++)
188  res[i] = _arr[i] / s;
189  return res;
190  }
191 
192  /// Component-wise division of a vector by a scalar.
194  {
195  for (size_t i = 0; i < N; i++)
196  _arr[i] /= s;
197  return *static_cast<V*>(this);
198  }
199 
200  /// Unary negation of a vector.
201  V operator-() const
202  {
203  V res(Uninit{});
204  for (size_t i = 0; i < N; i++)
205  res[i] = -_arr[i];
206  return res;
207  }
208 
209  /// Unary plus of a vector. Returns the unaltered vector
210  V operator+() const
211  {
212  V res(Uninit{});
213  for (size_t i = 0; i < N; i++)
214  res[i] = _arr[i];
215  return res;
216  }
217 
218  /// @}
219  /// @name Geometric Methods
220  /// @{
221 
222  /// Return the magnitude of the vector.
223  S getMagnitude() const
224  {
225  S res{};
226  for (size_t i = 0; i < N; i++)
227  res += _arr[i] * _arr[i];
228  return std::sqrt(res);
229  }
230 
231  /// Return a normalized vector.
232  V getNormalized() const
233  {
234  return *this / getMagnitude();
235  }
236 
237  /// Return the dot product of two vectors.
238  S dot(const V& rhs) const
239  {
240  S res{};
241  for (size_t i = 0; i < N; i++)
242  res += _arr[i] * rhs[i];
243  return res;
244  }
245 
246  /// @}
247  /// @name Iterators
248  /// @{
249 
250  Iterator begin() { return _arr.begin(); }
251  ConstIterator begin() const { return _arr.begin(); }
252 
253  Iterator end() { return _arr.end(); }
254  ConstIterator end() const { return _arr.end(); }
255 
256  /// @}
257  /// @name Utility
258  /// @{
259 
260  /// Return a pointer to the underlying data array.
261  S* data() { return _arr.data(); }
262 
263  /// Return a const pointer to the underlying data array.
264  const S* data() const { return _arr.data(); }
265 
266  /// Function object for hashing vectors.
267  class Hash
268  {
269  public:
270  size_t operator()(const V& v) const noexcept
271  {
272  size_t h = 0;
273  for (size_t i = 0; i < N; i++)
274  hashCombine(h, v[i]);
275  return h;
276  }
277  };
278 
279  /// @}
280  /// @name Static Methods
281  /// @{
282 
283  /// Return the number of scalar elements for the vector.
284  static constexpr size_t numElements() { return N; }
285 
286  /// @}
287 
288  protected:
289  std::array<S, N> _arr;
290 };
291 
292 /// @class Vector2
293 /// A vector of two floating-point values
294 class MX_CORE_API Vector2 : public VectorN<Vector2, float, 2>
295 {
296  public:
298  Vector2() = default;
299  Vector2(float x, float y) :
300  VectorN(Uninit{})
301  {
302  _arr = { x, y };
303  }
304 
305  /// Return the cross product of two vectors.
306  float cross(const Vector2& rhs) const
307  {
308  return _arr[0] * rhs[1] - _arr[1] * rhs[0];
309  }
310 };
311 
312 /// @class Vector3
313 /// A vector of three floating-point values
314 class MX_CORE_API Vector3 : public VectorN<Vector3, float, 3>
315 {
316  public:
318  Vector3() = default;
319  Vector3(float x, float y, float z) :
320  VectorN(Uninit{})
321  {
322  _arr = { x, y, z };
323  }
324 
325  /// Return the cross product of two vectors.
326  Vector3 cross(const Vector3& rhs) const
327  {
328  return Vector3(_arr[1] * rhs[2] - _arr[2] * rhs[1],
329  _arr[2] * rhs[0] - _arr[0] * rhs[2],
330  _arr[0] * rhs[1] - _arr[1] * rhs[0]);
331  }
332 };
333 
334 /// @class Vector4
335 /// A vector of four floating-point values
336 class MX_CORE_API Vector4 : public VectorN<Vector4, float, 4>
337 {
338  public:
340  Vector4() = default;
341  Vector4(float x, float y, float z, float w) :
342  VectorN(Uninit{})
343  {
344  _arr = { x, y, z, w };
345  }
346 };
347 
348 /// @class Color3
349 /// A three-component color value
350 class MX_CORE_API Color3 : public VectorN<Color3, float, 3>
351 {
352  public:
354  Color3() = default;
355  Color3(float r, float g, float b) :
356  VectorN(Uninit{})
357  {
358  _arr = { r, g, b };
359  }
360 
361  /// Transform the given color from linear RGB to the sRGB encoding,
362  /// returning the result as a new value.
363  Color3 linearToSrgb() const;
364 
365  /// Transform the given color from the sRGB encoding to linear RGB,
366  /// returning the result as a new value.
367  Color3 srgbToLinear() const;
368 };
369 
370 /// @class Color4
371 /// A four-component color value
372 class MX_CORE_API Color4 : public VectorN<Color4, float, 4>
373 {
374  public:
376  Color4() = default;
377  Color4(float r, float g, float b, float a) :
378  VectorN(Uninit{})
379  {
380  _arr = { r, g, b, a };
381  }
382 };
383 
384 /// The base class for square matrices of scalar values
385 class MatrixBase { };
386 
387 /// The class template for square matrices of scalar values. Inherited by
388 /// Matrix33 and Matrix44.
389 ///
390 /// The elements of a MatrixN are stored in row-major order, and may be
391 /// accessed using the syntax <c>matrix[row][column]</c>.
392 ///
393 /// Template parameter M is the matrix subclass, S is the scalar element type,
394 /// and N is the number of rows and columns in the matrix.
395 template <class M, class S, size_t N> class MatrixN : public MatrixBase
396 {
397  public:
398  using RowArray = typename std::array<S, N>;
399  using Iterator = typename std::array<RowArray, N>::iterator;
400  using ConstIterator = typename std::array<RowArray, N>::const_iterator;
401 
402  public:
403  MatrixN() : _arr{} { }
404  explicit MatrixN(Uninit) { }
405  explicit MatrixN(S s) { std::fill_n(&_arr[0][0], N * N, s); }
406  explicit MatrixN(const S* begin, const S* end) { std::copy(begin, end, &_arr[0][0]); }
407 
408  /// @name Comparison Operators
409  /// @{
410 
411  /// Return true if the given matrix is identical to this one.
412  bool operator==(const M& rhs) const { return _arr == rhs._arr; }
413 
414  /// Return true if the given matrix differs from this one.
415  bool operator!=(const M& rhs) const { return _arr != rhs._arr; }
416 
417  /// Return true if the given matrix is equivalent to this one
418  /// within a given floating-point tolerance.
419  bool isEquivalent(const M& rhs, S tolerance) const
420  {
421  for (size_t i = 0; i < N; i++)
422  {
423  for (size_t j = 0; j < N; j++)
424  {
425  if (std::abs(_arr[i][j] - rhs[i][j]) > tolerance)
426  {
427  return false;
428  }
429  }
430  }
431  return true;
432  }
433 
434  /// @}
435  /// @name Indexing Operators
436  /// @{
437 
438  /// Return the row array at the given index.
439  RowArray& operator[](size_t i) { return _arr.at(i); }
440 
441  /// Return the const row array at the given index.
442  const RowArray& operator[](size_t i) const { return _arr.at(i); }
443 
444  /// @}
445  /// @name Component-wise Operators
446  /// @{
447 
448  /// Component-wise addition of two matrices.
449  M operator+(const M& rhs) const
450  {
451  M res(Uninit{});
452  for (size_t i = 0; i < N; i++)
453  for (size_t j = 0; j < N; j++)
454  res[i][j] = _arr[i][j] + rhs[i][j];
455  return res;
456  }
457 
458  /// Component-wise addition of two matrices.
459  M& operator+=(const M& rhs)
460  {
461  *this = *this + rhs;
462  return *static_cast<M*>(this);
463  }
464 
465  /// Component-wise subtraction of two matrices.
466  M operator-(const M& rhs) const
467  {
468  M res(Uninit{});
469  for (size_t i = 0; i < N; i++)
470  for (size_t j = 0; j < N; j++)
471  res[i][j] = _arr[i][j] - rhs[i][j];
472  return res;
473  }
474 
475  /// Component-wise subtraction of two matrices.
476  M& operator-=(const M& rhs)
477  {
478  *this = *this - rhs;
479  return *static_cast<M*>(this);
480  }
481 
482  /// Component-wise multiplication of a matrix and a scalar.
483  M operator*(S s) const
484  {
485  M res(Uninit{});
486  for (size_t i = 0; i < N; i++)
487  for (size_t j = 0; j < N; j++)
488  res[i][j] = _arr[i][j] * s;
489  return res;
490  }
491 
492  /// Component-wise multiplication of a matrix and a scalar.
494  {
495  *this = *this * s;
496  return *static_cast<M*>(this);
497  }
498 
499  /// Component-wise division of a matrix by a scalar.
500  M operator/(S s) const
501  {
502  M res(Uninit{});
503  for (size_t i = 0; i < N; i++)
504  for (size_t j = 0; j < N; j++)
505  res[i][j] = _arr[i][j] / s;
506  return res;
507  }
508 
509  /// Component-wise division of a matrix by a scalar.
511  {
512  *this = *this / s;
513  return *static_cast<M*>(this);
514  }
515 
516  /// @}
517  /// @name Matrix Algebra
518  /// @{
519 
520  /// Compute the matrix product.
521  M operator*(const M& rhs) const
522  {
523  M res;
524  for (size_t i = 0; i < N; i++)
525  for (size_t j = 0; j < N; j++)
526  for (size_t k = 0; k < N; k++)
527  res[i][j] += _arr[i][k] * rhs[k][j];
528  return res;
529  }
530 
531  /// Compute the matrix product.
532  M& operator*=(const M& rhs)
533  {
534  *this = *this * rhs;
535  return *static_cast<M*>(this);
536  }
537 
538  /// Divide the first matrix by the second (computed as the product of the
539  /// first matrix and the inverse of the second).
540  M operator/(const M& rhs) const
541  {
542  return *this * rhs.getInverse();
543  }
544 
545  /// Divide the first matrix by the second (computed as the product of the
546  /// first matrix and the inverse of the second).
547  M& operator/=(const M& rhs)
548  {
549  *this *= rhs.getInverse();
550  return *static_cast<M*>(this);
551  }
552 
553  /// Unary negation of a matrix.
554  M operator-() const
555  {
556  M res(Uninit{});
557  for (size_t i = 0; i < N; i++)
558  for (size_t j = 0; j < N; j++)
559  res[i][j] = -_arr[i][j];
560  return res;
561  }
562 
563  /// Unary plus of a matrix.
564  M operator+() const
565  {
566  M res(Uninit{});
567  for (size_t i = 0; i < N; i++)
568  for (size_t j = 0; j < N; j++)
569  res[i][j] = _arr[i][j];
570  return res;
571  }
572 
573  /// @}
574  /// @name Iterators
575  /// @{
576 
577  Iterator begin() { return _arr.begin(); }
578  ConstIterator begin() const { return _arr.begin(); }
579 
580  Iterator end() { return _arr.end(); }
581  ConstIterator end() const { return _arr.end(); }
582 
583  /// @}
584  /// @name Utility
585  /// @{
586 
587  /// Return a pointer to the underlying data array.
588  S* data() { return _arr.front().data(); }
589 
590  /// Return a const pointer to the underlying data array.
591  const S* data() const { return _arr.front().data(); }
592 
593  /// @}
594  /// @name Static Methods
595  /// @{
596 
597  /// Return the number of rows in this matrix.
598  static constexpr size_t numRows() { return N; }
599 
600  /// Return the number of columns in this matrix.
601  static constexpr size_t numColumns() { return N; }
602 
603  /// @}
604 
605  protected:
606  std::array<RowArray, N> _arr;
607 };
608 
609 /// @class Matrix33
610 /// A 3x3 matrix of floating-point values.
611 ///
612 /// Vector transformation methods follow the row-vector convention,
613 /// with matrix-vector multiplication computed as v' = vM.
614 class MX_CORE_API Matrix33 : public MatrixN<Matrix33, float, 3>
615 {
616  public:
618  Matrix33() = default;
619  Matrix33(float m00, float m01, float m02,
620  float m10, float m11, float m12,
621  float m20, float m21, float m22) :
622  MatrixN(Uninit{})
623  {
624  _arr = { RowArray{ m00, m01, m02 },
625  RowArray{ m10, m11, m12 },
626  RowArray{ m20, m21, m22 } };
627  }
628 
629  /// @name Matrix Operations
630  /// @{
631 
632  /// Return the transpose of the matrix.
633  Matrix33 getTranspose() const;
634 
635  /// Return the determinant of the matrix.
636  float getDeterminant() const;
637 
638  /// Return the adjugate of the matrix.
639  Matrix33 getAdjugate() const;
640 
641  /// Return the inverse of the matrix.
643  {
644  return getAdjugate() / getDeterminant();
645  }
646 
647  /// @}
648  /// @name Vector Transformations
649  /// @{
650 
651  /// Return the product of this matrix and a 3D vector.
652  Vector3 multiply(const Vector3& v) const;
653 
654  /// Transform the given 2D point.
655  Vector2 transformPoint(const Vector2& v) const;
656 
657  /// Transform the given 2D direction vector.
658  Vector2 transformVector(const Vector2& v) const;
659 
660  /// Transform the given 3D normal vector.
661  Vector3 transformNormal(const Vector3& v) const;
662 
663  /// Create a translation matrix.
664  static Matrix33 createTranslation(const Vector2& v);
665 
666  /// Create a scale matrix.
667  static Matrix33 createScale(const Vector2& v);
668 
669  /// Create a rotation matrix.
670  /// @param angle Angle in radians
671  static Matrix33 createRotation(float angle);
672 
673  /// @}
674 
675  public:
676  static const Matrix33 IDENTITY;
677 };
678 
679 /// @class Matrix44
680 /// A 4x4 matrix of floating-point values.
681 ///
682 /// Vector transformation methods follow the row-vector convention,
683 /// with matrix-vector multiplication computed as v' = vM.
684 class MX_CORE_API Matrix44 : public MatrixN<Matrix44, float, 4>
685 {
686  public:
688  Matrix44() = default;
689  Matrix44(float m00, float m01, float m02, float m03,
690  float m10, float m11, float m12, float m13,
691  float m20, float m21, float m22, float m23,
692  float m30, float m31, float m32, float m33) :
693  MatrixN(Uninit{})
694  {
695  _arr = { RowArray{ m00, m01, m02, m03 },
696  RowArray{ m10, m11, m12, m13 },
697  RowArray{ m20, m21, m22, m23 },
698  RowArray{ m30, m31, m32, m33 } };
699  }
700 
701  /// @name Matrix Operations
702  /// @{
703 
704  /// Return the transpose of the matrix.
705  Matrix44 getTranspose() const;
706 
707  /// Return the determinant of the matrix.
708  float getDeterminant() const;
709 
710  /// Return the adjugate of the matrix.
711  Matrix44 getAdjugate() const;
712 
713  /// Return the inverse of the matrix.
715  {
716  return getAdjugate() / getDeterminant();
717  }
718 
719  /// @}
720  /// @name Vector Transformations
721  /// @{
722 
723  /// Return the product of this matrix and a 4D vector.
724  Vector4 multiply(const Vector4& v) const;
725 
726  /// Transform the given 3D point.
727  Vector3 transformPoint(const Vector3& v) const;
728 
729  /// Transform the given 3D direction vector.
730  Vector3 transformVector(const Vector3& v) const;
731 
732  /// Transform the given 3D normal vector.
733  Vector3 transformNormal(const Vector3& v) const;
734 
735  /// Create a translation matrix.
736  static Matrix44 createTranslation(const Vector3& v);
737 
738  /// Create a scale matrix.
739  static Matrix44 createScale(const Vector3& v);
740 
741  /// Create a rotation matrix about the X-axis.
742  /// @param angle Angle in radians
743  static Matrix44 createRotationX(float angle);
744 
745  /// Create a rotation matrix about the Y-axis.
746  /// @param angle Angle in radians
747  static Matrix44 createRotationY(float angle);
748 
749  /// Create a rotation matrix about the Z-axis.
750  /// @param angle Angle in radians
751  static Matrix44 createRotationZ(float angle);
752 
753  /// @}
754 
755  public:
756  static const Matrix44 IDENTITY;
757 };
758 
760 
761 #endif
V operator+() const
Unary plus of a vector. Returns the unaltered vector.
Definition: Types.h:210
MX_CORE_API const string ARRAY_PREFERRED_SEPARATOR
V & operator*=(S s)
Component-wise multiplication of a vector by a scalar.
Definition: Types.h:176
M operator+() const
Unary plus of a matrix.
Definition: Types.h:564
V operator+(const V &rhs) const
Component-wise addition of two vectors.
Definition: Types.h:99
MX_CORE_API const string VALUE_STRING_TRUE
M & operator+=(const M &rhs)
Component-wise addition of two matrices.
Definition: Types.h:459
S getMagnitude() const
Return the magnitude of the vector.
Definition: Types.h:223
M operator+(const M &rhs) const
Component-wise addition of two matrices.
Definition: Types.h:449
MX_CORE_API const string NONE_TYPE_STRING
bool isEquivalent(const M &rhs, S tolerance) const
Definition: Types.h:419
UT_Vector4T< Float > Vector4
Definition: APEX_Include.h:66
MatrixN(const S *begin, const S *end)
Definition: Types.h:406
M operator/(S s) const
Component-wise division of a matrix by a scalar.
Definition: Types.h:500
V & operator/=(S s)
Component-wise division of a vector by a scalar.
Definition: Types.h:193
M operator*(S s) const
Component-wise multiplication of a matrix and a scalar.
Definition: Types.h:483
std::array< S, N > _arr
Definition: Types.h:289
V getNormalized() const
Return a normalized vector.
Definition: Types.h:232
SIM_API const UT_StringHolder angle
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
MX_CORE_API const string VDF_TYPE_STRING
const GLdouble * v
Definition: glcorearb.h:837
MX_CORE_API const string LIGHT_SHADER_TYPE_STRING
typename std::array< float, N >::const_iterator ConstIterator
Definition: Types.h:59
MX_CORE_API const string FILENAME_TYPE_STRING
M operator-(const M &rhs) const
Component-wise subtraction of two matrices.
Definition: Types.h:466
vfloat4 sqrt(const vfloat4 &a)
Definition: simd.h:7694
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
GLboolean GLboolean g
Definition: glcorearb.h:1222
Iterator begin()
Definition: Types.h:577
Iterator end()
Definition: Types.h:580
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
GLdouble s
Definition: glad.h:3009
MX_CORE_API const string VOLUME_SHADER_TYPE_STRING
GLint y
Definition: glcorearb.h:103
const S * data() const
Return a const pointer to the underlying data array.
Definition: Types.h:264
Color4(float r, float g, float b, float a)
Definition: Types.h:377
VectorN()
Definition: Types.h:62
ConstIterator end() const
Definition: Types.h:581
FMT_CONSTEXPR auto fill_n(OutputIt out, Size count, const T &value) -> OutputIt
Definition: format.h:629
#define MX_CORE_API
Definition: Export.h:18
bool operator==(const M &rhs) const
Return true if the given matrix is identical to this one.
Definition: Types.h:412
VectorN(const vector< S > &vec)
Definition: Types.h:66
Definition: Types.h:395
The base class for square matrices of scalar values.
Definition: Types.h:385
MX_CORE_API const string EDF_TYPE_STRING
const S & operator[](size_t i) const
Return the const scalar value at the given index.
Definition: Types.h:92
bool operator!=(const V &rhs) const
Return true if the given vector differs from this one.
Definition: Types.h:76
V operator*(S s) const
Component-wise multiplication of a vector by a scalar.
Definition: Types.h:167
FMT_CONSTEXPR uint64_t multiply(uint64_t lhs, uint64_t rhs)
Definition: format.h:1718
static constexpr size_t numRows()
Return the number of rows in this matrix.
Definition: Types.h:598
bool operator<(const V &rhs) const
Compare two vectors lexicographically.
Definition: Types.h:79
A tag class for constructing vectors and matrices without initialization.
Definition: Types.h:48
MX_CORE_API const string VOLUME_MATERIAL_NODE_STRING
VectorN(const S *begin, const S *end)
Definition: Types.h:67
typename std::array< float, N >::iterator Iterator
Definition: Types.h:58
V operator-(const V &rhs) const
Component-wise subtraction of two vectors.
Definition: Types.h:116
ConstIterator begin() const
Definition: Types.h:578
Iterator end()
Definition: Types.h:253
static constexpr size_t numElements()
Return the number of scalar elements for the vector.
Definition: Types.h:284
V & operator+=(const V &rhs)
Component-wise addition of two vectors.
Definition: Types.h:108
The base class for vectors of scalar values.
Definition: Types.h:45
MX_CORE_API const string GEOMNAME_TYPE_STRING
Matrix44 getInverse() const
Return the inverse of the matrix.
Definition: Types.h:714
GLuint GLuint end
Definition: glcorearb.h:475
MatrixN()
Definition: Types.h:403
bool operator!=(const M &rhs) const
Return true if the given matrix differs from this one.
Definition: Types.h:415
MX_CORE_API const string MULTI_OUTPUT_TYPE_STRING
Definition: Types.h:336
M & operator/=(const M &rhs)
Definition: Types.h:547
Vector3 cross(const Vector3 &rhs) const
Return the cross product of two vectors.
Definition: Types.h:326
void hashCombine(size_t &seed, const T &value)
Combine the hash of a value with an existing seed.
Definition: Util.h:58
Definition: Types.h:294
MX_CORE_API const string NAME_PREFIX_SEPARATOR
S * data()
Return a pointer to the underlying data array.
Definition: Types.h:588
std::array< RowArray, N > _arr
Definition: Types.h:606
Matrix44(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
Definition: Types.h:689
Vector3(float x, float y, float z)
Definition: Types.h:319
Definition: Types.h:55
M & operator*=(S s)
Component-wise multiplication of a matrix and a scalar.
Definition: Types.h:493
ConstIterator begin() const
Definition: Types.h:251
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLint GLenum GLint x
Definition: glcorearb.h:409
V operator/(S s) const
Component-wise division of a vector by a scalar.
Definition: Types.h:184
bool operator==(const V &rhs) const
Return true if the given vector is identical to this one.
Definition: Types.h:73
float cross(const Vector2 &rhs) const
Return the cross product of two vectors.
Definition: Types.h:306
static constexpr size_t numColumns()
Return the number of columns in this matrix.
Definition: Types.h:601
typename std::array< RowArray, N >::iterator Iterator
Definition: Types.h:399
MX_CORE_API const string MATERIAL_TYPE_STRING
MX_CORE_API const string BSDF_TYPE_STRING
VectorN(const std::array< S, N > &arr)
Definition: Types.h:65
MX_CORE_API const string STRING_TYPE_STRING
V & operator/=(const V &rhs)
Component-wise division of two vectors.
Definition: Types.h:159
GLint j
Definition: glad.h:2733
RowArray & operator[](size_t i)
Return the row array at the given index.
Definition: Types.h:439
S & operator[](size_t i)
Return the scalar value at the given index.
Definition: Types.h:89
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string DEFAULT_TYPE_STRING
size_t operator()(const V &v) const noexcept
Definition: Types.h:270
V & operator*=(const V &rhs)
Component-wise multiplication of two vectors.
Definition: Types.h:142
S * data()
Return a pointer to the underlying data array.
Definition: Types.h:261
UT_Vector2T< Float > Vector2
Definition: APEX_Include.h:64
M operator/(const M &rhs) const
Definition: Types.h:540
MX_CORE_API const string SURFACE_SHADER_TYPE_STRING
Definition: Types.h:314
MX_CORE_API const string DISPLACEMENT_SHADER_TYPE_STRING
Vector2(float x, float y)
Definition: Types.h:299
VectorN(S s)
Definition: Types.h:64
Vec3< T1 > transformNormal(const Mat4< T0 > &m, const Vec3< T1 > &n)
Definition: Mat4.h:1227
ConstIterator end() const
Definition: Types.h:254
S dot(const V &rhs) const
Return the dot product of two vectors.
Definition: Types.h:238
GA_API const UT_StringHolder N
V & operator-=(const V &rhs)
Component-wise subtraction of two vectors.
Definition: Types.h:125
Color3(float r, float g, float b)
Definition: Types.h:355
V operator-() const
Unary negation of a vector.
Definition: Types.h:201
MX_CORE_API const string NAME_PATH_SEPARATOR
MX_CORE_API const string SURFACE_MATERIAL_NODE_STRING
M & operator-=(const M &rhs)
Component-wise subtraction of two matrices.
Definition: Types.h:476
V operator*(const V &rhs) const
Component-wise multiplication of two vectors.
Definition: Types.h:133
const S * data() const
Return a const pointer to the underlying data array.
Definition: Types.h:591
static const Matrix33 IDENTITY
Definition: Types.h:676
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
MX_CORE_API const string ARRAY_VALID_SEPARATORS
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE constexpr T abs(T a) IMATH_NOEXCEPT
Definition: ImathFun.h:26
Vector4(float x, float y, float z, float w)
Definition: Types.h:341
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
static const Matrix44 IDENTITY
Definition: Types.h:756
M operator*(const M &rhs) const
Compute the matrix product.
Definition: Types.h:521
GLboolean r
Definition: glcorearb.h:1222
M & operator*=(const M &rhs)
Compute the matrix product.
Definition: Types.h:532
UT_Vector3T< Float > Vector3
Definition: APEX_Include.h:65
VectorN(Uninit)
Definition: Types.h:63
MatrixN(S s)
Definition: Types.h:405
Matrix33(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
Definition: Types.h:619
typename std::array< RowArray, N >::const_iterator ConstIterator
Definition: Types.h:400
V operator/(const V &rhs) const
Component-wise division of two vectors.
Definition: Types.h:150
const RowArray & operator[](size_t i) const
Return the const row array at the given index.
Definition: Types.h:442
typename std::array< float, N > RowArray
Definition: Types.h:398
M operator-() const
Unary negation of a matrix.
Definition: Types.h:554
Matrix33 getInverse() const
Return the inverse of the matrix.
Definition: Types.h:642
MX_CORE_API const string VALUE_STRING_FALSE
M & operator/=(S s)
Component-wise division of a matrix by a scalar.
Definition: Types.h:510
Iterator begin()
Definition: Types.h:250
Function object for hashing vectors.
Definition: Types.h:267
MatrixN(Uninit)
Definition: Types.h:404