Mudbox/math.h Source File

math.h
Go to the documentation of this file.
1 //**************************************************************************/
2 // Copyright (c) 2008 Autodesk, Inc.
3 // All rights reserved.
4 
5 // Use of this software is subject to the terms of the Autodesk license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 //
9 
10 //**************************************************************************/
11 // DESCRIPTION:
12 // CREATED: October 2008
13 //**************************************************************************/
14 
15 #if defined(_MSC_VER)
16 #pragma warning(push)
17 #pragma warning(disable : 4201)
18 #endif
19 
20 
21 #include <xmmintrin.h>
22 
23 #if defined(WIN32) || defined(WIN64)
24 #include <intrin.h>
25 #endif
26 
27 #if (defined(_WIN32) && !defined(_WIN64))
28 #define OS_32BIT true
29 #endif
30 
31 
32 namespace mudbox {
33 
36 {
37 public:
39  inline Vector( void ) throw() { x = y = z = 0.0f; };
40 
42  inline Vector( float fX, float fY, float fZ = 0.0f ) throw()
43  { x = fX; y = fY; z = fZ; };
44 
46  inline Vector( const Vector &vVector ) throw()
47  { x = vVector.x; y = vVector.y; z = vVector.z; };
48 
52  inline Vector( const char *pVector ) throw()
53  { x = pVector[0]*(1.0f/127.0f); y = pVector[1]*(1.0f/127.0f); z = pVector[2]*(1.0f/127.0f); };
54 
57  inline Vector( const short *pVector ) throw()
58  { x = pVector[0]*(1.0f/32767.0f); y = pVector[1]*(1.0f/32767.0f); z = pVector[2]*(1.0f/32767.0f); };
59 
61  inline Vector &Set( float fX, float fY, float fZ ) throw()
62  { x = fX; y = fY; z = fZ; return *this; };
63 
65  inline Vector &Clear( void ) throw ()
66  { return Set( 0.0f, 0.0f, 0.0f ); };
67 
71  Vector &Normalize( void ) throw();
72 
77  Vector &NormalizeApprox( void ) throw();
78 
80  Vector Normalized( void ) const throw();
81 
87  Vector &MakeOrthogonal( const Vector &vBase );
88 
94  inline Vector &SetLength( float fLength )
95  { Normalize(); operator *=( fLength ); return *this; };
96 
97 
103  inline Vector &RotateOrthogonal( const Vector &vBase )
104  { float fLen = Length(); MakeOrthogonal( vBase ); SetLength( fLen ); return *this; };
105 
106 
108  inline float LengthSquare( void ) const { return x*x+y*y+z*z; };
109 
111  float Length() const throw();
112 
114  float Length2D() const throw();
115 
118  inline float DistanceFrom( const Vector &v ) const { return operator -(v).Length(); };
119 
122  inline float DistanceSquareFrom( const Vector &v ) const { return operator -(v).LengthSquare(); };
123 
126  float DistanceFromLine( const Vector &v0, const Vector &v1 ) const;
127 
130  float DistanceFromSegment( const Vector &v0, const Vector &v1 ) const;
131 
138  float DistanceFromTriangleSquared( const Vector& v0, const Vector& v1, const Vector& v2,
139  float* aBaryCoords = 0 ) const;
140 
153  const Vector &Relocate2D( const Vector &v0, const Vector &v1 );
154 
164  void Relocate( const Vector &v0, const Vector &v1, const Vector &v2 );
165 
166 
187  bool Relocate2DQuad( const Vector &v0, const Vector &v1,
188  const Vector &v2, const Vector &v3 );
189 
195  bool RelocateQuad( const Vector &v0, const Vector &v1,
196  const Vector &v2, const Vector &v3 );
197 
199  float AngleCos( const Vector &v1 ) const throw()
200  { return Vector(*this).Normalize()|Vector(v1).Normalize(); };
201 
202 
205  inline Vector Minimum( const Vector &o )
206  { return Vector( Min(x, o.x), Min(y, o.y), Min(z, o.z) ); };
207 
210  inline Vector Maximum( const Vector &o )
211  { return Vector( Max(x, o.x), Max(y, o.y), Max(z, o.z) ); };
212 
214  inline Vector operator -( void ) const throw()
215  { return Vector( -x, -y, -z ); };
216 
219  inline Vector operator +( float f ) const throw()
220  { return Vector( x+f, y+f, z+f ); };
221 
223  inline Vector operator +( const Vector &v ) const throw()
224  { return Vector( x+v.x, y+v.y, z+v.z ); };
225 
227  inline Vector operator -( const Vector &v ) const throw()
228  { return Vector( x-v.x, y-v.y, z-v.z ); };
229 
231  inline Vector operator *( const Vector &v ) const throw()
232  { return Vector( x*v.x, y*v.y, z*v.z ); };
233 
235  inline Vector operator *( float f ) const throw()
236  { return Vector( x*f, y*f, z*f ); };
237 
239  inline Vector operator /( const Vector &v ) const throw()
240  { return Vector( x/v.x, y/v.y, z/v.z ); };
241 
243  inline Vector operator /( float f ) const throw()
244  { return operator *( 1.0f/f ); };
245 
247  inline Vector operator *( int i ) const throw()
248  { return operator *( float(i) ); };
249 
251  inline Vector operator /( int i ) const throw()
252  { return operator /( float(i) ); };
253 
255  inline Vector operator /( unsigned int i ) const throw()
256  { return operator /( float(i) ); };
257 
259  inline float operator |( const Vector &v ) const throw()
260  { return x*v.x+y*v.y+z*v.z; };
261 
263  Vector operator &( const Vector &v ) const
264  {
265  Vector vR;
266  vR.m_fX = m_fY*v.m_fZ-m_fZ*v.m_fY;
267  vR.m_fY = m_fZ*v.m_fX-m_fX*v.m_fZ;
268  vR.m_fZ = m_fX*v.m_fY-m_fY*v.m_fX;
269  return vR;
270  };
271 
272 
275  inline bool operator ==( const Vector &v ) const throw()
276  { return x == v.x && y == v.y && z == v.z; };
277 
279  inline bool operator !=( const Vector &v ) const throw()
280  { return !operator ==( v ); };
281 
283  inline operator bool( void ) const throw() { return x || y || z; };
284 
286  inline bool operator !( void ) const throw() { return !operator bool(); };
287 
289  inline Vector &operator =( const Vector &v )
290  { x = v.x; y = v.y; z = v.z; return *this; };
291 
293  inline Vector &operator <<( const Vector &v )
294  { x = v.x; y = v.y; z = v.z; return *this; };
295 
298  inline Vector &operator -=( const Vector &v ) throw()
299  { x-=v.x; y-=v.y; z-=v.z; return *this; };
300 
302  inline Vector &operator +=( const Vector &v ) throw()
303  { x+=v.x; y+=v.y; z+=v.z; return *this; };
304 
306  inline Vector &operator +=( const float f ) throw()
307  { x+=f; y+=f; z+=f; return *this; };
308 
310  inline Vector &operator -=( const float f ) throw()
311  { x-=f; y-=f; z-=f; return *this; };
312 
315  inline Vector &operator *=( float f ) throw() { x *= f; y *= f; z *= f; return *this; };
316 
319  inline Vector &operator *=( const Vector &v ) throw()
320  { x *= v.x; y *= v.y; z *= v.z; return *this; };
321 
323  inline Vector &operator /=( float f ) { return operator *=( 1.0f/f ); };
324 
326  inline float &operator [] (
327  int i
328  ) throw() { return m_aCoors[i]; };
329 
331  inline float &operator [](
332  unsigned int i
333  ) throw() { return m_aCoors[i]; };
334 
336  inline operator const float *( void ) const { return &x; };
337  union
338  {
339  struct { float m_fX, m_fY, m_fZ; };
340  struct { float x, y, z; };
341  float m_aCoors[3];
342  };
343 };
344 
345 
346 
349 {
350 public:
352  inline DblVector( void ) throw() { x = y = z = 0.0; };
353 
354 
355  Vector Vec() const {
356  return Vector((float)x, (float)y, (float)z);
357  }
358 
360  inline DblVector( double fX, double fY, double fZ = 0.0 ) throw()
361  { x = fX; y = fY; z = fZ; };
362 
364  inline DblVector( const DblVector &vVector ) throw()
365  { x = vVector.x; y = vVector.y; z = vVector.z; };
366 
368  inline DblVector( const Vector &vVector ) throw()
369  { x = vVector.x; y = vVector.y; z = vVector.z; };
370 
374  inline DblVector( const char *pVector ) throw()
375  { x = pVector[0]*(1.0/127.0); y = pVector[1]*(1.0/127.0); z = pVector[2]*(1.0/127.0); };
376 
379  inline DblVector( const short *pVector ) throw()
380  { x = pVector[0]*(1.0/32767.0); y = pVector[1]*(1.0/32767.0); z = pVector[2]*(1.0/32767.0); };
381 
383  inline DblVector &Set( double fX, double fY, double fZ ) throw()
384  { x = fX; y = fY; z = fZ; return *this; };
385 
387  inline DblVector &Clear( void ) throw ()
388  { return Set( 0.0, 0.0, 0.0 ); };
389 
393  DblVector &Normalize( void ) throw();
394 
396  DblVector Normalized( void ) const throw();
397 
403  DblVector &MakeOrthogonal( const DblVector &vBase );
404 
410  inline DblVector &SetLength( double fLength )
411  { Normalize(); operator *=( fLength ); return *this; };
412 
413 
415  inline double LengthSquare( void ) const { return x*x+y*y+z*z; };
416 
418  double Length() const throw();
419 
421  double Length2D() const throw();
422 
425  inline double DistanceFrom( const DblVector &v ) const { return operator -(v).Length(); };
426 
429  double DistanceFromLine( const DblVector &v0, const DblVector &v1 ) const;
430 
433  double DistanceFromSegment( const DblVector &v0, const DblVector &v1 ) const;
434 
435 
437  double AngleCos( const DblVector &v1 ) const throw()
438  { return DblVector(*this).Normalize()|DblVector(v1).Normalize(); };
439 
442  inline DblVector Minimum( const DblVector &o )
443  { return DblVector( Min(x, o.x), Min(y, o.y), Min(z, o.z) ); };
444 
447  inline DblVector Maximum( const DblVector &o )
448  { return DblVector( Max(x, o.x), Max(y, o.y), Max(z, o.z) ); };
449 
451  inline DblVector operator -( void ) const throw()
452  { return DblVector( -x, -y, -z ); };
453 
456  inline DblVector operator +( double f ) const throw()
457  { return DblVector( x+f, y+f, z+f ); };
458 
460  inline DblVector operator +( const DblVector &v ) const throw()
461  { return DblVector( x+v.x, y+v.y, z+v.z ); };
462 
464  inline DblVector operator -( const DblVector &v ) const throw()
465  { return DblVector( x-v.x, y-v.y, z-v.z ); };
466 
468  inline DblVector operator *( const DblVector &v ) const throw()
469  { return DblVector( x*v.x, y*v.y, z*v.z ); };
470 
472  inline DblVector operator *( double f ) const throw()
473  { return DblVector( x*f, y*f, z*f ); };
474 
476  inline DblVector operator /( const DblVector &v ) const throw()
477  { return DblVector( x/v.x, y/v.y, z/v.z ); };
478 
480  inline DblVector operator /( double f ) const throw()
481  { return operator *( 1.0/f ); };
482 
484  inline DblVector operator *( int i ) const throw()
485  { return operator *( double(i) ); };
486 
488  inline DblVector operator /( int i ) const throw()
489  { return operator /( double(i) ); };
490 
492  inline DblVector operator /( unsigned int i ) const throw()
493  { return operator /( double(i) ); };
494 
496  inline double operator |( const DblVector &v ) const throw()
497  { return x*v.x+y*v.y+z*v.z; };
498 
500  DblVector operator &( const DblVector &v ) const
501  {
502  DblVector vR;
503  vR.m_fX = m_fY*v.m_fZ-m_fZ*v.m_fY;
504  vR.m_fY = m_fZ*v.m_fX-m_fX*v.m_fZ;
505  vR.m_fZ = m_fX*v.m_fY-m_fY*v.m_fX;
506  return vR;
507  };
508 
511  inline bool operator ==( const DblVector &v ) const throw()
512  { return x == v.x && y == v.y && z == v.z; };
513 
515  inline bool operator !=( const DblVector &v ) const throw()
516  { return !operator ==( v ); };
517 
519  inline operator bool( void ) const throw() { return x || y || z; };
520 
522  inline bool operator !( void ) const throw() { return !operator bool(); };
523 
525  inline DblVector &operator =( const DblVector &v )
526  { x = v.x; y = v.y; z = v.z; return *this; };
527 
529  inline DblVector &operator <<( const DblVector &v )
530  { x = v.x; y = v.y; z = v.z; return *this; };
531 
534  inline DblVector &operator -=( const DblVector &v ) throw()
535  { x-=v.x; y-=v.y; z-=v.z; return *this; };
536 
538  inline DblVector &operator +=( const DblVector &v ) throw()
539  { x+=v.x; y+=v.y; z+=v.z; return *this; };
540 
543  inline DblVector &operator *=( double f ) { x *= f; y *= f; z *= f; return *this; };
544 
547  inline DblVector &operator *=( const DblVector &v )
548  { x *= v.x; y *= v.y; z *= v.z; return *this; };
549 
551  inline DblVector &operator /=( double f ) { return operator *=( 1.0/f ); };
552 
554  inline double &operator [] (
555  int i
556  ) throw() { return m_aCoors[i]; };
557 
559  inline double &operator [](
560  unsigned int i
561  ) throw() { return m_aCoors[i]; };
562 
564  inline operator const double *( void ) const { return &x; };
565  union
566  {
567  struct { double m_fX, m_fY, m_fZ; };
568  struct { double x, y, z; };
569  double m_aCoors[3];
570  };
571 };
572 
573 
575 inline MBDLL_DECL Vector operator *( float f, const Vector &v ) throw()
576 { return v*f; };
577 
579 inline MBDLL_DECL Vector operator *( int i, const Vector &v ) throw()
580 { return float(i)*v; };
581 
583 inline MBDLL_DECL DblVector operator *( double f, const DblVector &v ) throw()
584 { return v*f; };
585 
587 inline MBDLL_DECL DblVector operator *( int i, const DblVector &v ) throw()
588 { return double(i)*v; };
589 
590 typedef AttributeInstance<Vector> avector;
591 
592 MBDLL_DECL AttributeWidget *CreateNewVectorWidget( QWidget *pParent,
593  int iWidth,
594  avector *pAttribute );
595 
596 template <> inline
597 AttributeWidget *avector::CreateEditorWidget( QWidget *pParent, int iWidth )
598 { return CreateNewVectorWidget( pParent, iWidth, this ); };
599 
600 template <> inline
601 QString avector::AsString( bool /*bLocalized*/ ) const
602 { return QString("%1 %2 %3").arg(m_cValue.x).arg(m_cValue.y).arg(m_cValue.z); };
603 
604 template <> inline
605 void avector::SetFromString( const QString &s, bool /*bInternal*/, bool /*bLocalized*/ )
606 {
607  m_cValue.x = s.section( ' ', 0,0 ).toFloat();
608  m_cValue.y = s.section( ' ', 1,1 ).toFloat();
609  m_cValue.z = s.section( ' ', 2,2 ).toFloat();
610 };
611 
612 template <> inline
613 Attribute::AttributeType avector::Type( void ) const { return typeVector; };
614 
615 
618 {
619 public:
620  Vector4() { x=y=z=w=0.0f; }
621 
622  Vector4(float X, float Y, float Z, float W) {x=X; y=Y; z=Z; w=W;}
623 
624  inline bool operator ==( const Vector4 &v ) const throw()
625  { return x == v.x && y == v.y && z == v.z; };
626 
627  inline bool operator !=( const Vector4 &v ) const throw()
628  { return !operator ==( v ); };
629 
630  union {
631  struct {
632  float x, y, z, w;
633  };
634  double m_dAlignDummy; // try for 8 byte alignment.
635 #if !defined OS_32BIT
636  __m128 m_VecSSE; // get 16 byte alignment.
637 #endif
638  };
639 };
640 
641 
642 
644 
645 MBDLL_DECL AttributeWidget *CreateNewVector4Widget( QWidget *pParent, int iWidth, avector4 *pAttribute );
646 
647 template <> inline
648 
649 AttributeWidget *avector4::CreateEditorWidget( QWidget *pParent, int iWidth )
650 { return CreateNewVector4Widget( pParent, iWidth, this ); };
651 
652 template <> inline
653 QString avector4::AsString( bool /*bLocalized*/ ) const
654 { return QString("%1 %2 %3 %4").arg(m_cValue.x).arg(m_cValue.y).arg(m_cValue.z).arg(m_cValue.w); };
655 
656 template <> inline
657 void avector4::SetFromString( const QString &s, bool /*bInternal*/, bool /*bLocalized*/ )
658 {
659  m_cValue.x = s.section( ' ', 0, 0 ).toFloat();
660  m_cValue.y = s.section( ' ', 1, 1 ).toFloat();
661  m_cValue.z = s.section( ' ', 2, 2 ).toFloat();
662  m_cValue.w = s.section( ' ', 3, 3 ).toFloat();
663 };
664 
665 template <> inline
666 Attribute::AttributeType avector4::Type( void ) const { return typeVector; };
667 
668 
669 
673 
675 
676 {
677 public:
678 
681  Color( float fRed = 1.0f, float fGreen = 1.0f, float fBlue = 1.0f, float fAlpha = 1.0f )
682  { m_fRed = fRed; m_fGreen = fGreen; m_fBlue = fBlue, m_fAlpha = fAlpha; };
683 
684 #ifdef QT_VERSION
685 
686  Color( const QColor &c )
687  { r = c.redF();
688  g = c.greenF();
689  b = c.blueF();
690  a = 1.0f; };
691 
692 #endif
693 
695  inline void Set( float fRed, float fGreen, float fBlue, float fAlpha = 1.0f )
696  { r = fRed; g = fGreen; b = fBlue; a = fAlpha; };
697 
698 
701  inline operator const float *( void ) const { return &m_fRed; };
702 
704  inline float &operator[]( unsigned int iChannel )
705  { MB_ASSERT( iChannel < 4 ); return m_fData[iChannel]; };
706 
709  inline operator unsigned int( void ) const
710  { return (unsigned int)(0xff*m_fRed)+(((unsigned int)(0xff*m_fGreen))<<8)+
711  (((unsigned int)(0xff*m_fBlue))<<16)+(((unsigned int)(0xff*m_fAlpha))<<24); };
712 
713 
716  Color &operator *=(const float f) { r*=f; g*=f; b*=f; return *this; };
717 
719  Color operator *( float f ) const
720  { return Color( r*f, g*f, b*f, a*f ); };
721 
723  Color operator /( float f ) const
724  { return operator *( 1/f ); };
725 
727  Color operator *( const Color &c ) const
728  { return Color( r*c.r, g*c.g, b*c.b, a*c.a ); };
729 
732  Color &operator *=( const Color &c )
733  { r *= c.r; g *= c.g; b *= c.b; a *= c.a; return *this; };
734 
736  Color operator +( const Color &c ) const
737  { return Color( r+c.r, g+c.g, b+c.b, a+c.a ); };
738 
740  Color operator -( const Color &c ) const
741  { return Color( r-c.r, g-c.g, b-c.b, a-c.a ); };
742 
744  Color &operator +=( const Color &c )
745  { r += c.r; g += c.g; b += c.b; a += c.a; return *this; };
746 
748  bool operator ==( const Color &c ) const
749  { return r == c.r && g == c.g && b == c.b && a == c.a; };
750 
752  inline bool operator !=( const Color &c ) const { return !operator ==( c ); };
753 
754 
762  Color Mix( const Color &c, float f ) const
763  { return Color( r*f+c.r*(1-f), g*f+c.g*(1-f), b*f+c.b*(1-f), a*f+c.a*(1-f) ); };
764 
766  inline float Luminance() const
767  { return 0.299f * r + 0.587f * g + 0.114f * b; }
768 
769 
770  void toHSV(float &hue, float &sat, float &val) const;
771  void fromHSV(float hue, float sat, float val);
772 
773  void toCMYK (float &c, float &m, float &y, float &k) const;
774  void fromCMYK (float c, float m, float y, float k);
775 
776 #ifdef QT_VERSION
777  operator QColor( void ) const { QColor col; col.setRgbF( r, g, b ); return col; };
778  QColor ToQColor( void ) const { QColor col; col.setRgbF( r, g, b ); return col; };
779 #endif
780 
781  union {
782  struct { float m_fRed, m_fGreen, m_fBlue, m_fAlpha; };
783  struct { float r, g, b, a; };
784  float m_fData[4];
785 
786  double m_dAlignDummy; // try for 8 byte alignment.
787 #if !defined OS_32BIT
788  __m128 m_vAlignDummy; // try for 16 byte alignment....
789 #endif
790  };
791 
792 
793  static Color black;
794  static Color white;
795  static Color red;
796  static Color green;
797  static Color blue;
798  static Color gray;
800 };
801 
802 
803 
805 inline Color operator *( float f, const Color &c )
806 { return Color( c.r*f, c.g*f, c.b*f, c.a*f ); };
807 
808 
809 typedef AttributeInstance<Color> acolor;
810 
811 MBDLL_DECL AttributeWidget *CreateNewColorWidget( QWidget *pParent, int iWidth, acolor *pAttribute );
812 
813 template <> inline
814 AttributeWidget *acolor::CreateEditorWidget( QWidget *pParent, int iWidth )
815 { return CreateNewColorWidget( pParent, iWidth, this ); };
816 
817 template <> inline
818 Attribute::AttributeType acolor::Type( void ) const { return typeColor; };
819 
820 template <> inline
821 QString acolor::AsString( bool /*bLocalized*/ )
822 const { return QString("%1 %2 %3 %4").arg(m_cValue.r).arg(m_cValue.g).arg(m_cValue.b).arg(m_cValue.a); };
823 
824 template <> inline
825 void acolor::SetFromString( const QString &s, bool /*bInternal*/, bool /*bLocalized*/ )
826 {
827  m_cValue.r = s.section( ' ', 0, 0 ).toFloat();
828  m_cValue.g = s.section( ' ', 1, 1 ).toFloat();
829  m_cValue.b = s.section( ' ', 2, 2 ).toFloat();
830  m_cValue.a = s.section( ' ', 3, 3 ).toFloat();
831 };
832 
833 
834 
839 {
840 public:
842  AxisAlignedBoundingBox( void ) { Reset(); };
843 
845  AxisAlignedBoundingBox( const Vector &vStart, const Vector &vEnd ) :
846  m_vStart( vStart ),
847  m_vEnd( vEnd ) {};
848 
851  AxisAlignedBoundingBox( const Vector &vCenter, float fSize )
852  {
853  Vector v( fSize, fSize, fSize );
854  m_vStart = vCenter-v;
855  m_vEnd = vCenter+v;
856  };
857 
860  m_vStart( cA.m_vStart ),
861  m_vEnd( cA.m_vEnd ) {};
862 
865  {
866  m_vStart = cBB.m_vStart;
867  m_vEnd = cBB.m_vEnd;
868  return *this;
869  };
870 
873  {
874  for ( int i = 0; i < 8; i++ ) Extend( cBB[i] );
875  return *this;
876  };
877 
879  bool operator ==( const AxisAlignedBoundingBox &cBB ) const
880  {
881  return m_vStart == cBB.m_vStart && m_vEnd == cBB.m_vEnd;
882  };
883 
885  void Reset( void )
886  {
887  m_vStart.Set( 0, 0, 0 );
888  m_vEnd.Set( -1, -1, -1 );
889  };
890 
892  void Serialize( Stream &s );
893 
894 
896  bool operator !=( const AxisAlignedBoundingBox &cBox ) const
897  { return !(operator ==(cBox)); };
898 
899 
901  inline void Extend( const Vector & cV) throw()
902  {
903  if ( IsEmpty() ) {
904  m_vStart = m_vEnd = cV;
905  } else {
906  if ( m_vStart.m_fX > cV.m_fX ) m_vStart.m_fX = cV.m_fX;
907  if ( m_vStart.m_fY > cV.m_fY ) m_vStart.m_fY = cV.m_fY;
908  if ( m_vStart.m_fZ > cV.m_fZ ) m_vStart.m_fZ = cV.m_fZ;
909  if ( m_vEnd.m_fX < cV.m_fX ) m_vEnd.m_fX = cV.m_fX;
910  if ( m_vEnd.m_fY < cV.m_fY ) m_vEnd.m_fY = cV.m_fY;
911  if ( m_vEnd.m_fZ < cV.m_fZ ) m_vEnd.m_fZ = cV.m_fZ;
912  }
913  }
914 
916  void Extend( const AxisAlignedBoundingBox &bb )
917  {
918  if ( !bb.IsEmpty() ) {
919  Extend( bb.m_vStart );
920  Extend( bb.m_vEnd );
921  };
922  };
923 
926  void ExpandBy(float f) throw()
927  {
928  m_vStart -= f;
929  m_vEnd += f;
930  }
931 
936  void Transform( const class Matrix &mMatrix );
937 
939  Vector operator []( int iCornerIndex ) const;
940 
942  float Size( void ) const { return Max( Max( XSize(), YSize() ), ZSize() ); };
943 
945  float XSize( void ) const { return m_vEnd.m_fX-m_vStart.m_fX; };
946 
948  float YSize( void ) const { return m_vEnd.m_fY-m_vStart.m_fY; };
949 
951  float ZSize( void ) const { return m_vEnd.m_fZ-m_vStart.m_fZ; };
952 
954  float Volume( void ) const { return XSize()*YSize()*ZSize(); };
955 
957  Vector Center( void ) const { return (m_vStart+m_vEnd)*0.5f; };
958 
960  bool IsPartOf( const AxisAlignedBoundingBox &cBB ) const
961  {
962  return (
963  m_vStart.m_fX >= cBB.m_vStart.m_fX && m_vEnd.m_fX <= cBB.m_vEnd.m_fX &&
964  m_vStart.m_fY >= cBB.m_vStart.m_fY && m_vEnd.m_fY <= cBB.m_vEnd.m_fY &&
965  m_vStart.m_fZ >= cBB.m_vStart.m_fZ && m_vEnd.m_fZ <= cBB.m_vEnd.m_fZ );
966  };
967 
969  bool IsTouching( const AxisAlignedBoundingBox &cBB ) const
970  {
971  return (
972  m_vStart.m_fX < cBB.m_vEnd.m_fX && m_vEnd.m_fX > cBB.m_vStart.m_fX &&
973  m_vStart.m_fY < cBB.m_vEnd.m_fY && m_vEnd.m_fY > cBB.m_vStart.m_fY &&
974  m_vStart.m_fZ < cBB.m_vEnd.m_fZ && m_vEnd.m_fZ > cBB.m_vStart.m_fZ );
975  };
976 
977 
984  bool IsTouching(
985  const Vector &vStart,
986  const Vector &vEnd,
987  float &fPlace
988  ) const;
990 
992  bool IsContaining( const Vector &cV ) const
993  {
994  return (
995  m_vStart.m_fX <= cV.m_fX && m_vEnd.m_fX >= cV.m_fX &&
996  m_vStart.m_fY <= cV.m_fY && m_vEnd.m_fY >= cV.m_fY &&
997  m_vStart.m_fZ <= cV.m_fZ && m_vEnd.m_fZ >= cV.m_fZ );
998  };
999 
1000 
1002  bool IsContaining( const AxisAlignedBoundingBox &b ) const
1003  { return IsContaining( b.m_vStart ) && IsContaining( b.m_vEnd ); };
1004 
1008  {
1009  if( !IsTouching( cOther ) ) return AxisAlignedBoundingBox();
1010 
1011  return AxisAlignedBoundingBox(
1012  Vector(
1013  Max( cOther.m_vStart.x, m_vStart.x ),
1014  Max( cOther.m_vStart.y, m_vStart.y ),
1015  Max( cOther.m_vStart.z, m_vStart.z ) ) ,
1016  Vector(
1017  Min( cOther.m_vEnd.x, m_vEnd.x ),
1018  Min( cOther.m_vEnd.y, m_vEnd.y ),
1019  Min( cOther.m_vEnd.z, m_vEnd.z ) ) );
1020  }
1021 
1024  bool IsEmpty( void ) const { return m_vStart.x > m_vEnd.x; };
1025 
1028  {
1029  return AxisAlignedBoundingBox( m_vStart*fFactor, m_vEnd*fFactor );
1030  };
1031 
1033  static AxisAlignedBoundingBox SphereBoundingBox( const Vector& cCenter, float fRadius, const Matrix& mTransform );
1034 
1037 };
1038 
1039 
1040 
1045 {
1046 
1047 public:
1049  Base( void );
1050 
1052  Base( const Vector &vA, const Vector &vB, const Vector &vC );
1053 
1055  bool operator !=( const Base &o ) const { return a != o.a || b != o.b || c != o.c; };
1056 
1058  void Derive(
1059  unsigned int iIndex,
1060  bool bRightHand = true
1061  );
1062 
1063 
1065 
1066  void Orthogonalize(
1067  unsigned int iIndex,
1068  unsigned int iSource = (unsigned int)-1
1069  );
1071 
1073  void Normalize( void ) { a.Normalize(); b.Normalize(); c.Normalize(); };
1074 
1075 
1077  Vector TransformFrom( const Vector &cSource ) const;
1078 
1080  Vector TransformTo( const Vector &cSource ) const;
1081 
1083  Base operator *( float fFactor ) const;
1084 
1086  Base operator +( const Base &bOther ) const;
1087 
1089  Base operator -( const Base &bOther ) const;
1090 
1092  Vector& Axis(
1093  unsigned int iIndex
1094  );
1095 
1096 
1098  const Vector& Axis(
1099  unsigned int iIndex
1100  ) const;
1101 
1103 };
1104 
1105 
1106 
1108 class SubSpace : public Node
1109 
1110 {
1111  DECLARE_CLASS;
1112 
1113 public:
1114  virtual void Initialize( const class Mesh *pMesh, Store<unsigned int> aFaceList, float fAClip, float fBClip );
1115  virtual bool IsOutside( const Vector &vPos, float fRange ) const;
1116  virtual AxisAlignedBoundingBox BoundingBox( void ) const;
1117 };
1118 
1119 
1120 
1123 {
1124 public:
1125 
1127  Matrix( void ) {};
1128 
1129  Matrix( const Matrix &m ) :
1130  _11(m._11), _12(m._12), _13(m._13), _14(m._14),
1131  _21(m._21), _22(m._22), _23(m._23), _24(m._24),
1132  _31(m._31), _32(m._32), _33(m._33), _34(m._34),
1133  _41(m._41), _42(m._42), _43(m._43), _44(m._44) {};
1134 
1136  Matrix( float f11, float f12, float f13, float f14,
1137  float f21, float f22, float f23, float f24,
1138  float f31, float f32, float f33, float f34,
1139  float f41, float f42, float f43, float f44 ) :
1140  _11(f11), _12(f12), _13(f13), _14(f14),
1141  _21(f21), _22(f22), _23(f23), _24(f24),
1142  _31(f31), _32(f32), _33(f33), _34(f34),
1143  _41(f41), _42(f42), _43(f43), _44(f44) {};
1144 
1146  Matrix( const double *pMatrix );
1147 
1149  float &operator()( int iRow, int iColumn )
1150  {
1151  return m_fData[iRow*4+iColumn];
1152  };
1153 
1155  float operator()( int iRow, int iColumn ) const
1156  {
1157  return m_fData[iRow*4+iColumn];
1158  };
1159 
1162  operator const float *( void ) const { return m_fData; };
1163 
1166  operator float *( void ) { return m_fData; };
1167 
1169  Matrix &SetIdentity( void );
1170 
1172  bool IsIdentity( void ) const;
1173 
1175  bool IsRigid( void ) const;
1176 
1178  Matrix &operator *=( float );
1179 
1181  Matrix operator *( const Matrix &m ) const;
1182 
1184  Matrix operator *( float ) const;
1185 
1187  Matrix operator +( const Matrix & ) const;
1188 
1190  Matrix &operator *=( const Matrix &m );
1191 
1193  bool operator ==( const Matrix &m ) const;
1194 
1197  void SetRow( int iRowIndex, const Vector &vValue );
1198 
1200  Matrix &Transpose( void );
1201 
1204  Matrix &Invert( bool* pOk = 0 );
1205 
1208  Matrix &FromEuler( const Vector &vAngles );
1209 
1211  Vector ToEuler( void ) const;
1212 
1214  Matrix &FromAxisAngle( const Vector &vAxis, float fAngle );
1215 
1220  const Vector &v,
1221  float fW = 1.0f
1222  ) const
1223  {
1224  return Vector(
1225  v.m_fX*_11+v.m_fY*_21+v.m_fZ*_31+fW*_41,
1226  v.m_fX*_12+v.m_fY*_22+v.m_fZ*_32+fW*_42,
1227  v.m_fX*_13+v.m_fY*_23+v.m_fZ*_33+fW*_43 );
1228  };
1229 
1235  const Vector &v,
1236  float fW = 1.0f
1237  ) const
1238  {
1239  float fRW = v.m_fX*_14+v.m_fY*_24+v.m_fZ*_34+fW*_44;
1240  return (1/fRW)*Vector(
1241  v.m_fX*_11+v.m_fY*_21+v.m_fZ*_31+fW*_41,
1242  v.m_fX*_12+v.m_fY*_22+v.m_fZ*_32+fW*_42,
1243  v.m_fX*_13+v.m_fY*_23+v.m_fZ*_33+fW*_43 );
1244  };
1245 
1246 
1253  const Vector &v,
1254  float fW,
1255  float &fRW
1256  ) const
1257  {
1258  fRW = v.m_fX*_14+v.m_fY*_24+v.m_fZ*_34+fW*_44;
1259  return Vector(
1260  v.m_fX*_11+v.m_fY*_21+v.m_fZ*_31+fW*_41,
1261  v.m_fX*_12+v.m_fY*_22+v.m_fZ*_32+fW*_42,
1262  v.m_fX*_13+v.m_fY*_23+v.m_fZ*_33+fW*_43 );
1263  };
1264 
1270  {
1271  return Vector(
1272  v.m_fX*_11+v.m_fY*_21+v.m_fZ*_31,
1273  v.m_fX*_12+v.m_fY*_22+v.m_fZ*_32,
1274  v.m_fX*_13+v.m_fY*_23+v.m_fZ*_33 );
1275  };
1276 
1277  union {
1278  float m_fData[16];
1279  struct {
1280  float _11, _12, _13, _14;
1281  float _21, _22, _23, _24;
1282  float _31, _32, _33, _34;
1283  float _41, _42, _43, _44;
1284  };
1285  double m_fAlignDummy[8]; // at least get it 8 byte aligned.
1286 #if !defined OS_32BIT
1287  __m128 m_vAlignDummy[4]; // try for 16 byte....
1288 #endif
1289  };
1290 };
1301 {
1302 public:
1304  inline Quaternion( void ) { SetIdentity(); };
1305 
1307  inline Quaternion(
1308  float fW,
1309  const Vector &vXYZ
1310  )
1311  { m_fW = fW; m_fX = vXYZ.x; m_fY = vXYZ.y; m_fZ = vXYZ.z; };
1312 
1314  inline Quaternion( float fW, float fX, float fY, float fZ )
1315  { m_fW = fW; m_fX = fX; m_fY = fY; m_fZ = fZ; };
1316 
1318  Quaternion(
1319  const Vector &vAxis,
1320  float fAngle
1321  );
1322 
1324  Quaternion( const Matrix &mRotation );
1325 
1327  float LengthSquare( void ) const;
1328 
1331  float Length( void ) const;
1332 
1334  Matrix ToMatrix( void ) const;
1335 
1337  Vector Transform(
1338  const Vector &vPoint
1339  ) const;
1340 
1342  inline Quaternion operator *( float fMultiplier ) const
1343  { return Quaternion( m_fW*fMultiplier, m_fX*fMultiplier, m_fY*fMultiplier, m_fZ*fMultiplier ); };
1344 
1346  inline Quaternion &operator *=( float fMultiplier )
1347  { *this = operator *( fMultiplier ); return *this; };
1348 
1350  inline Quaternion operator -( void ) const
1351  { return Quaternion( -m_fW, -m_fX, -m_fY, -m_fZ ); };
1352 
1354  Quaternion operator +( const Quaternion &vAddition ) const;
1355 
1357  Quaternion &operator +=( const Quaternion &vAddition );
1358 
1360  Quaternion operator -( const Quaternion &vAddition ) const;
1361 
1363  Quaternion &operator -=( const Quaternion &vAddition );
1364 
1367  Quaternion operator *( const Quaternion &vMultiplier ) const;
1368 
1370  Quaternion &operator *=( const Quaternion &vMultiplier );
1371 
1373  float operator |( const Quaternion &vMultiplier ) const;
1374 
1377  Quaternion &Normalize( void );
1378 
1380  Quaternion &Conjugate( void );
1381 
1384  Quaternion &Invert( void );
1385 
1387  Quaternion Slerp( const Quaternion &vTarget, float fWeight ) const;
1388 
1390  inline void SetIdentity( void )
1391  { m_fW = 1.0; m_fX = m_fY = m_fZ = 0.0f; };
1392 
1394  void SetZero( void ) { m_fW = m_fX = m_fY = m_fZ = 0.0f; };
1395 
1397  float operator [](
1398  int iIndex
1399  ) const;
1400 
1405  float m_fW, m_fX, m_fY, m_fZ;
1406 };
1407 
1416 {
1417 public:
1419  inline DualQuaternion( void ) { SetIdentity(); };
1420 
1423  const Quaternion &vReal,
1424  const Quaternion &vDual
1425  )
1426  { m_vReal = vReal; m_vDual = vDual; };
1427 
1430  DualQuaternion(
1431  const Vector &vPivot,
1432  const Vector &vAxis,
1433  float fAngle
1434  );
1435 
1438  float fAngle,
1439  float fPitch,
1440  const Vector &vDirection,
1441  const Vector &vMoment
1442  );
1443 
1445  DualQuaternion(
1446  const Vector &vTranslation,
1447  const Quaternion &vRotation
1448  );
1449 
1451  DualQuaternion( const Matrix &mRigid );
1452 
1454  Matrix ToMatrix( void ) const;
1455 
1457  Vector Translation( void ) const;
1458 
1460  Vector Transform( const Vector &vPoint ) const;
1461 
1463  DualQuaternion operator +( const DualQuaternion &vAddition ) const;
1464 
1466  DualQuaternion &operator +=( const DualQuaternion &vAddition );
1467 
1469  DualQuaternion operator -( const DualQuaternion &vAddition ) const;
1470 
1472  DualQuaternion &operator -=( const DualQuaternion &vAddition );
1473 
1476  DualQuaternion operator *( const DualQuaternion &vMultiplier ) const;
1477 
1479  DualQuaternion &operator *=( const DualQuaternion &vMultiplier );
1480 
1482  DualQuaternion operator *( float fMultiplier ) const;
1483 
1486  DualQuaternion &Normalize( void );
1487 
1489  void ToScrew( float &fAngle, float &fPitch, Vector &vDirection, Vector &vMoment ) const;
1490 
1492  DualQuaternion &Power( float fExponent );
1493 
1496  DualQuaternion Slerp( const DualQuaternion &vTarget, float fWeight ) const;
1497 
1499  DualQuaternion &Conjugate( void );
1500 
1502  DualQuaternion &DualConjugate( void );
1503 
1506  inline DualQuaternion &DoubleConjugate( void ) { Conjugate(); DualConjugate(); return *this; };
1507 
1510  DualQuaternion &Invert( void );
1511 
1513  void SetIdentity( void ) { m_vReal.SetIdentity(); m_vDual.SetZero(); };
1514 
1516  float operator [](
1517  int iIndex
1518  ) const;
1519 
1526 
1527 private:
1530  DualQuaternion( const Vector &vPoint );
1531 
1532 };
1533 
1536 {
1537  Vector m_vStart, m_vEnd, m_vDirection;
1538  float m_fFactor;
1539 
1540 public:
1541 
1543  Line( const Vector &vStart, const Vector &vEnd );
1544 
1550 
1552 
1553  float RangeFrom( const Vector &vPoint );
1554 
1557  {
1561  INTERSECTING
1562  };
1563 
1567  IntersectionResult Intersection2D( const Line& cOther, Vector &vResult, bool bSegmentOnly = false );
1568 };
1569 
1570 
1577 
1579 
1583 
1584 class MBDLL_DECL Selector : virtual public Node
1585 {
1586  DECLARE_CLASS;
1587 
1588 public:
1589  enum EState
1590  {
1593  eTouching
1594  };
1595 
1597  virtual EState IsTouchedBy( const AxisAlignedBoundingBox &cArea ) const;
1598 };
1599 
1600 
1601 inline MBDLL_DECL Vector operator *( const Vector &v, const Matrix &m )
1602 {
1603  return Vector(
1604  v.m_fX*m._11+v.m_fY*m._21+v.m_fZ*m._31+m._41,
1605  v.m_fX*m._12+v.m_fY*m._22+v.m_fZ*m._32+m._42,
1606  v.m_fX*m._13+v.m_fY*m._23+v.m_fZ*m._33+m._43 );
1607 };
1608 
1609 inline MBDLL_DECL Vector operator *( const Matrix &m, const Vector &v )
1610 {
1611  return Vector(
1612  v.m_fX*m._11+v.m_fY*m._12+v.m_fZ*m._13+m._14,
1613  v.m_fX*m._21+v.m_fY*m._22+v.m_fZ*m._23+m._24,
1614  v.m_fX*m._31+v.m_fY*m._32+v.m_fZ*m._33+m._34 );
1615 };
1616 
1617 
1623 {
1624 public:
1625  CheckableFloat( void ) { m_bState = true; m_fValue = 0.0f; };
1626  CheckableFloat( bool bState, float fValue ) { m_bState = bState; m_fValue = fValue; };
1627 
1629  void SetValue( float f ) { m_fValue = f; };
1630 
1632  float Value( void ) const { return m_fValue; };
1633 
1635  void SetState( bool b ) { m_bState = b; };
1636 
1638  bool State( void ) const { return m_bState; };
1639 
1640  inline bool operator ==( const CheckableFloat &cf ) const throw() { return State() == cf.State() && Value() == cf.Value(); };
1641  inline bool operator !=( const CheckableFloat &cf ) const throw() { return !operator ==( cf ); };
1642  inline CheckableFloat &operator =( const CheckableFloat &cf ) { m_bState = cf.m_bState; m_fValue = cf.m_fValue; return *this; };
1643 
1644  void Serialize( Stream &s )
1645  {
1646  s == m_bState == m_fValue;
1647  };
1648 
1649 
1650 protected:
1651  bool m_bState;
1652  float m_fValue;
1653 };
1654 
1656 
1658 
1659 class AttributeCheckableFloat : public AttributeInstance<CheckableFloat>
1660 {
1661 public:
1662  AttributeCheckableFloat( Node *pOwner = 0, const QString &sID = "", const QString &sValueName = "" ) : AttributeInstance<CheckableFloat>( pOwner, sID )
1663  { m_iSize = sizeof(CheckableFloat); m_sValueName = sValueName; };
1664  void SetValueName( const QString &sValueName ) { m_sValueName = sValueName; };
1665  QString ValueName( void ) const { return m_sValueName; };
1666 
1667  Attribute::AttributeType Type( void ) const { return typeUnknown; };
1668  AttributeWidget *CreateEditorWidget( QWidget *pParent, int iWidth ) { return CreateNewCheckableFloatWidget( pParent, iWidth, (AttributeCheckableFloat *)this ); };
1669  QString AsString( bool /*bLocalized*/ ) const { return QString("%1 %2").arg(m_cValue.State() ? "true" : "false").arg(m_cValue.Value()); };
1670  void SetFromString( const QString &s, bool /*bInternal*/ = true, bool /*bLocalized*/ = false )
1671  {
1672  m_cValue.SetState( s.section( ' ', 0, 0 ) == "true" ? true : false );
1673  m_cValue.SetValue( s.section( ' ', 1, 1 ).toFloat() );
1674  };
1675 
1676  virtual void SetState( bool bState, bool bInternal = false )
1677  {
1678  m_cValue.SetState( bState );
1679  UpdateTargets();
1680  if( !bInternal )
1681  StartEvent( etValueChanged );
1682  };
1683 
1684 protected:
1685  QString m_sValueName;
1686 };
1687 
1689 // data structure, references: StampConfiguration and CheckableFloat.
1691 {
1692 
1694  {
1695  m_iSize = 2;
1696  m_aValue[0] = 0; m_aValue[1] = 1;
1697  m_bComplementary = false;
1698  }
1699 
1701  void SetState( bool b ) { s_bActive = b; };
1703  bool State( void ) const { return s_bActive; };
1704 
1705  float Value(unsigned int i) const { MB_ASSERT(i < m_iSize); return m_aValue[i]; }
1706  void SetValue(unsigned int i, float v) { MB_ASSERT(i < m_iSize); m_aValue[i] = v; }
1707 
1708  void AddElement(unsigned int i, QString sLabel, float fMin, float fMax, float fValue)
1709  {
1710  MB_ASSERT(i < m_iSize);
1711  MB_ASSERT(fValue > fMin && fValue < fMax);
1712  m_aLabel[i] = sLabel;
1713  m_aMin[i] = fMin;
1714  m_aMax[i] = fMax;
1715  m_aValue[i] = fValue;
1716  }
1717 
1718  unsigned int Size() const { return m_iSize; }
1719 
1722  bool IsComplementary() const { return m_bComplementary; }
1723  void SetComplementary(bool b) { m_bComplementary = b; }
1724 
1725  inline bool operator ==( const CheckableFloatArray & ) const throw() { return false; };
1726  inline bool operator !=( const CheckableFloatArray &v ) const throw() { return !operator ==( v ); };
1727 
1728  void Serialize( Stream &s )
1729  {
1730  s == s_bActive == m_iSize == m_bComplementary;
1731  for (unsigned int i = 0; i < m_iSize; ++i)
1732  s == m_aLabel[i] == m_aMin[i] == m_aMax[i] == m_aValue[i];
1733  };
1734 
1735  static bool s_bActive;
1736  unsigned int m_iSize;
1737  QString m_aLabel[2];
1738  float m_aMin[2];
1739  float m_aMax[2];
1740  float m_aValue[2];
1742 };
1743 
1745 
1747 
1748 class AttributeCheckableFloatArray : public AttributeInstance<CheckableFloatArray>
1749 {
1750 public:
1751  AttributeCheckableFloatArray( Node *pOwner = 0, const QString &sID = "" )
1752  : AttributeInstance<CheckableFloatArray>( pOwner, sID )
1753  { m_iSize = sizeof(CheckableFloat); };
1754 
1756 
1757  Attribute::AttributeType Type( void ) const { return typeUnknown; };
1758  AttributeWidget *CreateEditorWidget( QWidget *pParent, int iWidth )
1759  {
1760  return CreateNewCheckableFloatArrayWidget( pParent, iWidth, (AttributeCheckableFloatArray *)this );
1761  };
1762  // the data structure of this attribute
1763  //virtual QString AsString( bool bLocalized = false ) const;
1764  //virtual void SetFromString( const QString &sValue, bool bInternal = true, bool /*bLocalized*/ = false );
1765 
1766 protected:
1767 };
1768 
1769 //-----------------------------------------------------------------------------
1773 static inline bool FloatEqual(float A, float B, const int max_ulps = 4)
1774 {
1775  int a = *(int*)&A; // load the float bits into integers
1776  int b = *(int*)&B;
1777  // floats have a sign bit, convert to 2's compliment
1778  if (a < 0) a = 0x80000000 - a; // correctly handles 0 vs -0 and
1779  if (b < 0) b = 0x80000000 - b; // positive and negative denormals
1780  return (abs(a - b) <= max_ulps);
1781 }
1782 
1783 //-----------------------------------------------------------------------------
1787 static inline bool FloatGreaterOrEqual(float A, float B, const int max_ulps = 4)
1788 {
1789  int a = *(int*)&A; // load the float bits into integers
1790  int b = *(int*)&B;
1791  // floats have a sign bit, convert to 2's compliment
1792  if (a < 0) a = 0x80000000 - a; // correctly handles 0 vs -0 and
1793  if (b < 0) b = 0x80000000 - b; // positive and negative denormals
1794  return (a - b) >= -max_ulps;
1795 }
1796 
1797 //-----------------------------------------------------------------------------
1801 static inline bool FloatLessOrEqual(float A, float B, const int max_ulps = 4)
1802 {
1803  return FloatGreaterOrEqual(B, A, max_ulps);
1804 }
1805 
1806 
1807 }; // end of namespace mudbox
1808 
1809 
1810 #if defined(_MSC_VER)
1811 #pragma warning(pop)
1812 #endif
float Volume(void) const
Returns the volume of the box.
Definition: math.h:954
static Color green
Definition: math.h:796
Quaternion(void)
Constructs a quaternion which represents the identical transformation.
Definition: math.h:1304
float _24
Definition: math.h:1281
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
AxisAlignedBoundingBox Intersection(const AxisAlignedBoundingBox &cOther) const
Returns the intersection between this box and cOther.
Definition: math.h:1007
float z
Definition: math.h:340
Vector Minimum(const Vector &o)
Returns the minimum of this and the argument vector.
Definition: math.h:205
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
Definition: GLee.h:10762
float m_fZ
Definition: math.h:339
const QPoint operator/(const QPoint &p, qreal c)
Definition: qpoint.h:201
GLenum GLint GLint y
Definition: GLee.h:876
static bool FloatGreaterOrEqual(float A, float B, const int max_ulps=4)
compares floats for >= with a tolerance expressed in Units of Least Precision.
Definition: math.h:1787
void SetValueName(const QString &sValueName)
Definition: math.h:1664
Represents a 3D vector or point with S23E8 floating point elements.
Definition: math.h:35
MBDLL_DECL AttributeWidget * CreateNewVector4Widget(QWidget *pParent, int iWidth, avector4 *pAttribute)
static Color gray
Definition: math.h:798
void SetState(bool b)
Sets the associated boolean value.
Definition: math.h:1635
AttributeCheckableFloat acheckablefloat
Definition: math.h:1688
A Mesh is a collection of vertices organized into faces, and optional Texture Coordinate information...
Definition: mesh.h:452
QString ValueName(void) const
Definition: math.h:1665
GLdouble GLdouble z
Definition: GLee.h:1393
float _31
Definition: math.h:1282
float m_fRed
Definition: math.h:782
double m_fX
Definition: math.h:567
QByteArray & operator+=(QByteArray &a, const QStringBuilder< A, B > &b)
Quaternion m_vReal
Content of the dual quaterion as two regular quaternions.
Definition: math.h:1525
float z
Definition: math.h:632
float m_fY
Definition: math.h:339
float _12
Definition: math.h:1280
#define MB_ASSERT(condition)
Definition: mudbox.h:73
Color Mix(const Color &c, float f) const
Mix two colors based on a scalar value which should be within the range 0 and 1.
Definition: math.h:762
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
State
The state the media producing object is in at the moment.
GLfloat GLfloat GLfloat v2
Definition: GLee.h:1736
DblVector(const short *pVector)
Construct the vector from a pointer to 16bit signed data.
Definition: math.h:379
static Color red
Definition: math.h:795
void setRgbF(qreal r, qreal g, qreal b, qreal a=1.0)
Vector a
Definition: math.h:1102
virtual ~AttributeCheckableFloatArray(void)
Definition: math.h:1755
Attribute::AttributeType Type(void) const
Returns the type of the attribute.
Definition: node.h:450
double m_dAlignDummy
Definition: math.h:786
double m_dAlignDummy
Definition: math.h:634
Vector4(float X, float Y, float Z, float W)
Definition: math.h:622
mudbox::Vector & operator<<(mudbox::Vector &v, const HWVector &r)
Definition: SSE.h:245
DualQuaternion & DoubleConjugate(void)
Conjugates the dual quaternion by both the quaternion and dual conjugation.
Definition: math.h:1506
void SetComplementary(bool b)
Definition: math.h:1723
DblVector(const char *pVector)
Construct the vector from a pointer to 8bit signed data.
Definition: math.h:374
void SetState(bool b)
Sets the associated boolean value.
Definition: math.h:1701
AxisAlignedBoundingBox(void)
Creates an empty bounding box.
Definition: math.h:842
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
void Reset(void)
Makes the box empty.
Definition: math.h:885
DualQuaternion(void)
Constructs a dual quaternion which represents the identical transformation.
Definition: math.h:1419
Represents a local coordinate basis comprising three axes that define a coordinate system...
Definition: math.h:1044
Definition: qcolor.h:67
Vector ProjectedTransform(const Vector &v, float fW=1.0f) const
Transforms a point (represented by a Vector) by the matrix and returns the result.
Definition: math.h:1234
float AngleCos(const Vector &v1) const
Returns the cosine of the angle between this vector and the one passed in.
Definition: math.h:199
void SetZero(void)
Sets the quaternion to represents the zero transformation.
Definition: math.h:1394
void SetFromString(const QString &s, bool=true, bool=false)
Sets the value of the attribute as a string.
Definition: math.h:1670
Represents a bounding box whose axes are aligned with the coordinate system.
Definition: math.h:838
double y
Definition: math.h:568
float Value(void) const
Retrieves the associated float value.
Definition: math.h:1632
double AngleCos(const DblVector &v1) const
Returns the cosine of the angle between this vector and the one passed in.
Definition: math.h:437
DblVector Maximum(const DblVector &o)
Returns the maximum of this and the argument vector.
Definition: math.h:447
AttributeWidget * CreateEditorWidget(QWidget *pParent, int iWidth)
This function creates and returns the address of a QWidget object.
Definition: math.h:1668
This is the base class for most classes in the Mudbox SDK.
Definition: node.h:740
The Quaternion class is used to represent rotations in most cases.
Definition: math.h:1300
#define inline
Definition: image.h:2490
void Serialize(Stream &s)
Definition: math.h:1728
type Min(type a, type b)
Definition: mudbox.h:184
virtual QString AsString(bool bLocalized=false) const
Returns the value of the attribute as a string.
Definition: math.h:601
Vector Maximum(const Vector &o)
Returns the maximum of this and the argument vector.
Definition: math.h:210
Quaternion(float fW, const Vector &vXYZ)
Constructs a quaternion by passing the real part as a scalar, and the rest as a vector.
Definition: math.h:1307
qreal greenF() const
float _34
Definition: math.h:1282
static bool FloatLessOrEqual(float A, float B, const int max_ulps=4)
compares floats for <= with="" a="" tolerance="" expressed="" in="" units="" of="" least="" precision.="">
Definition: math.h:1801
unsigned int m_iSize
Definition: math.h:1736
DblVector & Normalize(void)
Normalizes the vector and returns it.
float & operator()(int iRow, int iColumn)
Returns a reference to a specific element in the matrix.
Definition: math.h:1149
void Set(float fRed, float fGreen, float fBlue, float fAlpha=1.0f)
Sets the current value of the color.
Definition: math.h:695
float _21
Definition: math.h:1281
AttributeWidget * CreateEditorWidget(QWidget *pParent, int iWidth)
This function creates and returns the address of a QWidget object.
Definition: math.h:1758
qreal redF() const
bool operator==(const Attribute &cA, const AttributeInstance< type > &cB)
This operator compares the two attributes and NOT their values.
Definition: node.h:577
Q_CORE_EXPORT QBitArray operator&(const QBitArray &, const QBitArray &)
bool IsTouching(const AxisAlignedBoundingBox &cBB) const
Returns true if the two boxes intersect at all.
Definition: math.h:969
float YSize(void) const
Returns the length of the box along the Y axis.
Definition: math.h:948
Represents a color with four components: red, green, blue, alpha.
Definition: math.h:674
float _14
Definition: math.h:1280
The DualQuaternion class is used to represent rigid transformations in most cases.
Definition: math.h:1415
Value of an attribute is changed.
Definition: node.h:151
void SetValue(float f)
Sets the associated float value.
Definition: math.h:1629
AttributeInstance< Color > acolor
Definition: math.h:806
Vector & RotateOrthogonal(const Vector &vBase)
Rotates this vector to be orthogonal to vBase without changing its length, and returns it...
Definition: math.h:103
float y
Definition: math.h:340
double x
Definition: math.h:568
virtual void SetFromString(const QString &sValue, bool bInternal=true, bool=false)
Sets the value of the attribute as a string.
Definition: math.h:605
float b
Definition: math.h:783
float m_fX
Definition: math.h:339
Vector Transform(const Vector &v, float fW, float &fRW) const
Transforms a point (represented by a Vector) by the matrix, and returns all four homogeneous coordina...
Definition: math.h:1252
qreal blueF() const
bool IsComplementary() const
the return value is true when the second range is [0, m_aMax[0] - m_aValue[0]].
Definition: math.h:1722
Vector(float fX, float fY, float fZ=0.0f)
Constructs the vector with specified values.
Definition: math.h:42
DualQuaternion(const Quaternion &vReal, const Quaternion &vDual)
Constructs a dual quaternion from two quaternions, using one as the real and the other one as the dua...
Definition: math.h:1422
MBDLL_DECL AttributeWidget * CreateNewVectorWidget(QWidget *pParent, int iWidth, avector *pAttribute)
float _41
Definition: math.h:1283
static Color black
Definition: math.h:793
A container class that holds a boolean and a float value.
Definition: math.h:1622
AttributeCheckableFloatArray(Node *pOwner=0, const QString &sID="")
Definition: math.h:1751
DblVector(double fX, double fY, double fZ=0.0)
Constructs the vector with specified values.
Definition: math.h:360
unsigned int Size() const
Definition: math.h:1718
MBDLL_DECL Vector operator*(const Matrix &m, const Vector &v)
Definition: math.h:1609
void Extend(const Vector &cV)
Extends the box to contain the passed point.
Definition: math.h:901
GLfloat GLfloat v1
Definition: GLee.h:1735
Matrix(void)
Construct a matrix without initializing its elements. The values stored in the matrix are undefined...
Definition: math.h:1127
This base class represents any shape in 3d space.
Definition: math.h:1584
__m128 m_vAlignDummy
Definition: math.h:788
void AddElement(unsigned int i, QString sLabel, float fMin, float fMax, float fValue)
Definition: math.h:1708
float _22
Definition: math.h:1281
Vector TransformDirection(const Vector &v) const
Transform a direction vector by the matrix.
Definition: math.h:1269
DblVector(void)
Constructs the vector with zero values.
Definition: math.h:352
GLubyte g
Definition: GLee.h:5404
This class represents a 4x4 transformation matrix.
Definition: math.h:1122
float & operator[](unsigned int iChannel)
Returns a color component based on its index.
Definition: math.h:704
double z
Definition: math.h:568
double m_fZ
Definition: math.h:567
Vector & Set(float fX, float fY, float fZ)
Sets the values of the vector elements and returns the vector.
Definition: math.h:61
This is a generic attribute which can be used instead of the standard built in types.
Definition: node.h:394
static Color transparent
Definition: math.h:799
float g
Definition: math.h:783
GLenum GLint x
Definition: GLee.h:876
float operator()(int iRow, int iColumn) const
Returns the value of a specific element in the matrix.
Definition: math.h:1155
AttributeInstance< Vector > avector
Definition: math.h:588
A four dimensionsional vector (X, Y, Z, and W)
Definition: math.h:617
bool IsContaining(const AxisAlignedBoundingBox &b) const
Returns true if the box contains the specified box.
Definition: math.h:1002
const QByteArray operator+(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:564
GLfloat v0
Definition: GLee.h:1734
float LengthSquare(void) const
Returns the square of the length of the vector.
Definition: math.h:108
Attribute::AttributeType Type(void) const
Returns the type of the attribute.
Definition: math.h:1667
Quaternion(float fW, float fX, float fY, float fZ)
Constructs a quaternion by passing all the four components as a scalar.
Definition: math.h:1314
DblVector(const DblVector &vVector)
Copy constructor.
Definition: math.h:364
float Size(void) const
Returns the maximum edge length of the box.
Definition: math.h:942
Vector & Clear(void)
Zeros all the components of the Vector, then returns it.
Definition: math.h:65
AttributeInstance< Vector4 > avector4
Definition: math.h:643
double LengthSquare(void) const
Returns the square of the length of the DblVector.
Definition: math.h:415
Matrix(float f11, float f12, float f13, float f14, float f21, float f22, float f23, float f24, float f31, float f32, float f33, float f34, float f41, float f42, float f43, float f44)
Construct the matrix by passing all the 16 values.
Definition: math.h:1136
Represents a line segment in 3d space.
Definition: math.h:1535
bool operator!=(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:533
const GLdouble * v
Definition: GLee.h:1174
CheckableFloat(bool bState, float fValue)
Definition: math.h:1626
Vector & Normalize(void)
Normalizes the vector and returns it.
AttributeInstance< Matrix > amatrix
This attribute class represents a 4x4 transformation matrix.
Definition: math.h:1292
void Serialize(Stream &s)
Definition: math.h:1644
DblVector & Clear(void)
Zeros all the components of the Vector, then returns it.
Definition: math.h:387
double m_fY
Definition: math.h:567
GLubyte GLubyte b
Definition: GLee.h:5404
Matrix(const Matrix &m)
Definition: math.h:1129
virtual void SetState(bool bState, bool bInternal=false)
Definition: math.h:1676
Vector Center(void) const
Returns the center of the box.
Definition: math.h:957
float Luminance() const
Returns the luminance value for the color.
Definition: math.h:766
float _23
Definition: math.h:1281
void SetValue(unsigned int i, float v)
Definition: math.h:1706
Vector Transform(const Vector &v, float fW=1.0f) const
Transforms a vector by the matrix and returns the result.
Definition: math.h:1219
__m128 m_VecSSE
Definition: math.h:636
bool IsContaining(const Vector &cV) const
Returns true if the box contains the specified point.
Definition: math.h:992
float _32
Definition: math.h:1282
MBDLL_DECL Vector operator*(float f, const Vector &v)
Multiplies a float scalar value by a vector, the result is a vector.
Definition: math.h:575
const GLubyte * c
Definition: GLee.h:5419
AxisAlignedBoundingBox(const AxisAlignedBoundingBox &cA)
Creates an object by cloning another one.
Definition: math.h:859
AxisAlignedBoundingBox(const Vector &vStart, const Vector &vEnd)
Creates an object by specifying two corners of the box.
Definition: math.h:845
Class: ConvolutionKernel.
Definition: array.h:15
Vector(const char *pVector)
Construct the vector from a pointer to 8bit signed data.
Definition: math.h:52
float _11
Definition: math.h:1280
Vector c
Definition: math.h:1102
QString section(QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
Definition: qstring.h:781
GLubyte GLubyte GLubyte a
Definition: GLee.h:5404
static Color white
Definition: math.h:794
float Value(unsigned int i) const
Definition: math.h:1705
AttributeType
Type of the attribute.
Definition: node.h:184
float DistanceSquareFrom(const Vector &v) const
Returns the square of the distance between two points (this and another, represented as Vector object...
Definition: math.h:122
Vector, 3xfloat, see Vector.
Definition: node.h:201
DblVector Minimum(const DblVector &o)
Returns the minimum of this and the argument vector.
Definition: math.h:442
float XSize(void) const
Returns the length of the box along the X axis.
Definition: math.h:945
IntersectionResult
Possible return values of computing intersection of 2 lines.
Definition: math.h:1556
const QPoint operator-(const QPoint &p1, const QPoint &p2)
Definition: qpoint.h:170
float _13
Definition: math.h:1280
bool IsEmpty(void) const
Returns true if the box is empy.
Definition: math.h:1024
DblVector & Set(double fX, double fY, double fZ)
Sets the values of the vector elements and returns the vector.
Definition: math.h:383
This class will be removed from the SDK.
Definition: math.h:1108
bool IsPartOf(const AxisAlignedBoundingBox &cBB) const
Returns true if the passed-in box contains this box.
Definition: math.h:960
Streams are used to read information from a file, or to write it to a file.
Definition: stream.h:39
#define DECLARE_CLASS
This macro should be used in declaration of classes which are inherited from the Node class (or any d...
Definition: node.h:91
AttributeCheckableFloat(Node *pOwner=0, const QString &sID="", const QString &sValueName="")
Definition: math.h:1662
bool State(void) const
Retrieves the associated boolean value.
Definition: math.h:1703
void SetIdentity(void)
Sets the quaternion to represents the identical transformation.
Definition: math.h:1390
MBDLL_DECL AttributeWidget * CreateNewCheckableFloatWidget(QWidget *pParent, int iWidth, AttributeCheckableFloat *pAttribute)
Q_CORE_EXPORT QBitArray operator|(const QBitArray &, const QBitArray &)
void Extend(const AxisAlignedBoundingBox &bb)
Extends the box to contain another one.
Definition: math.h:916
void ExpandBy(float f)
Expands the AABB by a specified amount in all directions.
Definition: math.h:926
void SetIdentity(void)
Sets the dual quaternion to represents the identical transformaion.
Definition: math.h:1513
float _42
Definition: math.h:1283
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
float a
Definition: math.h:783
float _43
Definition: math.h:1283
MBDLL_DECL AttributeWidget * CreateNewCheckableFloatArrayWidget(QWidget *pParent, int iWidth, class AttributeCheckableFloatArray *pAttribute)
Vector(const short *pVector)
Construct the vector from a pointer to 16bit signed data.
Definition: math.h:57
QString AsString(bool) const
Returns the value of the attribute as a string.
Definition: math.h:1669
GLdouble s
Definition: GLee.h:1173
static Color blue
Definition: math.h:797
void Normalize(void)
Normalize all the three axes.
Definition: math.h:1073
GLfloat GLfloat GLfloat GLfloat v3
Definition: GLee.h:1737
type Max(type a, type b)
Definition: mudbox.h:186
Vector(const Vector &vVector)
Copy constructor.
Definition: math.h:46
float x
Definition: math.h:340
float r
Definition: math.h:783
Vector(void)
Constructs the vector with zero values.
Definition: math.h:39
static bool FloatEqual(float A, float B, const int max_ulps=4)
compares floats for equality with a tolerance expressed in Units of Least Precision.
Definition: math.h:1773
GLclampf f
Definition: GLee.h:9303
#define MBDLL_DECL
Definition: dllinterface.h:35
Represents a 3D vector or point with S56E11 floating point elements.
Definition: math.h:348
float toFloat(bool *ok=0) const
MBDLL_DECL AttributeWidget * CreateNewColorWidget(QWidget *pParent, int iWidth, acolor *pAttribute)
DECLARE_CLASS
Definition: node.h:966
Attribute::AttributeType Type(void) const
Returns the type of the attribute.
Definition: math.h:1757
AttributeWidget * CreateEditorWidget(QWidget *pParent, int iWidth)
This function creates and returns the address of a QWidget object.
Definition: node.h:449
float ZSize(void) const
Returns the length of the box along the Y axis.
Definition: math.h:951
DblVector(const Vector &vVector)
constructor from single precision vector.
Definition: math.h:368
AxisAlignedBoundingBox(const Vector &vCenter, float fSize)
Creates an object by specifying the center of it and the distance of the sides from the center...
Definition: math.h:851
Color(float fRed=1.0f, float fGreen=1.0f, float fBlue=1.0f, float fAlpha=1.0f)
Constructs a color object with specified values.
Definition: math.h:681
float _33
Definition: math.h:1282
float _44
Definition: math.h:1283
Vector Vec() const
Definition: math.h:355
bool State(void) const
Retrieves the associated boolean value.
Definition: math.h:1638
Vector b
Definition: math.h:1102