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;
82 
84  virtual unsigned int SourceCount( void ) const;
86  virtual mudbox::SubdivisionLevel *SourceMesh( unsigned int iIndex ) const;
88  virtual void SetSourceCount( unsigned int iMeshCount );
90  virtual void SetSourceMesh( unsigned int iIndex, mudbox::SubdivisionLevel *pSource );
91 
93  virtual unsigned int SamplerCount( void ) const;
95  virtual class Sampler *SamplerByIndex( int iIndex ) const;
97  virtual class Sampler *SamplerByName( const QString &sSamplerName ) const;
99  virtual class Sampler *SamplerByClass( const mudbox::ClassDesc *, int iIndex = 0 );
101  virtual class Sampler *SamplerByClassName( const QString &sClassName, int iIndex = 0 );
102 
104  virtual unsigned int LocationCount( void ) const;
106  virtual void TargetLocation( unsigned int iIndex, class TargetLocation *pLocation ) const;
108  virtual void SourceLocation( unsigned int iIndex, mudbox::SurfacePoint *pLocation ) const;
109 
111  virtual bool SourceSmoothing( void ) const;
113  virtual bool TargetUVSmoothing( void ) const;
115  virtual bool TargetSmoothing( void ) const;
117  virtual void SetSmoothing( bool bTargetSmoothing, bool bSourceSmoothing, bool bTargetUVSmoothing = false );
119  virtual bool SourceCreases( void ) const;
121  virtual void SetSourceCreases( bool bOn );
123  virtual bool AddProgress( int iProgress );
124 
126  virtual void SetMapWidth( int iWidth );
128  virtual void SetMapHeight( int iHeight );
129 
131  virtual class Layout *Layout() const;
133  virtual class Locator *Locator( int iIndex = 0 ) const;
134 
137  virtual void RequestTangents( void );
140  virtual void SetTangentGenerator( mudbox::TangentGenerator *pGenerator );
141 
146  virtual void SetUtilizerType( const mudbox::ClassDesc *pUtilizerType );
148  virtual void SetLocatorType( const mudbox::ClassDesc *pLocatorType, int iIndex = 0 );
149 
151  virtual bool Execute(
152  bool bInterface = true
153  );
155  virtual bool SilentMode( void ) const;
156 
158  virtual void ValidityChanged( void );
159 
161  static bool DeveloperMode( void );
162 };
163 
164 //------------------------------------------------------------------------------
168 class Data
169 {
170  public:
171  union {
172  int m_int[16];
173  float m_float[16];
174  double m_double[8];
175  // we cant put classes with copy ctors or assignment operators in a union...
176  };
177  bool m_valid;
178 
179  Data(void) { m_valid = false; };
180  Data(int r) { m_int[0] = r; m_valid = true; }
181  Data(float r) { m_float[0] = r; m_float[1] = m_float[2] = 0; m_float[3] = 1; m_valid = true; }
182  Data(double r) { m_double[0] = r; m_valid = true; }
183  Data(const mudbox::Color &r) { m_float[0] = r.m_fRed; m_float[1] = r.m_fGreen;
184  m_float[2] = r.m_fBlue; m_float[3] = r.m_fAlpha; m_valid = true; }
185  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; }
186  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; }
187  Data(const mudbox::Vector4 &r) { m_float[0] = r.x; m_float[1] = r.y;
188  m_float[2] = r.z; m_float[3] = r.w; m_valid = true; }
189  Data(const mudbox::Quaternion &r) { memcpy(m_float, &r.m_fW, sizeof(float) * 4); m_valid = true; }
190  Data(const mudbox::Matrix &r) { memcpy(m_float, r.m_fData, sizeof(float) * 16); m_valid = true; }
191  bool IsValid( void ) const { return m_valid; }
192 
193  int As_int () const { return m_int[0]; }
194  float As_float () const { return m_float[0]; }
195  double As_double () const { return m_double[0]; }
196  mudbox::Color As_Color () const { return mudbox::Color(m_float[0], m_float[1], m_float[2], m_float[3]); }
200  mudbox::Quaternion As_Quaternion () const { mudbox::Quaternion q; memcpy(&q.m_fW, m_float, sizeof(float) * 4); return q; }
201  mudbox::Matrix As_Matrix () const { mudbox::Matrix m; memcpy(m.m_fData, m_float, sizeof(float) * 16); return m; }
202 };
203 
204 
205 //------------------------------------------------------------------------------
206 // This is the base class for locators, i.e. nodes which should find surface
207 // points on the source mesh to match surface points on the target mesh. The map
208 // extractor node always uses one instance of a locator during the extraction
209 // process
210 class MEDLL Locator : public mudbox::Node
211 {
213 public:
214  Locator( Mapper *pMapper = 0 ) : m_pMapper( pMapper ) {};
215  ~Locator( void ) {};
217  virtual void Prepare( void ) {};
219  virtual void CleanUp( void ) {};
222  virtual bool LocateSurfacePoint( mudbox::SurfacePoint &pPoint, const class TargetLocation &vTarget );
225  virtual QWidget *UserInterface( void );
227  virtual void Serialize( mudbox::Stream &s );
228  virtual bool IsValid( void );
230  MapExtractor *Extractor( void ) const;
233 
235  Mapper *m_pMapper;
236 private:
237 
238  friend class Mapper;
239 };
240 
251 class MEDLL SamplerUI : public QObject, public mudbox::Node
252 {
253  Q_OBJECT;
254 protected:
255  SamplerUI( class Sampler *pTarget );
257  QWidget *CreateTargetWidget(
258  bool bSmoothing = true,
259  bool bUVSmoothing = true,
260  bool bDefaultToLowest = true,
261  bool bShowLevels = true
262  );
264  QWidget *CreateSourceWidget(
265  bool bSmoothing = true
266  );
269  QWidget *CreateLocatorWidget( void );
273  QWidget *CreateLayoutWidget( void );
276  QWidget *CreateOutputWidget( void );
277 public:
278  Mapper *m_pMapper;
280  virtual void Initialize( void );
281  virtual QWidget *RootWidget( void );
282  virtual void UpdateValues( void );
283 
284  TextureExtractionDialog *m_pDialog;
288  QLabel *SmallerLabel( const QString& text );
289  MapExtractor *Extractor( void ) const;
290 private slots:
291  void OnAddSelectedAsTarget( void );
292  void OnAddAllAsTarget( void );
293  void OnRemoveTarget( void );
294  void OnTargetItemClicked( int row, int column );
295  void OnSourceItemClicked( int row, int column );
296  void OnSmoothTargetChanged( void );
297  void OnSmoothTargetUVChanged( void );
298  void OnPreserveCreasesAndHardEdgesChanged( void );
299  void OnSmoothSourceChanged( void );
300  void OnAddSelectedAsSource( void );
301  void OnAddAllAsSource( void );
302  void OnRemoveSource( void );
303  void OnTargetReordered( int, int, int );
304  void OnMapTypeChanged( const QString & );
305 protected:
308 private:
309 
310  friend class Sampler;
311  friend class Mapper;
312 };
313 
316 {
325 };
326 
334 class MEDLL Layout : public mudbox::Node
335 {
337 
338  Layout( void ) : m_pMapExtractor( NULL ) {};
340  bool ProcessSurfacePoint( const TargetLocation &vLocation );
343  void Flush( void );
350  void BeginSection( void );
352  void EndSection( void );
354  virtual void CleanUp( void );
355  void Serialize( mudbox::Stream & );
356 
358  virtual unsigned int Prepare( void );
361  virtual void ProcessSurface( mudbox::SubdivisionLevel *pTarget );
363  virtual QWidget *UserInterface( void );
364  MapExtractor *Extractor( void ) const { return m_pMapExtractor; };
365  MapExtractor *m_pMapExtractor;
366 private:
367 
368  friend class Mapper;
369 };
370 
377 class MEDLL Gate : public mudbox::Node
378 {
380 public:
381  virtual Data Process( const Data &cData, const mudbox::SurfacePoint &cSource, const TargetLocation &cTarget );
382  virtual class Sampler *Sampler( void ) const { return m_pSampler; };
383  virtual void Serialize( mudbox::Stream & );
384 private:
385  class Sampler *m_pSampler;
386 
387  friend class Sampler;
388 };
389 
400 class MEDLL Sampler : public mudbox::Node
401 {
403  enum Normalization
404  {
405  eNormNone,
406  eNormFull,
407  eNormKeepZero,
408  eNormCustom
409  };
410  enum Precision
411  {
412  ePrecByte,
413  ePrecFloat,
414  ePrecFloatOnly
415  };
417  struct DataInfo
418  {
419  DataInfo() : m_eNormalization( eNormNone ), m_fLowerBound( 0 ), m_fUpperBound( 1 ), m_iChannelCount( 3 ), m_ePrecision( ePrecFloat ) {};
420  Normalization m_eNormalization;
421  float m_fLowerBound;
422  float m_fUpperBound;
423  int m_iChannelCount;
424  Precision m_ePrecision;
425  QString m_sMaterialChannelName;
426  QString m_sDataName;
428  };
430  Sampler( void );
431  ~Sampler( void );
432  void Serialize( mudbox::Stream & );
436  virtual int Prepare( void );
438  virtual void CleanUp( void );
439 
442  virtual Data ProcessSurfacePoint( const TargetLocation &cTarget, const mudbox::SurfacePoint &cSource );
444  virtual SamplerUI *UserInterface( void );
452  virtual unsigned int ConfigurationCount( void ) const;
454  virtual void SetConfiguration( unsigned int iConfiguration );
457  virtual bool IsValid( void );
459  virtual void SetupPaintLayer( mudbox::TexturePool *pPaintLayer ) const;
461  virtual void OnPhaseEvent( PhaseEventType eType );
465  virtual Data DefaultData( void ) const;
468  virtual struct DataInfo DataInfo( void ) const;
471  virtual void AddGate( Gate *pGate );
472  // Remove all gates added to the sampler.
473  virtual void RemoveAllGates( void );
474 
475  class Utilizer *Utilizer( void ) const { return m_pUtilizer; };
476 
478  void SetEnabled( bool bOn );
480  bool IsEnabled( void ) const { return m_bEnabled; };
481 
482  MapExtractor *Extractor( void ) const { return m_pMapExtractor; };
483  Mapper *m_pMapper;
484  class MapExtractor *m_pMapExtractor;
485  class Utilizer *m_pUtilizer;
486  QVector<Gate *> m_aGates;
487 
488 private:
489 
490  mudbox::abool m_bEnabled;
491  friend class Mapper;
492 };
493 
500 {
501 public:
502  enum Flags
503  {
504  flagMirrorX = 1,
505  flagMirrorY = 2,
506  flagMirrorZ = 4,
507  flagLocalMirror = 8
508  };
509 
513  float m_fDiameter;
517  int m_aLayoutData[16];
521  unsigned int m_iReferenceFaceIndex;
525  float m_fReferenceFaceU, m_fReferenceFaceV;
529  unsigned int m_iIndex;
531  mutable unsigned int m_iFlags;
533 
534  TargetLocation( void ) : m_fDiameter( 1.0f ), m_iReferenceFaceIndex( 0xffffffff ), m_fReferenceFaceU(0), m_fReferenceFaceV(0), m_iIndex(0xffffffff), m_iFlags( 0 ) {};
535  TargetLocation( class mudbox::Mesh *pMesh, unsigned int iVertexIndex, unsigned int iFaceIndex ) :
536  SurfacePoint( pMesh, iVertexIndex, iFaceIndex ), m_fDiameter( 1.0f ), m_iReferenceFaceIndex( 0xffffffff ),
537  m_fReferenceFaceU(0), m_fReferenceFaceV(0), m_iIndex(0xffffffff), m_iFlags( 0 ) {};
538 
540  void Fill(
541  class mudbox::Mesh *pMesh,
542  unsigned int iFaceIndex,
543  float fFaceU,
544  float fFaceV,
545  float fDiameter = 1.0f
546  );
550  void FillUsingUV(
551  class mudbox::Mesh *pMesh,
552  unsigned int iFaceIndex,
553  float fU,
554  float fV,
555  mudbox::SurfaceSmoother *pSS = NULL,
556  float fDiameter = 1.0f
557  );
558 
562  void FillNSided(
563  class mudbox::Mesh *pMesh,
564  unsigned int iFaceIndex,
565  const mudbox::Vector &vPosition,
566  float fDiameter = 1.0f
567  );
568 
571  void AddFlag( Flags eFlagToAdd ) const { m_iFlags |= eFlagToAdd; };
572 
573  mudbox::Base TangentBase( void ) const { return m_bTangent; };
574 
575 private:
576  bool RefineFaceIndex( void );
577  float RefineFaceCoordinates( const mudbox::SurfaceSmoother *pSS, float fTargetU, float fTargetV, unsigned int iSteps );
578 };
579 
588 {
590  Utilizer( void ) : m_pSampler( 0 ) {};
592  virtual QString MapTypeName( void ) const;
594  virtual void OnPhaseEvent( PhaseEventType eType );
596  virtual bool IsValid( void );
598  virtual void CleanUp( void );
601  virtual void Prepare( Layout *pLayout, class Sampler *pSampler );
602  // 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
603  // 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
604  // knows how to interpret the data stored in that area. This function must be thread safe.
605  virtual void StoreData(
606  const Data &cData,
607  const TargetLocation &cTarget,
608  const mudbox::SurfacePoint &cSource
609  );
611  virtual QWidget *UserInterface( void );
615  virtual Layout *CreateLayout( void );
616  virtual void Serialize( mudbox::Stream &s );
618  virtual mudbox::Layer *ResultLayer( void ) const;
619 
620  class Sampler *Sampler( void ) const { return m_pSampler; };
621  MapExtractor *Extractor( void ) const { return Sampler()->Extractor(); };
622  class Sampler *m_pSampler;
623 private:
624 
625  friend class Mapper;
626 };
627 
629 {
631  virtual void Prepare( void );
632  virtual void CleanUp( void );
633  virtual mudbox::Mesh *Target( void ) const;
634  virtual bool MapSurfacePoint( mudbox::SurfacePoint &pPoint, const class TargetLocation &vTarget );
635 };
636 
637 };
638 
639 #endif
640 
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.