Mudbox/mesh.h Source File

mesh.h
Go to the documentation of this file.
1 
2 //**************************************************************************/
3 // Copyright (c) 2008 Autodesk, Inc.
4 // All rights reserved.
5 //
6 // Use of this software is subject to the terms of the Autodesk license
7 // agreement provided at the time of installation or download, or which
8 // otherwise accompanies this software in either electronic or hard copy form.
9 //
10 //**************************************************************************/
11 // DESCRIPTION:
12 // CREATED: October 2008
13 //**************************************************************************/
14 
15 
16 #if defined(_MSC_VER)
17 #ifndef __attribute__
18 #define __attribute__(_a)
19 #endif
20 #endif
21 
22 namespace mudbox {
23 
24 class SpatialGrid;
25 
26 #ifndef MB_NORMALPRECISION
27 #define MB_NORMALPRECISION 16
28 #endif
29 
30 #ifndef MB_NORMALMAX
31 #if MB_NORMALPRECISION == 16
32 //typedef short int tnormal;
33 //typedef qint64 tnormalv;
34 #define MB_NORMALMAX 32767
35 #else
36 #if MB_NORMALPRECISION == 8
37 //typedef char tnormal;
38 //typedef int tnormalv;
39 #define MB_NORMALMAX 127
40 #else
41 #error MB_NORMALPRECISION must be either 8 or 16
42 #endif
43 #endif
44 #endif
45 
46 #ifndef INVALID_ID
47 #define INVALID_ID (0xffffffff)
48 #endif
49 
51 
57 {
58  inline Vertex( void ) { m_iStrokeID = 0; m_iStates = 0; };
59 
60  // data
61  Vector m_vPos;
62  mutable unsigned int m_iStrokeID;
63  //union
64  //{
65  // tnormal m_vNormal[4];
66  // tnormalv m_iNormal;
67  //};
68  unsigned short m_iStates;
69 
76  inline float Freeze( void ) const
77  { return ((float)(unsigned char)(m_iStates&0x7f)) * (1.0f/0x7f); };
78 
85  inline void SetFreeze( float fFreeze )
86  { m_iStates = (m_iStates&0xff80)+(unsigned int)(0x7f*fFreeze); };
87 
90  inline float Mask( void ) const
91  { return ((float)(unsigned char)(m_iStates>>8)) * (1.0f/0xff); };
92 
95  inline void SetMask( float fMask )
96  { m_iStates = (m_iStates&0xff)+(((unsigned int)(0xff*fMask))<<8); };
97 
99  inline bool IsSelected( void ) const { return (m_iStates&0x80) != 0; };
100 
102  inline void SetSelected( bool bSelected )
103  { m_iStates = (m_iStates&0xff7f)+bSelected*0x80; };
104 };
105 
111 {
113  unsigned int GetSides( void ) { return m_aIndices.ItemCount(); };
115  unsigned int Adjacency( unsigned int i) { return m_aAdjacents[i]; };
117  unsigned int TCI( unsigned int i ) { return m_aTCIs[i]; };
119  void Serialize( Stream &s )
120  {
121  m_aIndices.Serialize( s );
122  m_aAdjacents.Serialize( s );
123  m_aTCIs.Serialize( s );
124  };
126  const GenericFace & operator=(const GenericFace &rhs)
127  {
130  rhs.m_aTCIs.Copy(m_aTCIs);
131  return *this;
132  }
133 
137 };
138 
140 
148 {
149  TC( void ) {m_fU = m_fV = 0.0f;};
150  TC( float fU, float fV ) { m_fU = fU; m_fV = fV; };
151  inline bool operator ==( const TC &a ) const { return m_fU == a.m_fU && m_fV == a.m_fV; };
152  inline bool operator !=( const TC &a ) const { return !operator==( a ); };
153  inline TC operator +( const TC &a ) const { return TC( m_fU + a.m_fU, m_fV + a.m_fV ); };
154  inline TC operator -( const TC &a ) const { return TC( m_fU - a.m_fU, m_fV - a.m_fV ); };
155  inline TC operator *( float f ) const { return TC( m_fU * f, m_fV * f ); };
156  inline TC operator /( float f ) const { f = 1.0f/f; return TC( m_fU * f, m_fV * f ); };
157  inline TC &operator +=( const TC &a ) { m_fU += a.m_fU, m_fV += a.m_fV; return *this; };
158  inline TC &operator -=( const TC &a ) { m_fU -= a.m_fU, m_fV -= a.m_fV; return *this; };
159  inline TC &operator *=( float f ) { m_fU *= f, m_fV *= f; return *this; };
160  inline TC &operator /=( float f ) { f = 1.0f/f; m_fU *= f, m_fV *= f; return *this; };
161  inline operator bool( void ) const throw() { return m_fU || m_fV; };
162  inline operator Vector( void ) const throw() { return Vector( m_fU, m_fV, 0 ); };
163  inline operator const float *( void ) const { return &u; };
164  void Normalize( void );
165  float Length( void );
166  union
167  {
168  float m_fU;
169  float u;
170  };
171  union
172  {
173  float m_fV;
174  float v;
175  };
176 };
177 
184 {
185 public:
186 
188  inline VertexAdjacency() : m_iFaceIndex(INVALID_ID), m_iCornerIndex(0xff) {};
189 
191  inline VertexAdjacency( unsigned int iFaceIndex, unsigned char iCornerIndex ) :
192  m_iFaceIndex(iFaceIndex), m_iCornerIndex(iCornerIndex) {};
193 
197  inline bool IsValid() const { return m_iCornerIndex < 0xff; }
198 
201  inline unsigned int FaceIndex() const { return m_iFaceIndex; }
202 
205  inline unsigned char CornerIndex() const { return m_iCornerIndex; }
206 
207 private:
208  unsigned int m_iFaceIndex;
209  unsigned char m_iCornerIndex;
210 };
211 
226 {
227 public:
229  virtual void Operator(
230  class Mesh *pMesh,
231  unsigned int iFaceIndex
232  );
233 
236  virtual bool Tester(
237  class Mesh *pMesh,
238  unsigned int iFaceIndex
239  );
240 };
241 
242 
244 
256 
258 {
259 public:
260  virtual void Operator(
261  class Mesh *pMesh,
262  unsigned int iVertexIndex,
263  unsigned int iFaceIndex
264  );
266 
267  virtual bool Tester(
268  class Mesh *pMesh,
269  unsigned int iVertexIndex,
270  unsigned int iFaceIndex
271  );
273 };
274 
275 
287 {
288 public:
289  virtual void ProcessAdjacentVertex(
290  unsigned int iVertexIndex,
291  unsigned int iFaceIndex
292  );
294 
295  bool m_bEdge;
296 
298  unsigned char m_iCurrentCorner;
299  unsigned char m_iVertexCorner;
300 
302 
305  virtual ~AdjacentVertexEnumerator();
306 };
307 
312 {
316  unsigned int m_iID;
318  union
319  {
322  };
324  float m_fData;
326  unsigned int m_iVertexIndex;
328  unsigned int m_iFaceIndex;
330  unsigned int m_iLayerVertexIndex;
331 };
332 
333 
335 
341 {
342  class Mesh *m_pMesh;
343  unsigned int m_iFaceIndex;
347  bool m_bSide;
349 
351  SurfacePoint( void ) : m_pMesh(0), m_iFaceIndex(0xffffffff), m_fRelativeRange(0), m_bSide(false), m_pTG( NULL ) {}
352 
354  SurfacePoint(
355  class Mesh *pMesh,
356  unsigned int iVertexIndex,
357  unsigned int iFaceIndex
358  );
359 
361  class Mesh *Mesh( void ) const;
362 
364  unsigned int FaceIndex( void ) const;
365 
367  Vector LocalPosition( void ) const;
368 
370  Vector WorldPosition( void ) const;
371 
373  Vector LocalNormal( void ) const;
374 
376  Vector WorldNormal( void ) const;
377 
379  TC TextureCoordinate( void ) const;
380 
382  Base TangentBase( void ) const;
383 
385  Vector FaceCoordinates( void ) const;
386 
393  bool Fill(
394  class Mesh *pMesh,
395  unsigned int iFaceIndex,
396  const Vector &vStart,
397  const Vector &vEnd,
398  bool bTwoSide = false,
399  bool bOriginalPosition = false
400  );
401 
406  void Fill(
407  class Mesh *pMesh,
408  unsigned int iFaceIndex,
409  float fFaceU,
410  float fFaceV
411  );
412 
417  void Fill(
418  class Mesh *pMesh,
419  unsigned int iFaceIndex,
420  const Vector &vLocalPosition,
421  bool bRecalculatePosition
422  );
423 
429  void SetTangentGenerator(
430  TangentGenerator *pGenerator
431  );
432 
435  void Align( void );
436 
438  void Mirror( void );
439 
441  void Serialize( Stream& s );
442 
444 };
445 
452 class MBDLL_DECL Mesh : public Topology
453 {
455 
456 protected:
464  Mesh(
465  FaceType eFaceType = typeQuadric
466  );
468 
469 public:
471  virtual class Geometry *Geometry( void ) const;
472 
475  virtual class MeshRenderer *Renderer(
476  float fLODLevel = 1.0f
477  );
478 
480  virtual void CopyTo( Node *pNode ) const;
481 
483  virtual class Material *Material( void ) const;
484 
487  virtual class Material *MaterialOverride( void ) const;
488 
490  inline unsigned int VertexCount( void ) const { return m_iVertexCount; };
491 
493  void SetVertexCount(
494  unsigned int iVertexCount
495  );
496 
498  inline unsigned int TCCount( void ) const { return m_pTCs.ItemCount(); };
499 
501  virtual void SetTCCount(
502  unsigned int iTCCount
503  );
504 
506  bool HasTC( bool bIgnorePtexUV = false ) const;
507 
509  virtual unsigned int UVlessPaintingStatus( void ) const;
510 
512  virtual void SetUVlessPaintingStatus(
513  unsigned int iStatus
514  );
516 
521  inline const Vertex *VertexArray( void ) const { return &m_pVertices[0]; };
522 
524  inline const Vertex &VertexData(
525  unsigned int iVertexIndex
526  ) const { return m_pVertices[iVertexIndex]; };
527 
530  unsigned int iVertexIndex
531  ) { return m_pVertices[iVertexIndex]; };
532 
534  inline const Vector &VertexPosition(
535  unsigned int iVertexIndex
536  ) const { return m_pVertices[iVertexIndex].m_vPos; };
537 
540  unsigned int iVertexIndex
541  ) { return m_pVertices[iVertexIndex].m_vPos; };
542 
547  unsigned int iVertexIndex
548  ) const { return m_pVertices[iVertexIndex].m_vPos; };
549 
551  inline const TC &VertexTC(
552  unsigned int iVertexTCIndex
553  ) const { return m_pTCs[iVertexTCIndex]; };
554 
557  unsigned int iVertexIndex
558  ) const { return Vector( m_pVertexNormals[iVertexIndex].m_vNormal ); };
559 
561  inline unsigned int VertexStrokeID( unsigned int iVertexIndex ) const
562  { return m_pVertices[iVertexIndex].m_iStrokeID; };
563 
574  inline float VertexMask(
575  unsigned int iVertexIndex
576  ) const { return m_pVertices[iVertexIndex].Mask(); };
577 
585  inline float VertexFreeze(
586  unsigned int iVertexIndex
587  ) const { return m_pVertices[iVertexIndex].Freeze(); };
588 
591  virtual unsigned int FrozenVertexCount( void ) const;
592 
595  inline const tnormal *VertexNormalArray(
596  unsigned int iVertexIndex
597  ) const { return m_pVertexNormals[iVertexIndex].m_vNormal; };
598 
602  unsigned int iVertexIndex
603  ) const { return m_pVertexNormals[iVertexIndex].m_iNormal; };
604 
605  inline const Normal *VertexNormalArray( void ) const { return &m_pVertexNormals[0]; };
606 
607  inline unsigned int VertexNormalCount( void ) const { return m_pVertexNormals.ItemCount(); }
608 
610  virtual AxisAlignedBoundingBox BoundingBox( bool bRecalculate = false ) const;
611 
612  virtual void SetBoundingBox( const AxisAlignedBoundingBox& cBox );
613 
615  virtual AxisAlignedBoundingBox StrokeBoundingBox() const;
616 
617  virtual void SetStrokeBoundingBox( const AxisAlignedBoundingBox& cBox );
618 
620  virtual AxisAlignedBoundingBox TCBoundingBox( void ) const;
621 
623  inline void SetVertexPosition(
624  unsigned int iVertexIndex,
625  const Vector &vPosition
626  ) { m_pVertices[iVertexIndex].m_vPos = vPosition; };
627 
629  inline void AddVertexPosition(
630  unsigned int iVertexIndex,
631  const Vector &vPosition
632  )
633  { m_pVertices[iVertexIndex].m_vPos += vPosition; };
634 
636  inline void SetVertexNormal( unsigned int iVertexIndex, int *pNormal)
637  {
638  m_pVertexNormals[iVertexIndex].m_vNormal[0] = tnormal(pNormal[3]);
639  m_pVertexNormals[iVertexIndex].m_vNormal[1] = tnormal(pNormal[2]);
640  m_pVertexNormals[iVertexIndex].m_vNormal[2] = tnormal(pNormal[1]);
641  };
642 
644  inline void SetVertexNormal(
645  unsigned int iVertexIndex,
646  const Vector &vNormal
647  )
648  {
649  m_pVertexNormals[iVertexIndex].m_vNormal[0] = tnormal(vNormal.x * MB_NORMALMAX);
650  m_pVertexNormals[iVertexIndex].m_vNormal[1] = tnormal(vNormal.y * MB_NORMALMAX);
651  m_pVertexNormals[iVertexIndex].m_vNormal[2] = tnormal(vNormal.z * MB_NORMALMAX);
652  };
653 
654  // Adds vNormal to the current normal of the vertex with the given index.
655  //void AddVertexNormal(
656  // unsigned int iVertexIndex, ///< [in] index of the vertex
657  // const Vector &vNormal ///< [in] x,y,z offset to be added to the normal
658  // );
659 
661  inline void SetVertexTC(
662  unsigned int iTCIndex,
663  const TC &tc
664  ) { m_pTCs[iTCIndex] = tc; }
665 
667  virtual void SetVertexFreeze(
668  unsigned int iVertexIndex,
669  unsigned int iFaceIndex,
670  float fFreeze
671  );
673 
675  virtual void SetFreezeValues(
676  Store<float> &aNewFreeze
677  );
678 
680  void SetVertexMask( unsigned int iVertexIndex, unsigned int iFaceIndex, float fFMask );
681 
683  inline void SetVertexStrokeID( unsigned int iVertexIndex, unsigned int iStrokeID ) const
684  { m_pVertices[iVertexIndex].m_iStrokeID = iStrokeID; };
685 
689  inline unsigned int &GetVertexID( unsigned int iIndex )
690  {
691  Vertex &v = m_pVertices[iIndex];
692  if ( v.m_iStrokeID < m_iRestoreCount && m_aRestoreBuffer[v.m_iStrokeID].m_iVertexIndex == iIndex )
693  return m_aRestoreBuffer[v.m_iStrokeID].m_iID;
694  return v.m_iStrokeID;
695  };
696 
703  inline void MarkVertex( unsigned int iVertexIndex )
704  {
705  GetVertexID( iVertexIndex ) = CollectionID();
706  };
707 
714  inline bool IsVertexMarked( unsigned int iVertexIndex )
715  {
716  return GetVertexID( iVertexIndex ) == CollectionID();
717  };
718 
719 
727  inline void ClearVertexMarks( void )
728  {
729  IncreaseCollectionID();
730  };
731 
732 
742  virtual unsigned int VertexExternalIndex(
743  unsigned int iVertexIndex
744  ) const;
745 
748  virtual void SetVertexExternalIndex(
749  unsigned int iVertexIndex,
750  unsigned int iExternalVertexIndex
751  );
752 
756  unsigned int iTriangleIndex,
757  unsigned int iCornerIndex
758  ) const { return VertexPosition( TriangleIndex( iTriangleIndex, iCornerIndex ) ); };
759 
761  inline const Vector &QuadVertexPosition(
762  unsigned int iQuadIndex,
763  unsigned int iCornerIndex
764  ) const { return VertexPosition( QuadIndex( iQuadIndex, iCornerIndex ) ); };
765 
769  unsigned int iTriangleIndex,
770  unsigned int iCornerIndex
771  ) const { return VertexTC( TriangleTCI( iTriangleIndex, iCornerIndex ) ); };
772 
774  const TC &QuadVertexTC(
775  unsigned int iQuadIndex,
776  unsigned int iCornerIndex
777  ) const { return VertexTC( QuadTCI( iQuadIndex, iCornerIndex ) ); };
778 
781  unsigned int iTriangleIndex,
782  unsigned int iCornerIndex
783  ) const { return VertexNormal( TriangleIndex( iTriangleIndex, iCornerIndex ) ); };
784 
787  unsigned int iQuadIndex,
788  unsigned int iCornerIndex
789  ) const { return VertexNormal( QuadIndex( iQuadIndex, iCornerIndex ) ); };
790 
793  unsigned int iTriangleIndex,
794  unsigned int iCornerIndex
795  ) const { return VertexNormal( TriangleCreaseNormalIndex( iTriangleIndex, iCornerIndex ) ); };
796 
799  unsigned int iQuadIndex,
800  unsigned int iCornerIndex
801  ) const { return VertexNormal( QuadCreaseNormalIndex( iQuadIndex, iCornerIndex ) ); };
802 
804  inline float TriangleVertexFreeze(
805  unsigned int iTriangleIndex,
806  unsigned int iCornerIndex
807  ) const { return VertexFreeze( TriangleIndex( iTriangleIndex, iCornerIndex ) ); };
808 
811  inline float QuadVertexFreeze(
812  unsigned int iQuadIndex,
813  unsigned int iCornerIndex
814  ) const { return VertexFreeze( QuadIndex( iQuadIndex, iCornerIndex ) ); };
815 
818  unsigned int iTriangleIndex,
819  unsigned int iCornerIndex
820  ) const { return VertexNormalArray( TriangleIndex( iTriangleIndex, iCornerIndex ) ); };
821 
824  unsigned int iQuadIndex,
825  unsigned int iCornerIndex
826  ) const { return VertexNormalArray( QuadIndex( iQuadIndex, iCornerIndex ) ); };
827 
830  unsigned int iTriangleIndex,
831  unsigned int iCornerIndex
832  ) const { return VertexNormalValue( TriangleIndex( iTriangleIndex, iCornerIndex ) ); };
833 
836  unsigned int iQuadIndex,
837  unsigned int iCornerIndex
838  ) const { return VertexNormalValue( QuadIndex( iQuadIndex, iCornerIndex ) ); };
839 
851  virtual void EnumerateFaces(
852  unsigned int iFaceIndex,
853  FaceEnumerator *pEnumerator,
854  bool bSymmetry = false
855  );
857 
863  virtual void EnumerateNearestFaces(
864  unsigned int iFaceIndex,
865  FaceEnumerator *pOperation
866  );
867 
873  virtual void EnumerateNeighboringFaces(
874  unsigned int iFaceIndex,
875  FaceEnumerator *pOperation
876  );
877 
879  virtual void EnumerateFaces(
880  FaceEnumerator* pEnumerator,
881  SpatialGrid* pGrid,
882  const AxisAlignedBoundingBox& cVolume
883  );
884 
889  virtual void EnumerateVertices(
890  unsigned int iFaceIndex,
891  VertexEnumerator *pEnumerator
892  );
893 
899  unsigned int EnumerateAdjacentVertices(
900  AdjacentVertexEnumerator *pEnumerator,
901  unsigned int iVertexIndex,
902  unsigned int iFaceIndex
903  );
904 
906  virtual void EnumerateVertices(
907  VertexEnumerator* pEnumerator,
908  SpatialGrid* pGrid,
909  const AxisAlignedBoundingBox& cVolume
910  );
911 
913  virtual int MeshVersion( void ) const;
914 
916  virtual void SmoothTextureCoordinates( float fStrength);
917 
919  virtual void RecalculateNormals(
920  bool bKeep = false
921  );
922 
924  virtual bool RecalculateAdjacency(
925  bool bForce = true,
926  bool bCheckTShapes = true
927  );
928 
929 
931  unsigned int CollectionID( void ) const { return m_iCollectionID; }; // this *must* be inline for performance on large meshes.
932 
933  // Obsolete method; do not use.
934  void SetCollectionID(unsigned int id) { m_iCollectionID = id; }; // this *must* be inline for performance on large meshes.
935 
937  void IncreaseCollectionID( void ) { ++m_iCollectionID; }; // this *must* be inline for performance on large meshes.
938 
939 
941  virtual bool IsSelected( void );
942 
944  virtual void SetSelected( bool bOn = true, bool bMerge = false );
945 
948  virtual class LayerMeshData *AddLayer( Layer * pLayer = NULL );
949 
952  virtual void RemoveLayer(
953  LayerMeshData* pLayer
954  );
955 
957  virtual class LayerMeshData *ActiveLayer( void ) const;
958 
962  aptr<LayerMeshData> ActiveSculptLayer;
963 
965  virtual bool IsActiveLevel( void ) const;
966 
973  virtual bool Lock(
974  class MeshUnlocker *pUnlocker = NULL
975  );
977 
983  virtual bool Unlock( void );
984 
986  virtual bool IsLocked( void );
987 
991  virtual class MeshChange *StartChange( void );
992 
994  virtual void EndChange( bool bUndo = true, bool bMerge = false);
995 
997  virtual bool IsNSided( void ) const;
999  virtual GenericFace &Face( unsigned int iIndex );
1001  virtual unsigned int GenericFaceCount( void );
1002  virtual void ClearGenericFaces();
1003 
1006  virtual bool HasExpandedTCs( void ) const;
1008  virtual void CreateExpandedTCs( void );
1010  virtual TC &ExpandedTC( unsigned int index );
1012  virtual bool SupportsTangentMirror() const;
1014  virtual unsigned int TangentMirroredFaceIndex( unsigned int iFaceIndex ) const;
1016  virtual unsigned int TangentMirroredVertexIndex( unsigned int iFaceIndex,
1017  unsigned int iCornerIndex,
1018  unsigned int &iOppositeFaceIndex,
1019  unsigned int &iOppositeCornerIndex) const;
1020 
1022 
1027 
1030  virtual bool InitializeTopologicalSymmetry( unsigned int iFaceIndex0, unsigned int iFaceIndex1, bool bSelectWhenFailed = true );
1033  virtual bool IsTopologicalSymmetryInitialized( unsigned int &iFaceIndex0, unsigned int &iFaceIndex1 ) const;
1035  virtual void RecalculateTopologicalSymmetry( void );
1037  virtual SurfacePoint MirrorSurfacePoint( const SurfacePoint &cPoint );
1039  virtual int TopologicalSide( unsigned int iFaceIndex );
1040 
1041  virtual unsigned int PrimaryCount(bool bNeedToUseTC);
1045  virtual unsigned int QuadPrimaryIndex(bool bNeedToUseTC, unsigned int iFaceIndex, unsigned int iCornerIndex);
1049  virtual unsigned int TrianglePrimaryIndex(bool bNeedToUseTC, unsigned int iFaceIndex, unsigned int iCornerIndex);
1050 
1052  virtual bool RecalculateVertexAdjacency(
1053  bool bForce = true
1054  );
1055 
1057  inline void SetVertexAdjacency(
1058  unsigned int iVertexIndex,
1059  unsigned int iFaceIndex,
1060  unsigned int iCornerIndex
1061  )
1062  {
1063  m_aVertexAdjacency[iVertexIndex] = mudbox::VertexAdjacency( iFaceIndex, iCornerIndex );
1064  };
1065 
1067  inline struct mudbox::VertexAdjacency VertexAdjacency( unsigned int iVertexIndex ) const { return m_aVertexAdjacency[iVertexIndex]; }
1068 
1069  virtual void Transform( const Matrix &mMatrix );
1070 
1071  virtual void CheckValidity( DiagnosticLevel iLevel = dgnLevel2 ) const;
1072 
1073 protected:
1074  unsigned int m_iVertexCount;
1075  mutable unsigned int m_iCollectionID;
1081 
1082  unsigned int m_iRestoreCount; // referenced and modified by the MeshChange class
1083  Store<StoredVertexInfo> m_aRestoreBuffer; // referenced and modified by the MeshChange class
1084 
1085 public:
1086  unsigned int GetRestoreCount() const { return m_iRestoreCount; }
1087 
1089  const StoredVertexInfo & GetRestoreVertexInfo(unsigned int i) const { return m_aRestoreBuffer[i]; }
1090 
1091  // The following two are only used for creating a MeshChange object. They give
1092  // write access to the restore buffer and count. Do not use them anywhere else.
1093 
1095  unsigned int & GetRestoreCountRef() { return m_iRestoreCount; }
1097  Store<StoredVertexInfo> & GetRestoreBufferRef() { return m_aRestoreBuffer; }
1098 
1099 protected:
1101 
1102 public:
1103  SpatialGrid* Grid();
1104 };
1105 
1106 
1109 {
1110  DECLARE_CLASS;
1111 public:
1112  virtual void Freeze( Mesh *pMesh, Store<float> aFreezeData, bool bMerge = false );
1113 };
1114 
1117 {
1118  DECLARE_CLASS;
1119 public:
1120  virtual void Select( Mesh *pMesh, bool bState, const Store<unsigned int> &aSelectionData, bool bMerge = false );
1121 };
1122 
1150 {
1151  DECLARE_CLASS;
1152 public:
1154  virtual Vector ConvertToTangent(
1155  unsigned int iVertexIndex,
1156  const Vector &vVector
1157  ) const;
1158 
1160  virtual Vector ConvertToObject(
1161  unsigned int iVertexIndex,
1162  const Vector &vVector
1163  ) const;
1164 
1166  virtual Base LocalBase(
1167  unsigned int iFaceIndex,
1168  unsigned int iCornerIndex
1169  );
1170 
1172  virtual void SetNormalization(
1173  bool bNormalize
1174  );
1175 };
1176 
1177 
1194 {
1195  DECLARE_CLASS;
1196 
1197 public:
1198  virtual void SetMesh(
1199  Mesh *m_pMesh
1200  );
1201 
1202  virtual void SetTolerance(
1203  float fTolerance
1204  );
1205 
1206  virtual bool Pick(
1207  const Vector &vLocalStart,
1208  const Vector &vLocalEnd,
1209  bool bBothSides,
1210  SurfacePoint &cResult,
1211  float fTarget = 0.5f
1212  );
1213 };
1214 
1230 {
1231  DECLARE_CLASS;
1232 
1233 public:
1235  virtual void SetFramebufferSize(
1236  unsigned int iWidth,
1237  unsigned int iHeight
1238  );
1239 
1241  virtual bool Pick(
1242  const class Camera *pCamera,
1243  float fXPosition,
1244  float fYPosition,
1245  SurfacePoint &sResult,
1246  bool bForceRedrawBuffer = false
1247  );
1248 };
1249 
1276 {
1277  DECLARE_CLASS;
1278 
1279 public:
1281  virtual unsigned int MeshGridCount( void ) const;
1282 
1285  virtual unsigned int MeshGridLevel(
1286  unsigned int iMeshGridIndex
1287  ) const;
1288 
1291  virtual unsigned int MeshGridFaceIndex(
1292  unsigned int iMeshGridIndex,
1293  unsigned int iX,
1294  unsigned int iY
1295  ) const;
1296 
1298  virtual unsigned int MeshGridVertexIndex(
1299  unsigned int iMeshGridIndex,
1300  unsigned int iX,
1301  unsigned int iY
1302  ) const;
1303 
1305  virtual unsigned int MeshGridTCIndex(
1306  unsigned int iMeshGridIndex,
1307  unsigned int iX,
1308  unsigned int iY
1309  ) const;
1310 
1312  virtual unsigned int MeshGridIndexByFaceIndex(
1313  unsigned int iFaceIndex
1314  ) const;
1315 };
1316 
1323 {
1324  DECLARE_CLASS;
1325 
1326 public:
1328  {
1329  Coord() { a[0] = a[1] = a[2] = 0; }
1330  Coord( unsigned int x, unsigned int y, unsigned int z )
1331  {
1332  a[0] = x; a[1] = y; a[2] = z;
1333  }
1334 
1335  unsigned int& operator[](unsigned int i) { return a[i]; };
1336  unsigned int operator[](unsigned int i) const { return a[i]; };
1337 
1338  bool operator==(const Coord& other)
1339  {
1340  return a[0] == other.a[0] && a[1] == other.a[1] && a[2] == other.a[2];
1341  }
1342 
1343  unsigned int a[3];
1344  };
1345 
1347  {
1348  public:
1349  VoxelIterator( const ExtendableStore<unsigned int>& data ): fData(data), fIndex(0)
1350  {
1351  if( fData.ItemCount() > 0 && fData[fIndex] == INVALID_ID )
1352  next();
1353  }
1354 
1355  void next() { while( ++fIndex < fData.ItemCount() && fData[fIndex] == INVALID_ID ); }
1356  bool isDone() const { return fIndex >= fData.ItemCount(); }
1357  unsigned int value() const { return fData[fIndex]; }
1358 
1359  private:
1360  unsigned int fIndex;
1361  const ExtendableStore<unsigned int>& fData;
1362  };
1363 
1370  static Coord computeDimensions( const mudbox::Mesh* mesh,
1371  unsigned int facesPerVoxel,
1372  const Coord& minVoxels,
1373  const Coord& maxVoxels);
1374 
1377  virtual void initialize( mudbox::Mesh* mesh,
1378  const AxisAlignedBoundingBox& bounds,
1379  const Coord& gridDimensions );
1380 
1382  virtual AxisAlignedBoundingBox gridBounds() const;
1383 
1386  virtual void voxelRange( const AxisAlignedBoundingBox& cBox,
1387  Coord& cMinCoords,
1388  Coord& cMaxCoords
1389  ) const;
1390 
1392  virtual VoxelIterator voxelIterator( const Coord& cCoord );
1393 
1395  virtual void setDirty( const AxisAlignedBoundingBox& cBox );
1396 
1398  virtual void update();
1399 
1401  virtual void extend();
1402 
1404  virtual bool closestPoint( mudbox::SurfacePoint &surfacePt,
1405  mudbox::Mesh *pMesh,
1406  const mudbox::Vector& vPoint,
1407  const mudbox::Vector& vDirection,
1408  bool bothDirections = false );
1409 };
1410 
1430 {
1431  DECLARE_CLASS;
1432 
1433 public:
1435  virtual Vector SmoothPosition(
1436  unsigned int iFaceIndex,
1437  double fUCoordinate,
1438  double fVCoordinate,
1439  bool bConsiderCrease = true,
1440  bool bConsiderHarden = true
1441  ) const;
1442 
1444  virtual Vector SmoothNormal(
1445  unsigned int iFaceIndex,
1446  double fUCoordinate,
1447  double fVCoordinate,
1448  bool bConsiderCrease = true,
1449  bool bConsiderHarden = true
1450  ) const;
1451 
1453  virtual Vector SmoothTextureCoordinate(
1454  unsigned int iFaceIndex,
1455  double fUCoordinate,
1456  double fVCoordinate
1457  ) const;
1458 
1460  virtual Base SmoothTangent(
1461  unsigned int iFaceIndex,
1462  double fUCoordinate,
1463  double fVCoordinate,
1464  bool bConsiderCrease = true,
1465  bool bConsiderHarden = true
1466  ) const;
1467 };
1468 
1476 {
1477  MeshChange( Mesh *m_pMesh );
1478 
1479 public:
1482 
1484  inline float Data(
1485  unsigned int iVertexIndex
1486  ) const
1487  {
1488  Vertex &v = m_pMesh->VertexData( iVertexIndex );
1489  if ( v.m_iStrokeID < m_iVertexCount && m_pArray[v.m_iStrokeID].m_iVertexIndex == iVertexIndex )
1490  return m_pArray[v.m_iStrokeID].m_fData;
1491  else
1492  return 0.0f;
1493  };
1494 
1496  inline const Vector &OriginalPosition(
1497  unsigned int iVertexIndex
1498  ) const
1499  {
1500  Vertex &v = m_pMesh->VertexData( iVertexIndex );
1501  if ( v.m_iStrokeID < m_iVertexCount && m_pArray[v.m_iStrokeID].m_iVertexIndex == iVertexIndex )
1502  return m_pArray[v.m_iStrokeID].m_vPosition;
1503  else
1504  return v.m_vPos;
1505  };
1506 
1509  unsigned int iVertexIndex
1510  ) const __attribute__((always_inline))
1511  {
1512  Vertex &v = m_pMesh->VertexData( iVertexIndex );
1513  if ( v.m_iStrokeID < m_iVertexCount && m_pArray[v.m_iStrokeID].m_iVertexIndex == iVertexIndex )
1514  return m_pArray[v.m_iStrokeID].m_vNormal;
1515  else
1516  //return v.m_vNormal;
1517  return m_pMesh->VertexNormal(iVertexIndex);
1518  };
1519 
1520 
1521  // this function is not being inlined as it is too big, si it is split into a small inlined part,
1522  // and the larger not inlined part...
1523  private:
1524  VertexChange &Add_uncached( // see arg list of Add just below....
1525  unsigned int iVertexIndex,
1526  unsigned int iFaceIndex,
1527  Vertex &v,
1528  bool bPrecalculateLayerIndex = false,
1529  float fDataInitialValue = 0.0f );
1530 
1531  public:
1534  __forceinline VertexChange &Add(
1535  unsigned int iVertexIndex,
1536  unsigned int iFaceIndex,
1537  bool bPrecalculateLayerIndex = false,
1538  float fDataInitialValue = 0.0f
1540  ) __attribute__((always_inline))
1541  {
1542  Vertex &v = m_pMesh->VertexData( iVertexIndex );
1543  if ( v.m_iStrokeID < m_iVertexCount &&
1544  m_pArray[v.m_iStrokeID].m_iVertexIndex == iVertexIndex )
1545  return m_pArray[v.m_iStrokeID]; // 80% of the time it hits this...
1546  else {
1547  return Add_uncached(iVertexIndex, iFaceIndex, v, bPrecalculateLayerIndex, fDataInitialValue );
1548  }
1549  };
1550 
1552  void Finish(
1553  bool bUndo = true,
1554  bool bMerge = false
1556  );
1557 
1558 private:
1559  Mesh *m_pMesh;
1560 
1561  Store<VertexChange> &m_pArray; // these reference the count and RestoreArray in the Mesh class
1562  unsigned int &m_iVertexCount;
1563 
1564  friend class Mesh;
1565  friend class ::XMesh;
1566 };
1567 
1568 //-----------------------------------------------------------------------------
1577 {
1578 public:
1583  virtual bool Unlock(
1584  Mesh *pMesh
1585  );
1586 };
1587 
1588 
1589 
1590 
1591 //-----------------------------------------------------------------------------
1615 
1617 {
1619 
1620 public:
1622  eNone = 0, //<-- mesh has not partitioning computed yet.
1623  eFastest, //<-- order n partitioning -- may not be spatially coherent.
1624  eGood, //<-- no worse than order n log n. Mostly spatially coherent. default
1625  eBest //<-- slower than eGood, but better coherence
1626  };
1627 
1628 private:
1629 
1630  // Partition represents an individual partition in the mesh partitioning.
1631  class Partition
1632  {
1633  friend class MeshPartitioning;
1634  private:
1635  Store<unsigned int> m_aFaceIDs; // list of face ids in this partition
1636  Store<unsigned int> m_aInvalidIDs; // LIFO indexes of invalid IDs within the FaceID list
1637  AxisAlignedBoundingBox m_AABB; // bounding box of this partition - only valid in point mode.
1638  unsigned int m_MinFaceID;
1639  unsigned int m_MaxFaceID;
1640  unsigned int m_BlindInt; // Blind data
1641  bool m_bDirty; // is this partition dirty since last used by the renderer.
1642  unsigned int m_iVersion;
1643 
1644  // Adds a face to this partition. Does not check if it is already in the partition,
1645  // that would create an invalid partitioning, so don't do it.
1646  // returns the index in the partition of the specified face.
1647  // does not update the bounding box.
1648  unsigned int AddFace(unsigned int faceID);
1649 
1650  // Delete the face at the specified index within this partition.
1651  // does not update the bounding box.
1652  void DelFace(unsigned int index)
1653  {
1654  if (index < m_aFaceIDs.ItemCount() && m_aFaceIDs[index] != INVALID_ID) {
1655  m_aFaceIDs[index] = INVALID_ID;
1656  m_aInvalidIDs.Add(index);
1657  m_bDirty = true;
1658  }
1659  }
1660 
1661  // returns true if any changes were made.....
1662  bool Consolidate(bool force);
1663 
1664  public:
1665  Partition() : m_aFaceIDs("Mesh Partition Faces"),
1666  m_aInvalidIDs("Mesh Partition Unused Entries"),
1667  m_MinFaceID(0xFFFFFFFF),
1668  m_MaxFaceID(0),
1669  m_BlindInt(0),
1670  m_iVersion(0),
1671  m_bDirty(false) { m_AABB.Reset(); }
1672 
1673  ~Partition() { Clear(); }
1674 
1675  void Clear()
1676  { m_aFaceIDs.Clear(); m_aInvalidIDs.Clear();
1677  m_MinFaceID = 0xffffffff; m_MaxFaceID = m_BlindInt = 0;
1678  m_bDirty = false; m_AABB.Reset(); m_iVersion = 0; }
1679 
1680  void Serialize( Stream &s )
1681  {
1682  Consolidate(true);
1683  m_aFaceIDs.Serialize(s);
1684  m_aInvalidIDs.Serialize(s);
1685  m_AABB.Serialize(s);
1686  s == m_MinFaceID;
1687  s == m_MaxFaceID;
1688  s == m_BlindInt;
1689  s == m_bDirty;
1690  }
1691 
1692  Partition(const Partition &p) : m_aFaceIDs(p.m_aFaceIDs),
1693  m_aInvalidIDs(p.m_aInvalidIDs),
1694  m_AABB(p.m_AABB),
1695  m_BlindInt(p.m_BlindInt),
1696  m_bDirty(p.m_bDirty) {}
1697 
1698  Partition & operator = (const Partition &p) {
1699  m_aFaceIDs = p.m_aFaceIDs;
1700  m_aInvalidIDs = p.m_aInvalidIDs;
1701  m_AABB = p.m_AABB;
1702  m_MinFaceID = p.m_MinFaceID;
1703  m_MaxFaceID = p.m_MaxFaceID;
1704  m_BlindInt = p.m_BlindInt;
1705  m_bDirty = p.m_bDirty;
1706  return *this;
1707  }
1708 
1709  const AxisAlignedBoundingBox &getBoundingBox() const { return m_AABB; }
1710  };
1711 
1712  class InverseMapping {
1713  public:
1714  unsigned int m_iPartition; // the partition this face belongs to
1715  unsigned int m_iIndex; // and it's index in that partition.
1716 
1717  InverseMapping() : m_iPartition(INVALID_ID), m_iIndex(INVALID_ID) {}
1718  InverseMapping(const InverseMapping &m) : m_iPartition(m.m_iPartition), m_iIndex(m.m_iIndex) {}
1719 
1720  InverseMapping & operator = (const InverseMapping &m)
1721  { m_iPartition = m.m_iPartition; m_iIndex = m.m_iIndex; return *this; }
1722 
1723  void Serialize( Stream &s )
1724  {
1725  s == m_iPartition;
1726  s == m_iIndex;
1727  }
1728  };
1729 
1730  // regenerate the inverse mapping for all partitions
1731  void RegenInverseMapping();
1732 
1733  // regen the inverse mapping for one partition
1734  void RegenInverseMapping(int Part);
1735 
1736  void SetPartitionCount(unsigned int count);
1737 
1738  // merge two partitions, leaving src partition empty.
1739  void MergePartitions(unsigned int src, unsigned int target);
1740 
1741  // splits a partition into 2 roughly equal (in face count) partitions
1742  void SplitPartition(unsigned int part);
1743 
1744  // tries to even out the size (face count) of the partitions somewhat
1745  void RebalancePartitions(QualityHint hint);
1746 
1747 
1748  Store<Partition> m_aPartitions; // indexed by partition ID
1749  Store<InverseMapping> m_aFaces; // indexed by faceID.
1750  AxisAlignedBoundingBox m_TotalAABB; // bounding box of this partitioning.
1751 
1752  QualityHint m_eCurrentPartitionQuality; // quality of this partitioning
1753  bool m_UseFaces;
1754 
1755  static QualityHint m_sDefaultQuality; // used when linked to its parent node
1756  static unsigned int m_sPreferredPartitionCount; // used when computing a partitioning. Default is 2048.
1757  static unsigned int m_sMaxPartitionSize; // Partitions will not exceed this size. Default 64K - 1.
1758  static bool m_sBaseMesh; // go to the base level before partitioning. Default is true.
1759  static bool m_sUseFaces; // Use the face centers, or partition vertices...
1760 
1761 public:
1762 
1765  static void SetBaseMeshMode(bool b = true) { m_sBaseMesh = b; }
1766  static bool IsInBaseMeshMode() { return m_sBaseMesh; }
1767 
1768 
1774  static void SetFaceMode(bool b = true) { m_sUseFaces = b; }
1775  static bool IsInFaceMode() { return m_sUseFaces; }
1776 
1777  bool IsCurrentPartitioningFaceBased() const { return m_UseFaces; }
1778 
1781  static void SetDefaultQuality(QualityHint hint) { m_sDefaultQuality = hint; }
1782 
1784  static QualityHint GetDefaultQuality() { return m_sDefaultQuality; }
1785 
1789  static unsigned int GetDefaultPartitionCount() { return m_sPreferredPartitionCount; }
1790 
1794  static void SetDefaultPartitionCount(unsigned int pc) { m_sPreferredPartitionCount = pc; }
1795 
1796 
1798  MeshPartitioning();
1799 
1800  ~MeshPartitioning() { Clear(); }
1801 
1803  void Clear();
1804 
1808  virtual void OnLinked(const TreeNode *pOldParent);
1809 
1813  void RePartition(QualityHint hint = eGood);
1814 
1816  void RecomputePartitionAABB(unsigned int pIdx);
1817 
1819  void RecomputePartitionAABBs(void);
1820 
1825  const AxisAlignedBoundingBox &GetTotalAABB() const { return m_TotalAABB; }
1826 
1829  const AxisAlignedBoundingBox &GetPartitionAABB(unsigned int pIdx) const
1830  { return m_aPartitions[pIdx].m_AABB; }
1831 
1833  unsigned int GetPartitionMinFaceID(unsigned int pIdx) const
1834  { return m_aPartitions[pIdx].m_MinFaceID; }
1835 
1837  unsigned int GetPartitionMaxFaceID(unsigned int pIdx) const
1838  { return m_aPartitions[pIdx].m_MaxFaceID; }
1839 
1844  bool IsPartitionCloseToPoint(unsigned int pIdx, const Vector &pt, float dist) const
1845  {
1846  if (dist > 0) {
1847  AxisAlignedBoundingBox bBox = m_aPartitions[pIdx].m_AABB;
1848  bBox.ExpandBy(dist);
1849  return bBox.IsContaining(pt);
1850  } else {
1851  return m_aPartitions[pIdx].m_AABB.IsContaining(pt);
1852  }
1853  }
1854 
1856  QualityHint GetCurrentPartitioningQuality() const { return m_eCurrentPartitionQuality; }
1857 
1861  void Consolidate(bool force);
1862 
1864  void Serialize( Stream &s );
1865 
1868  bool IsPartitionDirty(unsigned int pIdx) const { return m_aPartitions[pIdx].m_bDirty; }
1869 
1872  void SetPartitionDirty(unsigned int pIdx) { m_aPartitions[pIdx].m_bDirty = true; }
1873 
1876  {
1877  bool b = false;
1878  for (unsigned int i = 0; i < m_aPartitions.ItemCount(); ++i)
1879  b |= m_aPartitions[i].m_bDirty;
1880  return b;
1881  }
1882 
1885  void ContentChanged( void )
1886  {
1887  for (unsigned int i = 0; i < m_aPartitions.ItemCount(); ++i)
1888  if( m_aPartitions[i].m_bDirty )
1889  {
1890  m_aPartitions[i].m_bDirty = false;
1891  m_aPartitions[i].m_iVersion++;
1892  }
1893 
1895  }
1896 
1899  void SetFaceCount(unsigned int faceCount, bool noOvergrowth = false);
1900 
1903  unsigned int GetFaceCount() const { return m_aFaces.ItemCount(); }
1904 
1906  unsigned int GetPartitionCount() const { return m_aPartitions.ItemCount(); }
1907 
1911  unsigned int GetPartitionFaceCount(unsigned int pIdx) const
1912  { return m_aPartitions[pIdx].m_aFaceIDs.ItemCount(); }
1913 
1917  unsigned int GetPartitionFace(unsigned int pIdx, unsigned int fIdx) const
1918  { return m_aPartitions[pIdx].m_aFaceIDs[fIdx]; }
1919 
1921  unsigned int GetPartitionBlindInt(unsigned int pIdx) const
1922  { return m_aPartitions[pIdx].m_BlindInt; }
1923 
1925  void SetPartitionBlindInt(unsigned int pIdx, unsigned int ii)
1926  { m_aPartitions[pIdx].m_BlindInt = ii; }
1927 
1930  unsigned int GetPartitionVersion( unsigned int pIdx ) const
1931  { return m_aPartitions[pIdx].m_iVersion; }
1932 
1934  unsigned int GetFacePartition(unsigned int faceID) const
1935  { return faceID < m_aFaces.ItemCount() ? m_aFaces[faceID].m_iPartition : INVALID_ID; }
1936 
1939  unsigned int GetFacePartitionIndex(unsigned int faceID) const
1940  { return faceID < m_aFaces.ItemCount() ? m_aFaces[faceID].m_iIndex : INVALID_ID; }
1941 
1948  void AddFaceToPartition(unsigned int faceID, unsigned int partitionID);
1949 
1951  unsigned int GetPartitionID(unsigned int faceID) const
1952  { return (faceID < GetFaceCount()) ? m_aFaces[faceID].m_iPartition : INVALID_ID; }
1953 
1954  void DebugLog();
1955 
1956  void SetBlindIntsAsColors();
1957 
1958  virtual void CheckValidity( Node::DiagnosticLevel iLevel = dgnLevel2 ) const;
1959 };
1960 
1961 
1962 }; // end of namespace mudbox
1963 
1964 
void MarkVertex(unsigned int iVertexIndex)
Mark a particular vertex.
Definition: mesh.h:703
VoxelIterator(const ExtendableStore< unsigned int > &data)
Definition: mesh.h:1349
float z
Definition: math.h:340
void SetCollectionID(unsigned int id)
Definition: mesh.h:934
float QuadVertexFreeze(unsigned int iQuadIndex, unsigned int iCornerIndex) const
Returns the freeze value of a corner of a mesh face.
Definition: mesh.h:811
tnormalv m_iNormal
Definition: mesh.h:320
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
Definition: GLee.h:10762
const QPoint operator/(const QPoint &p, qreal c)
Definition: qpoint.h:201
GLenum GLint GLint y
Definition: GLee.h:876
Store< mudbox::VertexAdjacency > m_aVertexAdjacency
Definition: mesh.h:1078
The MeshGrid class is an interface for dividing the surface of a mesh to grids.
Definition: mesh.h:1275
void SetVertexAdjacency(unsigned int iVertexIndex, unsigned int iFaceIndex, unsigned int iCornerIndex)
Sets the adjacency data for a specified vertex. If this vertex is not touching any faces...
Definition: mesh.h:1057
Generic base interface for classes implementing a freeze function.
Definition: mesh.h:1108
Store< Normal > m_pVertexNormals
Definition: mesh.h:1077
void SetVertexNormal(unsigned int iVertexIndex, const Vector &vNormal)
Sets the normal of the vertex with the given index.
Definition: mesh.h:644
static void SetDefaultQuality(QualityHint hint)
Set the default quality hint.
Definition: mesh.h:1781
Vector QuadVertexNormal(unsigned int iQuadIndex, unsigned int iCornerIndex) const
Returns the normal of a corner of a mesh face. Can be used for quad meshes only.
Definition: mesh.h:786
aevent TopologyChange
This event is triggered when the mesh's topology has been editer.
Definition: mesh.h:1026
bool m_bHasVertexAdjacency
Definition: mesh.h:1079
unsigned int VertexNormalCount(void) const
Definition: mesh.h:607
unsigned int value() const
Definition: mesh.h:1357
Represents a 3D vector or point with S23E8 floating point elements.
Definition: math.h:35
unsigned char m_iCurrentCorner
This is set to true if the original vertex passed in to Mesh::EnumerateAdjacentVertices() is on the e...
Definition: mesh.h:298
unsigned int GetPartitionCount() const
Returns the number of partitions. Partition ids are 0 through PartitionCount-1 inclusive.
Definition: mesh.h:1906
float v
Definition: mesh.h:174
A Mesh is a collection of vertices organized into faces, and optional Texture Coordinate information...
Definition: mesh.h:452
const GLfloat * tc
Definition: GLee.h:5439
const Normal * VertexNormalArray(void) const
Definition: mesh.h:605
GLdouble GLdouble z
Definition: GLee.h:1393
Vertex & VertexData(unsigned int iVertexIndex)
Returns a vertex.
Definition: mesh.h:529
tnormalv VertexNormalValue(unsigned int iVertexIndex) const
Returns the normal of the vertex with the given index as a single 64-bit signed value.
Definition: mesh.h:601
void Serialize(Stream &s)
Writes/reads the object data to/from a stream.
Vector TriangleVertexCreaseNormal(unsigned int iTriangleIndex, unsigned int iCornerIndex) const
Returns the normal of a corner of a mesh face. Can be used for triangular meshes only.
Definition: mesh.h:792
bool m_bSide
if true, the backside of the face was selected. (This is not supported; use at your own risk...
Definition: mesh.h:347
unsigned int & GetVertexID(unsigned int iIndex)
Not part of the Mesh API – used internally.
Definition: mesh.h:689
QByteArray & operator+=(QByteArray &a, const QStringBuilder< A, B > &b)
Store< TC > m_pTCs
Definition: mesh.h:1021
Contains generic polygon representation.
Definition: mesh.h:110
const GenericFace & operator=(const GenericFace &rhs)
Copies the face values into another instance.
Definition: mesh.h:126
void SetVertexPosition(unsigned int iVertexIndex, const Vector &vPosition)
Sets the position of the vertex with the given index.
Definition: mesh.h:623
Represents face adjacency data for a vertex.
Definition: mesh.h:183
unsigned int operator[](unsigned int i) const
Definition: mesh.h:1336
bool IsPartitionCloseToPoint(unsigned int pIdx, const Vector &pt, float dist) const
returns true if a specified point is within a given (non empty) partition, or within a specified dist...
Definition: mesh.h:1844
Vector m_vLocalPosition
position of the point in local space
Definition: mesh.h:345
Store< Vertex > m_pVertices
Definition: mesh.h:1076
static void SetBaseMeshMode(bool b=true)
sets a static mode to use the base mesh or the current subdiv level of the mesh.
Definition: mesh.h:1765
void SetPartitionBlindInt(unsigned int pIdx, unsigned int ii)
Write Accessor for blind data (32 bit uint) on each partition.
Definition: mesh.h:1925
unsigned int m_iFaceIndex
Index of a face which uses the vertex.
Definition: mesh.h:328
float Freeze(void) const
Returns the Freeze value of the Vertex (between 0.0 and 1.0, where 0.0 is not frozen) ...
Definition: mesh.h:76
This is the base class for anything which is an element of a list with a fixed order and a transparen...
Definition: layer.h:20
void SetVertexTC(unsigned int iTCIndex, const TC &tc)
Sets the Texture Coordinated(UV) value at the given index.
Definition: mesh.h:661
GLuint src
Definition: GLee.h:7190
Store< unsigned int > m_aIndices
Definition: mesh.h:134
void SetFreeze(float fFreeze)
Sets the Freeze value of the Vertex (between 0.0 and 1.0, where 0.0 is not frozen) ...
Definition: mesh.h:85
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
void Reset(void)
Makes the box empty.
Definition: math.h:885
Represents a local coordinate basis comprising three axes that define a coordinate system...
Definition: math.h:1044
unsigned int a[3]
Definition: mesh.h:1343
unsigned int GetPartitionBlindInt(unsigned int pIdx) const
Read Accessor for blind data (32 bit uint) on each partition.
Definition: mesh.h:1921
TC(float fU, float fV)
Definition: mesh.h:150
const tnormal * QuadVertexNormalArray(unsigned int iQuadIndex, unsigned int iCornerIndex) const
Returns the normal of a corner of a quad mesh face as an array of 16-bit signed values.
Definition: mesh.h:823
Represents a bounding box whose axes are aligned with the coordinate system.
Definition: math.h:838
static void SetDefaultPartitionCount(unsigned int pc)
Set the default partition count.
Definition: mesh.h:1794
Vector VertexNormal(unsigned int iVertexIndex) const
Returns the normal of the vertex with the given index.
Definition: mesh.h:556
The SpatialGrid class is an interface for dividing the space of a mesh to grids/cells/voxels.
Definition: mesh.h:1322
const tnormal * TriangleVertexNormalArray(unsigned int iTriangleIndex, unsigned int iCornerIndex) const
Returns the normal of a corner of a triangle mesh face as an array of 16-bit signed values...
Definition: mesh.h:817
Normal vector with 16 bit components.
Definition: topology.h:25
Vertex(void)
Definition: mesh.h:58
bool IsPartitionDirty(unsigned int pIdx) const
returns true if the partition has been changed since the HWRenderer has built the VBOs for this parti...
Definition: mesh.h:1868
Describes a location somewhere on the surface of a Mesh.
Definition: mesh.h:340
This is the base class for most classes in the Mudbox SDK.
Definition: node.h:740
const StoredVertexInfo & GetRestoreVertexInfo(unsigned int i) const
This is not part of the API – do not use. (it is here for performance reasons.)
Definition: mesh.h:1089
Vector & VertexPosition(unsigned int iVertexIndex)
Returns the x,y,z position of the vertex with the given index.
Definition: mesh.h:539
void SetSelected(bool bSelected)
Sets the Selected state of the Vertex (true or false)
Definition: mesh.h:102
FaceEnumerator is a base class for operations that must be applied across mesh faces.
Definition: mesh.h:225
TC(void)
Definition: mesh.h:149
Coord(unsigned int x, unsigned int y, unsigned int z)
Definition: mesh.h:1330
void ContentChanged(void)
Call this method after modifying the partitioning.
Definition: mesh.h:1885
const Vector & OriginalPosition(unsigned int iVertexIndex) const
This function returns the position of a vertex before this change.
Definition: mesh.h:1496
tnormalv QuadVertexNormalValue(unsigned int iQuadIndex, unsigned int iCornerIndex) const
Returns the normal a corner of a quad mesh face as a single 64-bit signed value.
Definition: mesh.h:835
void ClearVertexMarks(void)
Clears all vertex marks.
Definition: mesh.h:727
void Serialize(class Stream &s)
Serializes the the array and its contents from/to a stream.
Definition: stream.h:294
This is the base class for a renderer implementation, which transforms a mesh into the opengl pipelin...
Definition: renderer.h:29
unsigned long long tnormalv
Type of the whole normal vector.
Definition: topology.h:22
Vector m_vPos
Definition: mesh.h:58
void IncreaseCollectionID(void)
Obsolete method; do not use.
Definition: mesh.h:937
bool m_bEnumerateFakeTriangles
The corner within the face that corresponds to the original vertex.
Definition: mesh.h:301
aptr< LayerMeshData > ActiveSculptLayer
This is a readonly pointer containing the address of the active sculpt layer or null if there is no a...
Definition: mesh.h:962
bool operator==(const Attribute &cA, const AttributeInstance< type > &cB)
This operator compares the two attributes and NOT their values.
Definition: node.h:577
static bool IsInBaseMeshMode()
Definition: mesh.h:1766
Store< unsigned int > m_aAdjacents
Definition: mesh.h:135
float u
Definition: mesh.h:169
unsigned int GetSides(void)
Returns the sidecount for a given face.
Definition: mesh.h:113
Store< StoredVertexInfo > m_aRestoreBuffer
Definition: mesh.h:1083
#define __forceinline
Definition: mudbox.h:146
float y
Definition: math.h:340
void Clear(bool bDestruct=false)
Clears the array and deallocates its memory.
Definition: array.h:394
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:880
unsigned short m_iStates
Definition: mesh.h:68
AdjacentVertexEnumerator is a base class for operations that must be applied to all vertices adjacent...
Definition: mesh.h:286
void AddVertexPosition(unsigned int iVertexIndex, const Vector &vPosition)
Adds vPosition to the current position of the vertex with the given index.
Definition: mesh.h:629
short int tnormal
Type of one component in a normal vector.
Definition: topology.h:20
bool operator==(const Coord &other)
Definition: mesh.h:1338
Vector m_vFaceCoordinates
Definition: mesh.h:443
StoredVertexInfo VertexChange
This struct holds the change information about a single vertex.
Definition: mesh.h:1481
const TC & TriangleVertexTC(unsigned int iTriangleIndex, unsigned int iCornerIndex) const
Returns the texture coordinates of a corner of a mesh face.
Definition: mesh.h:768
Store< StoredVertexInfo > & GetRestoreBufferRef()
This is not part of the API – do not use. (it is here for performance reasons.)
Definition: mesh.h:1097
Picker objects are used as part of the map extraction process, to find points on one mesh that most c...
Definition: mesh.h:1193
This class represents a 4x4 transformation matrix.
Definition: math.h:1122
void SetMask(float fMask)
Do not use this method.
Definition: mesh.h:95
VertexAdjacency(unsigned int iFaceIndex, unsigned char iCornerIndex)
Constructs an adjacency struture with the specified face and corner indices.
Definition: mesh.h:191
void SetVertexStrokeID(unsigned int iVertexIndex, unsigned int iStrokeID) const
Internal use only. Do not call.
Definition: mesh.h:683
unsigned int m_iStrokeID
Definition: mesh.h:62
#define MB_NORMALMAX
Definition: mesh.h:34
float m_fV
Definition: mesh.h:173
Store< unsigned int > m_aTCIs
Definition: mesh.h:136
bool Copy(Store &s) const
Copies the contents of another array into this one, duplicating all data. Returns true if successful...
Definition: array.h:381
Vector m_vLocalNormal
the normal vector of the mesh at the picked point, in local space
Definition: mesh.h:346
const Vertex * VertexArray(void) const
This method returns a pointer to the actual array data.
Definition: mesh.h:521
unsigned int & operator[](unsigned int i)
Definition: mesh.h:1335
unsigned int VertexStrokeID(unsigned int iVertexIndex) const
Internal use only. Do not call this method.
Definition: mesh.h:561
TangentGenerator is a class that defines the tangent space used by Mesh objects.
Definition: mesh.h:1149
GLenum GLint x
Definition: GLee.h:876
const AxisAlignedBoundingBox & GetPartitionAABB(unsigned int pIdx) const
returns the bounding box of a partition.
Definition: mesh.h:1829
const QByteArray operator+(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:564
GLuint GLuint GLsizei count
Definition: GLee.h:872
SpatialGrid * m_pGrid
Definition: mesh.h:1100
float m_fData
This variable can be used freely to store a float value for the vertex.
Definition: mesh.h:324
const Vector & QuadVertexPosition(unsigned int iQuadIndex, unsigned int iCornerIndex) const
Returns the position of a corner of a mesh face. Can be used for quadric meshes only.
Definition: mesh.h:761
float VertexMask(unsigned int iVertexIndex) const
Returns the layer mask of the vertex with the given index for the current sculpt layer.
Definition: mesh.h:574
Generic base interface for classes implementing a face based selection.
Definition: mesh.h:1116
const TC & QuadVertexTC(unsigned int iQuadIndex, unsigned int iCornerIndex) const
Returns the texture coordinates of a corner of a mesh face. Can be used for quadric meshes only...
Definition: mesh.h:774
unsigned int GetFacePartitionIndex(unsigned int faceID) const
return the index within it's partition partition of a given face ID.
Definition: mesh.h:1939
unsigned int m_iVertexCount
Definition: mesh.h:1074
This class represents an event receiver/triggerer point.
Definition: node.h:999
unsigned int VertexCount(void) const
Returns the number of vertices in the mesh.
Definition: mesh.h:490
DiagnosticLevel
Indicates the level of validity checking that is performed in CheckValidity()
Definition: node.h:781
A base class for operations that must be applied across mesh vertices.
Definition: mesh.h:257
unsigned char m_iVertexCorner
The corner within the face that corresponds to the current vertex.
Definition: mesh.h:299
This class represents a change to a mesh, and is used when an operation which modifies mesh vertices ...
Definition: mesh.h:1475
QualityHint GetCurrentPartitioningQuality() const
Return the current partitioning quality for this partitioning node.
Definition: mesh.h:1856
bool IsVertexMarked(unsigned int iVertexIndex)
Returns true if a particular vertex is marked.
Definition: mesh.h:714
bool operator!=(const QByteArray &a1, const QByteArray &a2)
Definition: qbytearray.h:533
const GLdouble * v
Definition: GLee.h:1174
ScreenSpacePicker objects are used to translate the user action of clicking in the view into a picked...
Definition: mesh.h:1229
unsigned int CollectionID(void) const
Obsolete method; do not use.
Definition: mesh.h:931
unsigned int GetPartitionFaceCount(unsigned int pIdx) const
Return the number of faces to enumerate in the specified partition Note some faces may be INVALID_ID ...
Definition: mesh.h:1911
unsigned char CornerIndex() const
Returns the corner index of a face which is touching the vertex that corresponds to this structure If...
Definition: mesh.h:205
GLubyte GLubyte b
Definition: GLee.h:5404
unsigned int ItemCount(void) const
Returns the number of items in the array.
Definition: array.h:645
Represents Texture Coordinates (UVs) in the mesh.
Definition: mesh.h:147
unsigned int m_iVertexIndex
Index of the vertex.
Definition: mesh.h:326
float TriangleVertexFreeze(unsigned int iTriangleIndex, unsigned int iCornerIndex) const
Returns the freeze value of a corner of a mesh face. Can be used for triangular meshes only...
Definition: mesh.h:804
unsigned int & GetRestoreCountRef()
This is not part of the API – do not use. (it is here for performance reasons.)
Definition: mesh.h:1095
Represents a camera (point of view) in a Mudbox scene.
Definition: camera.h:20
void ContentChanged(void) const
This function must be called if the content of the node is changed.
GLfloat GLfloat p
Definition: GLee.h:5416
float Data(unsigned int iVertexIndex) const
Returns the float data value stored in the vertex change.
Definition: mesh.h:1484
unsigned int m_iID
This variable is used internally.
Definition: mesh.h:316
const TC & VertexTC(unsigned int iVertexTCIndex) const
Returns the specified texture coordinate.
Definition: mesh.h:551
bool IsContaining(const Vector &cV) const
Returns true if the box contains the specified point.
Definition: math.h:992
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
void SetPartitionDirty(unsigned int pIdx)
called by the HWRenderer to set the dirty flag to clean once it has built the VBOs for the specified ...
Definition: mesh.h:1872
unsigned int Add(const type &e)
Adds a new item to the array, increasing the array size by 1.
Definition: array.h:482
Class: ConvolutionKernel.
Definition: array.h:15
This class is the base of all node types that can be structured in a hierarchy.
Definition: treenode.h:18
#define INVALID_ID
Definition: mesh.h:47
SurfacePoint(void)
Void Constructor.
Definition: mesh.h:351
unsigned int Adjacency(unsigned int i)
Returns the ith adjacent for the given face.
Definition: mesh.h:115
unsigned int m_iRestoreCount
Definition: mesh.h:1082
__forceinline Vector OriginalNormal(unsigned int iVertexIndex) const __attribute__((always_inline))
This function returns the surface normal before the change for a specified vertex.
Definition: mesh.h:1508
static void SetFaceMode(bool b=true)
sets a static mode to use either face indices or vertex indices to perform partitioning.
Definition: mesh.h:1774
const Vector & VertexPosition(unsigned int iVertexIndex) const
Returns the x,y,z position of the vertex with the given index.
Definition: mesh.h:534
unsigned int GetFaceCount() const
return the count of faces in the partitioning.
Definition: mesh.h:1903
unsigned int GetPartitionVersion(unsigned int pIdx) const
Returns the version number of the specified partition.
Definition: mesh.h:1930
This object is used to manage the lock on a mesh.
Definition: mesh.h:1576
StoredVertexInfo is used to store vertex change information.
Definition: mesh.h:311
GLubyte GLubyte GLubyte a
Definition: GLee.h:5404
tnormal m_vNormal[4]
Definition: mesh.h:321
class Mesh * m_pMesh
the mesh that has been picked
Definition: mesh.h:342
unsigned int TCCount(void) const
Returns the number of texture coordinates in the mesh.
Definition: mesh.h:498
unsigned int GetPartitionID(unsigned int faceID) const
Returns the partition ID given a face ID.
Definition: mesh.h:1951
This object is used to manage a roughly spatially coherent partitioning of the mesh.
Definition: mesh.h:1616
unsigned int GetPartitionMaxFaceID(unsigned int pIdx) const
Get the maximum face ID in a partition. If empty, return 0.
Definition: mesh.h:1837
Describes a material of a geometry including its surface colors, transparency and texture information...
Definition: material.h:73
static unsigned int GetDefaultPartitionCount()
Query the default partition count.
Definition: mesh.h:1789
bool IsSelected(void) const
Returns the Selected state of the Vertex (true or false)
Definition: mesh.h:99
unsigned int m_iCollectionID
Definition: mesh.h:1075
const QPoint operator-(const QPoint &p1, const QPoint &p2)
Definition: qpoint.h:170
bool m_bBuildVertexAdjacency
Definition: mesh.h:1080
Represents a 3d object in the scene.
Definition: geometry.h:18
float Mask(void) const
Do not use this method.
Definition: mesh.h:90
Streams are used to read information from a file, or to write it to a file.
Definition: stream.h:39
Vector TriangleVertexNormal(unsigned int iTriangleIndex, unsigned int iCornerIndex) const
Returns the normal of a corner of a mesh face. Can be used for triangular meshes only.
Definition: mesh.h:780
unsigned int TCI(unsigned int i)
Returns the ith TC index for the face.
Definition: mesh.h:117
float m_fRelativeRange
position of a mesh-line intersection relative to the line. Ranges from 0.0 (at the beginning of the l...
Definition: mesh.h:344
#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
void ExpandBy(float f)
Expands the AABB by a specified amount in all directions.
Definition: math.h:926
const AxisAlignedBoundingBox & GetTotalAABB() const
get the bounding box of this partitioning.
Definition: mesh.h:1825
void SetVertexNormal(unsigned int iVertexIndex, int *pNormal)
Internal use only. Do not call.
Definition: mesh.h:636
const Vertex & VertexData(unsigned int iVertexIndex) const
Returns a vertex.
Definition: mesh.h:524
GLuint id
Definition: GLee.h:1552
aevent Modified
This event is triggered when the mesh has been editer. During a sculpt stroke this event is only trig...
Definition: mesh.h:1024
tnormalv TriangleVertexNormalValue(unsigned int iTriangleIndex, unsigned int iCornerIndex) const
Returns the normal a corner of a triangle mesh face as a single 64-bit signed value.
Definition: mesh.h:829
unsigned int GetPartitionFace(unsigned int pIdx, unsigned int fIdx) const
Return the specified face id in the specified partition Note some faces may be INVALID_ID – these sh...
Definition: mesh.h:1917
unsigned int GetPartitionMinFaceID(unsigned int pIdx) const
Get the minimum face ID in a specified partition. If empty, will return 0xffffffff.
Definition: mesh.h:1833
unsigned int GetFacePartition(unsigned int faceID) const
return the Partition id of a specified face. Can be INVALID_ID if it's not in a partition.
Definition: mesh.h:1934
GLdouble s
Definition: GLee.h:1173
This is an interface for a SurfaceSmoother object, which is responsible to provide information about ...
Definition: mesh.h:1429
Represents a vertex point on a Mesh with its associated data.
Definition: mesh.h:56
float x
Definition: math.h:340
GLclampf f
Definition: GLee.h:9303
Represents the topology data of a mesh, providing information about the structure of a surface...
Definition: topology.h:45
unsigned int GetRestoreCount() const
Definition: mesh.h:1086
void Serialize(Stream &s)
Serializing.
Definition: mesh.h:119
VertexAdjacency()
Constructs a invalid adjacency structure.
Definition: mesh.h:188
bool IsValid() const
Returns true if this structure is valid, false otherwise.
Definition: mesh.h:197
const tnormal * VertexNormalArray(unsigned int iVertexIndex) const
Returns the normal of the vertex with the given index as an array of 16-bit signed values...
Definition: mesh.h:595
static QualityHint GetDefaultQuality()
Query the default quality hint.
Definition: mesh.h:1784
#define MBDLL_DECL
Definition: dllinterface.h:35
virtual const Vector & VertexOriginalPosition(unsigned int iVertexIndex) const
Returns the position of the vertex before the current sculpting-brush stroke.
Definition: mesh.h:546
This class represents a Sculpt Layer.
Definition: layer.h:216
bool AnyPartitionsDirty()
returns true if any of the partitions are dirty.
Definition: mesh.h:1875
const Vector & TriangleVertexPosition(unsigned int iTriangleIndex, unsigned int iCornerIndex) const
Returns the position of a corner of a mesh face.
Definition: mesh.h:755
static bool IsInFaceMode()
Definition: mesh.h:1775
float VertexFreeze(unsigned int iVertexIndex) const
Returns the freeze value of the vertex with the given index.
Definition: mesh.h:585
Vector m_vPosition
The position of the vertex before the change.
Definition: mesh.h:314
GLuint index
Definition: GLee.h:1704
unsigned int m_iFaceIndex
the index of the face that has been picked
Definition: mesh.h:343
float m_fU
Definition: mesh.h:168
__forceinline VertexChange & Add(unsigned int iVertexIndex, unsigned int iFaceIndex, bool bPrecalculateLayerIndex=false, float fDataInitialValue=0.0f) __attribute__((always_inline))
Register a vertex for the change, and returns the corresponding VertexChange structure.
Definition: mesh.h:1534
class TangentGenerator * m_pTG
address of a tangent generator which should be used to calculate tangents for this surface point ...
Definition: mesh.h:348
Vector QuadVertexCreaseNormal(unsigned int iQuadIndex, unsigned int iCornerIndex) const
Returns the normal of a corner of a mesh face. Can be used for quad meshes only.
Definition: mesh.h:798
unsigned int m_iLayerVertexIndex
Index of the vertex within the current sculpt layer.
Definition: mesh.h:330
unsigned int FaceIndex() const
Returns the face index of a face which is touching the vertex that corresponds to this structure If V...
Definition: mesh.h:201
bool IsCurrentPartitioningFaceBased() const
Definition: mesh.h:1777