MapExtractor/MapExtractorInterface.h Source File

MapExtractorInterface.h
Go to the documentation of this file.
1 #ifndef __MAPEXTRACTORINTERFACE_H
2 #define __MAPEXTRACTORINTERFACE_H
3 
4 #include <QtGui/QComboBox>
5 
6 #if defined(JAMBUILD)
7 #include <Mudbox/mudbox.h>
8 #else
9 #include "../../include/Mudbox/mudbox.h"
10 #endif
11 
12 class TextureExtractionDialog;
13 class Mapper;
14 
16 {
17 
18 #ifndef COMPILING_MAPEXTRACTOR_DLL
19 #define MEDLL MUDBOX_DLLIMPORT
20 #else
21 #define MEDLL MUDBOX_DLLEXPORT
22 #endif
23 
65 {
67 
69  virtual void SetTargetCount( unsigned int iTargetCount );
71  virtual void SetTargetMesh(
72  unsigned int iTargetIndex,
73  mudbox::SubdivisionLevel *pTarget
74  );
75 
77  virtual unsigned int TargetCount( void ) const;
79  virtual mudbox::SubdivisionLevel *TargetMesh( unsigned int iMeshIndex ) const;
81  virtual unsigned int CurrentTarget( void ) const;
83  virtual mudbox::SurfaceSmoother *CurrentTargetSmoother( void ) const;
85  virtual bool IsCurrentTargetAClone( void ) const;
86 
88  virtual unsigned int SourceCount( void ) const;
90  virtual mudbox::SubdivisionLevel *SourceMesh( unsigned int iIndex ) const;
92  virtual void SetSourceCount( unsigned int iMeshCount );
94  virtual void SetSourceMesh( unsigned int iIndex, mudbox::SubdivisionLevel *pSource );
95 
97  virtual unsigned int SamplerCount( void ) const;
99  virtual class Sampler *SamplerByIndex( int iIndex ) const;
101  virtual class Sampler *SamplerByName( const QString &sSamplerName ) const;
103  virtual class Sampler *SamplerByClass( const mudbox::ClassDesc *, int iIndex = 0 );
105  virtual class Sampler *SamplerByClassName( const QString &sClassName, int iIndex = 0 );
106 
108  virtual unsigned int LocationCount( void ) const;
110  virtual void TargetLocation( unsigned int iIndex, class TargetLocation *pLocation ) const;
112  virtual void SourceLocation( unsigned int iIndex, mudbox::SurfacePoint *pLocation ) const;
113 
115  virtual bool SourceSmoothing( void ) const;
117  virtual bool TargetUVSmoothing( void ) const;
119  virtual bool TargetSmoothing( void ) const;
121  virtual void SetSmoothing( bool bTargetSmoothing, bool bSourceSmoothing, bool bTargetUVSmoothing = false );
123  virtual bool SourceCreases( void ) const;
125  virtual void SetSourceCreases( bool bOn );
127  virtual bool AddProgress( int iProgress );
128 
130  virtual void SetMapWidth( int iWidth );
132  virtual void SetMapHeight( int iHeight );
133 
135  virtual class Layout *Layout() const;
137  virtual class Locator *Locator( int iIndex = 0 ) const;
138 
141  virtual void RequestTangents( void );
143  virtual bool AreTangentsNeeded( void ) const;
146  virtual void SetTangentGenerator( mudbox::TangentGenerator *pGenerator );
147  virtual mudbox::TangentGenerator *CurrentTangentGenerator( void ) const;
148 
153  virtual void SetUtilizerType( const mudbox::ClassDesc *pUtilizerType );
155  virtual void SetLocatorType( const mudbox::ClassDesc *pLocatorType, int iIndex = 0 );
156 
158  virtual bool Execute(
159  bool bInterface = true
160  );
162  virtual bool SilentMode( void ) const;
163 
165  virtual void ValidityChanged( void );
166 
168  static bool DeveloperMode( void );
169 };
170 
171 //------------------------------------------------------------------------------
175 class Data
176 {
177  public:
178  union {
179  int m_int[16];
180  float m_float[16];
181  double m_double[8];
182  // we cant put classes with copy ctors or assignment operators in a union...
183  };
184  bool m_valid;
185 
186  Data(void) { m_valid = false; };
187  Data(int r) { m_int[0] = r; m_valid = true; }
188  Data(float r) { m_float[0] = r; m_float[1] = m_float[2] = 0; m_float[3] = 1; m_valid = true; }
189  Data(double r) { m_double[0] = r; m_valid = true; }
190  Data(const mudbox::Color &r) { m_float[0] = r.m_fRed; m_float[1] = r.m_fGreen;
191  m_float[2] = r.m_fBlue; m_float[3] = r.m_fAlpha; m_valid = true; }
192  Data(const mudbox::Vector &r) { m_float[0] = r.x; m_float[1] = r.y; m_float[2] = r.z; m_float[3] = 1; m_valid = true; }
193  Data(const mudbox::DblVector &r) { m_double[0] = r.x; m_double[1] = r.y; m_double[2] = r.z; m_double[3] = 1; m_valid = true; }
194  Data(const mudbox::Vector4 &r) { m_float[0] = r.x; m_float[1] = r.y;
195  m_float[2] = r.z; m_float[3] = r.w; m_valid = true; }
196  Data(const mudbox::Quaternion &r) { memcpy(m_float, &r.m_fW, sizeof(float) * 4); m_valid = true; }
197  Data(const mudbox::Matrix &r) { memcpy(m_float, r.m_fData, sizeof(float) * 16); m_valid = true; }
198  bool IsValid( void ) const { return m_valid; }
199 
200  int As_int () const { return m_int[0]; }
201  float As_float () const { return m_float[0]; }
202  double As_double () const { return m_double[0]; }
203  mudbox::Color As_Color () const { return mudbox::Color(m_float[0], m_float[1], m_float[2], m_float[3]); }
207  mudbox::Quaternion As_Quaternion () const { mudbox::Quaternion q; memcpy(&q.m_fW, m_float, sizeof(float) * 4); return q; }
208  mudbox::Matrix As_Matrix () const { mudbox::Matrix m; memcpy(m.m_fData, m_float, sizeof(float) * 16); return m; }
209 };
210 
211 
212 //------------------------------------------------------------------------------
213 // This is the base class for locators, i.e. nodes which should find surface
214 // points on the source mesh to match surface points on the target mesh. The map
215 // extractor node always uses one instance of a locator during the extraction
216 // process
217 class MEDLL Locator : public mudbox::Node
218 {
220 public:
221  Locator( Mapper *pMapper = 0 ) : m_pMapper( pMapper ) {};
222  ~Locator( void ) {};
224  virtual void Prepare( void ) {};
226  virtual void CleanUp( void ) {};
229  virtual bool LocateSurfacePoint( mudbox::SurfacePoint &pPoint, const class TargetLocation &vTarget );
232  virtual QWidget *UserInterface( void );
234  virtual void Serialize( mudbox::Stream &s );
235  virtual bool IsValid( void );
237  MapExtractor *Extractor( void ) const;
240 
242  Mapper *m_pMapper;
243 private:
244 
245  friend class Mapper;
246 };
247 
258 class MEDLL SamplerUI : public QObject, public mudbox::Node
259 {
260  Q_OBJECT;
261 protected:
262  SamplerUI( class Sampler *pTarget );
264  QWidget *CreateTargetWidget(
265  bool bSmoothing = true,
266  bool bUVSmoothing = true,
267  bool bDefaultToLowest = true,
268  bool bShowLevels = true
269  );
271  QWidget *CreateSourceWidget(
272  bool bSmoothing = true
273  );
276  QWidget *CreateLocatorWidget( void );
280  QWidget *CreateLayoutWidget( void );
283  QWidget *CreateOutputWidget( void );
284 public:
285  Mapper *m_pMapper;
287  virtual void Initialize( void );
288  virtual QWidget *RootWidget( void );
289  virtual void UpdateValues( void );
290 
291  TextureExtractionDialog *m_pDialog;
295  QLabel *SmallerLabel( const QString& text );
296  MapExtractor *Extractor( void ) const;
297 private slots:
298  void OnAddSelectedAsTarget( void );
299  void OnAddAllAsTarget( void );
300  void OnRemoveTarget( void );
301  void OnTargetItemClicked( int row, int column );
302  void OnSourceItemClicked( int row, int column );
303  void OnSmoothTargetChanged( void );
304  void OnSmoothTargetUVChanged( void );
305  void OnPreserveCreasesAndHardEdgesChanged( void );
306  void OnSmoothSourceChanged( void );
307  void OnAddSelectedAsSource( void );
308  void OnAddAllAsSource( void );
309  void OnRemoveSource( void );
310  void OnTargetReordered( int, int, int );
311  void OnMapTypeChanged( const QString & );
312 protected:
315 private:
316 
317  friend class Sampler;
318  friend class Mapper;
319 };
320 
323 {
332 };
333 
341 class MEDLL Layout : public mudbox::Node
342 {
344 
345  Layout( void ) : m_pMapExtractor( NULL ) {};
347  bool ProcessSurfacePoint( const TargetLocation &vLocation );
350  void Flush( void );
357  void BeginSection( void );
359  void EndSection( void );
361  virtual void CleanUp( void );
362  void Serialize( mudbox::Stream & );
363 
365  virtual unsigned int Prepare( void );
368  virtual void ProcessSurface( mudbox::SubdivisionLevel *pTarget );
370  virtual QWidget *UserInterface( void );
371  MapExtractor *Extractor( void ) const { return m_pMapExtractor; };
372  MapExtractor *m_pMapExtractor;
373 private:
374 
375  friend class Mapper;
376 };
377 
384 class MEDLL Gate : public mudbox::Node
385 {
387 public:
388  virtual Data Process( const Data &cData, const mudbox::SurfacePoint &cSource, const TargetLocation &cTarget );
389  virtual class Sampler *Sampler( void ) const { return m_pSampler; };
390  virtual void Serialize( mudbox::Stream & );
391 private:
392  class Sampler *m_pSampler;
393 
394  friend class Sampler;
395 };
396 
407 class MEDLL Sampler : public mudbox::Node
408 {
410  enum Normalization
411  {
412  eNormNone,
413  eNormFull,
414  eNormKeepZero,
415  eNormCustom
416  };
417  enum Precision
418  {
419  ePrecByte,
420  ePrecFloat,
421  ePrecFloatOnly
422  };
424  struct DataInfo
425  {
426  DataInfo() : m_eNormalization( eNormNone ), m_fLowerBound( 0 ), m_fUpperBound( 1 ), m_iChannelCount( 3 ), m_ePrecision( ePrecFloat ) {};
427  Normalization m_eNormalization;
428  float m_fLowerBound;
429  float m_fUpperBound;
430  int m_iChannelCount;
431  Precision m_ePrecision;
432  QString m_sMaterialChannelName;
433  QString m_sDataName;
435  };
437  Sampler( void );
438  ~Sampler( void );
439  void Serialize( mudbox::Stream & );
443  virtual int Prepare( void );
445  virtual void CleanUp( void );
446 
449  virtual Data ProcessSurfacePoint( const TargetLocation &cTarget, const mudbox::SurfacePoint &cSource );
451  virtual SamplerUI *UserInterface( void );
459  virtual unsigned int ConfigurationCount( void ) const;
461  virtual void SetConfiguration( unsigned int iConfiguration );
464  virtual bool IsValid( void );
466  virtual void SetupPaintLayer( mudbox::TexturePool *pPaintLayer ) const;
468  virtual void OnPhaseEvent( PhaseEventType eType );
472  virtual Data DefaultData( void ) const;
475  virtual struct DataInfo DataInfo( void ) const;
478  virtual void AddGate( Gate *pGate );
479  // Remove all gates added to the sampler.
480  virtual void RemoveAllGates( void );
481 
482  class Utilizer *Utilizer( void ) const { return m_pUtilizer; };
483 
485  void SetEnabled( bool bOn );
487  bool IsEnabled( void ) const { return m_bEnabled; };
488 
489  MapExtractor *Extractor( void ) const { return m_pMapExtractor; };
490  Mapper *m_pMapper;
491  class MapExtractor *m_pMapExtractor;
492  class Utilizer *m_pUtilizer;
493  QVector<Gate *> m_aGates;
494 
495 private:
496 
497  mudbox::abool m_bEnabled;
498  friend class Mapper;
499 };
500 
507 {
508 public:
509  enum Flags
510  {
511  flagMirrorX = 1,
512  flagMirrorY = 2,
513  flagMirrorZ = 4,
514  flagLocalMirror = 8
515  };
516 
520  float m_fDiameter;
524  int m_aLayoutData[16];
528  unsigned int m_iReferenceFaceIndex;
532  float m_fReferenceFaceU, m_fReferenceFaceV;
536  unsigned int m_iIndex;
538  mutable unsigned int m_iFlags;
540 
541  TargetLocation( void ) : m_fDiameter( 1.0f ), m_iReferenceFaceIndex( 0xffffffff ), m_fReferenceFaceU(0), m_fReferenceFaceV(0), m_iIndex(0xffffffff), m_iFlags( 0 ) {};
542  TargetLocation( class mudbox::Mesh *pMesh, unsigned int iVertexIndex, unsigned int iFaceIndex ) :
543  SurfacePoint( pMesh, iVertexIndex, iFaceIndex ), m_fDiameter( 1.0f ), m_iReferenceFaceIndex( 0xffffffff ),
544  m_fReferenceFaceU(0), m_fReferenceFaceV(0), m_iIndex(0xffffffff), m_iFlags( 0 ) {};
545 
547  void Fill(
548  class mudbox::Mesh *pMesh,
549  unsigned int iFaceIndex,
550  float fFaceU,
551  float fFaceV,
552  float fDiameter = 1.0f
553  );
557  void FillUsingUV(
558  class mudbox::Mesh *pMesh,
559  unsigned int iFaceIndex,
560  float fU,
561  float fV,
562  mudbox::SurfaceSmoother *pSS = NULL,
563  float fDiameter = 1.0f
564  );
565 
569  void FillNSided(
570  class mudbox::Mesh *pMesh,
571  unsigned int iFaceIndex,
572  const mudbox::Vector &vPosition,
573  float fDiameter = 1.0f
574  );
575 
578  void AddFlag( Flags eFlagToAdd ) const { m_iFlags |= eFlagToAdd; };
579 
580  void CalculateSmoothData( const MapExtractor * );
581  mudbox::Base TangentBase( void ) const { return m_bTangent; };
582 
583 private:
584  bool RefineFaceIndex( void );
585  float RefineFaceCoordinates( const mudbox::SurfaceSmoother *pSS, float fTargetU, float fTargetV, unsigned int iSteps );
586 };
587 
596 {
598  Utilizer( void ) : m_pSampler( 0 ) {};
600  virtual QString MapTypeName( void ) const;
602  virtual void OnPhaseEvent( PhaseEventType eType );
604  virtual bool IsValid( void );
606  virtual void CleanUp( void );
609  virtual void Prepare( Layout *pLayout, class Sampler *pSampler );
610  // This function is called every time when a new data is calculated by the associated sampler of the utilizer. Usually the utilizer obtains additional data
611  // from the cTarget objects, which is able to hold generic data from the layout (m_aLayoutData). The utilizer should know the current layout type, so it
612  // knows how to interpret the data stored in that area. This function must be thread safe.
613  virtual void StoreData(
614  const Data &cData,
615  const TargetLocation &cTarget,
616  const mudbox::SurfacePoint &cSource
617  );
619  virtual QWidget *UserInterface( void );
623  virtual Layout *CreateLayout( void );
624  virtual void Serialize( mudbox::Stream &s );
626  virtual mudbox::Layer *ResultLayer( void ) const;
627 
628  class Sampler *Sampler( void ) const { return m_pSampler; };
629  MapExtractor *Extractor( void ) const { return Sampler()->Extractor(); };
630  class Sampler *m_pSampler;
631 private:
632 
633  friend class Mapper;
634 };
635 
637 {
639  virtual void Prepare( void );
640  virtual void CleanUp( void );
641  virtual mudbox::Mesh *Target( void ) const;
642  virtual bool MapSurfacePoint( mudbox::SurfacePoint &pPoint, const class TargetLocation &vTarget );
643 };
644 
645 };
646 
647 #endif
648 
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
float z
Definition: math.h:340
mudbox::Vector As_Vector() const
This node is responsible to collect the surface points on the target mesh which needs data to be comp...
Data(const mudbox::Vector &r)
mudbox::DblVector As_DblVector() const
Represents a 3D vector or point with S23E8 floating point elements.
Definition: math.h:35
A Mesh is a collection of vertices organized into faces, and optional Texture Coordinate information...
Definition: mesh.h:452
virtual void Prepare(void)
This is called once at the beginning. The locator node can initialize its own internal data during th...
float m_fRed
Definition: math.h:782
unsigned int m_iIndex
Index of the target location in the queue.
This is a container class for simple textures.
Definition: material.h:467
float z
Definition: math.h:632
Definition: qlabel.h:55
float m_fDiameter
This data member is an approximation of the influence area on the target mesh, i.e.
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
Represents a local coordinate basis comprising three axes that define a coordinate system...
Definition: math.h:1044
float m_fData[16]
Definition: math.h:1278
Procession of a new target mesh is started.
double y
Definition: math.h:568
#define MEDLL
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
The Quaternion class is used to represent rotations in most cases.
Definition: math.h:1300
float y
Definition: math.h:632
float m_fW
Content of the quaternion represented by four scalar values.
Definition: math.h:1405
Represents a color with four components: red, green, blue, alpha.
Definition: math.h:674
GLenum GLenum GLvoid * row
Definition: GLee.h:893
unsigned int m_iFlags
These flags are used to indicate special properties of the target location.
float y
Definition: math.h:340
double x
Definition: math.h:568
The queue which contains the collected target locations will be flushed now. No valid source location...
mudbox::Color As_Color() const
TextureExtractionDialog * m_pDialog
This is the final module in the map extraction process, which gets the data calculated by the sampler...
float m_fBlue
Definition: math.h:782
float w
Definition: math.h:632
This class represents a 4x4 transformation matrix.
Definition: math.h:1122
float m_fGreen
Definition: math.h:782
double z
Definition: math.h:568
GLdouble GLdouble GLdouble GLdouble q
Definition: GLee.h:1197
Data(const mudbox::Vector4 &r)
This structure represents and describes a class.
Definition: node.h:22
TangentGenerator is a class that defines the tangent space used by Mesh objects.
Definition: mesh.h:1149
A four dimensionsional vector (X, Y, Z, and W)
Definition: math.h:617
QVector< mudbox::SubdivisionLevel * > m_pOutputs
This structure represents the data which is calculated by the samplers, and passed to the utilizers...
TargetLocation(class mudbox::Mesh *pMesh, unsigned int iVertexIndex, unsigned int iFaceIndex)
#define Q_OBJECT
Definition: qobjectdefs.h:157
Data(const mudbox::Color &r)
GLenum GLenum GLvoid GLvoid * column
Definition: GLee.h:893
void AddFlag(Flags eFlagToAdd) const
This function adds a new flag to the current ones (OR operation).
This class is the base of all node types that can be structured in a hierarchy.
Definition: treenode.h:18
Data(const mudbox::DblVector &r)
float x
Definition: math.h:632
All the target locations in the queue got their source locations.
Data(const mudbox::Quaternion &r)
virtual void Initialize(void)
float m_fAlpha
Definition: math.h:782
mudbox::Vector4 As_Vector4() const
Represents one level of subdivision details in a geometry.
Definition: subdivision.h:40
This class holds information about a reference point on the target mesh.
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
unsigned int m_iReferenceFaceIndex
Sometimes it is necessary to use two different locations on the target mesh, one as a reference point...
This is a base class for a sampler node, which can generate some data for a given target-source surfa...
mudbox::Quaternion As_Quaternion() const
#define slots
Definition: qobjectdefs.h:68
This node is used to change data from a Sampler before it is processed by the Utilizer node...
GLdouble s
Definition: GLee.h:1173
This is the cental modul for map extraction, this node controls the map extraction process by communi...
This is an interface for a SurfaceSmoother object, which is responsible to provide information about ...
Definition: mesh.h:1429
This class represents the user interface which belongs to a sampler in map extraction.
float x
Definition: math.h:340
GLclampf f
Definition: GLee.h:9303
virtual void CleanUp(void)
Called once at the end of the map extraction.
Represents a 3D vector or point with S56E11 floating point elements.
Definition: math.h:348
mudbox::Matrix As_Matrix() const
virtual class Sampler * Sampler(void) const
Data(const mudbox::Matrix &r)
PhaseEventType
Types of the events occuring during extraction.