mesh.h

Go to the documentation of this file.
00001 
00002 
00003 //**************************************************************************/
00004 
00005 // Copyright (c) 2008 Autodesk, Inc.
00006 
00007 // All rights reserved.
00008 
00009 //
00010 
00011 // Use of this software is subject to the terms of the Autodesk license
00012 
00013 // agreement provided at the time of installation or download, or which
00014 
00015 // otherwise accompanies this software in either electronic or hard copy form.
00016 
00017 //
00018 
00019 //**************************************************************************/
00020 
00021 // DESCRIPTION:
00022 
00023 // CREATED: October 2008
00024 
00025 //**************************************************************************/
00026 
00027 
00028 
00029 namespace mudbox {
00030 
00031 
00032 
00033 #ifndef MB_NORMALPRECISION
00034 
00035 #define MB_NORMALPRECISION 16
00036 
00037 #endif
00038 
00039 
00040 
00041 #ifndef MB_NORMALMAX
00042 
00043 #if MB_NORMALPRECISION == 16
00044 
00045 //typedef short int tnormal;
00046 
00047 //typedef qint64 tnormalv;
00048 
00049 #define MB_NORMALMAX 32767
00050 
00051 #else
00052 
00053 #if MB_NORMALPRECISION == 8
00054 
00055 //typedef char tnormal;
00056 
00057 //typedef int tnormalv;
00058 
00059 #define MB_NORMALMAX 127
00060 
00061 #else
00062 
00063 #error MB_NORMALPRECISION must be either 8 or 16
00064 
00065 #endif
00066 
00067 #endif
00068 
00069 #endif
00070 
00071 
00072 
00073 
00074 
00076 
00077 
00078 
00080 
00082 
00084 
00086 
00087 struct MBDLL_DECL Vertex
00088 
00089 {
00090 
00091     inline Vertex( void ) { m_iStrokeID = 0; m_iNormal = 0; };
00092 
00093 
00094 
00095     // data
00096 
00097     Vector m_vPos;
00098 
00099     mutable unsigned int m_iStrokeID;
00100 
00101     union
00102 
00103     { 
00104 
00105         tnormal m_vNormal[4];
00106 
00107         int m_iNormalIndex;
00108 
00109         tnormalv m_iNormal;
00110 
00111     };
00112 
00113 
00114 
00116 
00118 
00120 
00122 
00124 
00126 
00127     inline float Freeze( void ) const 
00128 
00129         { return ((float)(unsigned char)(m_vNormal[3]&0x7f))/0x7f; };
00130 
00131     
00132 
00134 
00136 
00138 
00140 
00142 
00144 
00145     inline void SetFreeze( float fFreeze ) 
00146 
00147         { m_vNormal[3] = (m_vNormal[3]&0xff80)+(unsigned int)(0x7f*fFreeze); };
00148 
00149     
00150 
00152 
00154 
00155     inline float Mask( void ) const 
00156 
00157         { return ((float)(unsigned char)(m_vNormal[3]>>8))/0xff; };
00158 
00159     
00160 
00162 
00164 
00165     inline void SetMask( float fMask ) 
00166 
00167         { m_vNormal[3] = (m_vNormal[3]&0xff)+(((unsigned int)(0xff*fMask))<<8); };
00168 
00169     
00170 
00172 
00173     inline bool IsSelected( void ) const { return (m_vNormal[3]&0x80) != 0; };
00174 
00175     
00176 
00178 
00179     inline void SetSelected( bool bSelected ) 
00180 
00181         { m_vNormal[3] = (m_vNormal[3]&0xff7f)+bSelected*0x80; };
00182 
00183 };
00184 
00185 
00186 
00188 
00189 
00190 
00192 
00194 
00196 
00198 
00200 
00202 
00203 struct MBDLL_DECL TC
00204 
00205 {
00206 
00207     TC( void ) {m_fU = m_fV = 0.0f;};
00208 
00209     TC( float fU, float fV ) { m_fU = fU; m_fV = fV; };
00210 
00211     inline bool operator ==( const TC &a ) const { return m_fU == a.m_fU && m_fV == a.m_fV; };
00212 
00213     inline bool operator !=( const TC &a ) const { return !operator==( a ); };
00214 
00215     inline TC operator +( const TC &a ) const { return TC( m_fU + a.m_fU, m_fV + a.m_fV ); };
00216 
00217     inline TC operator -( const TC &a ) const { return TC( m_fU - a.m_fU, m_fV - a.m_fV ); };
00218 
00219     inline TC operator *( float f ) const { return TC( m_fU * f, m_fV * f ); };
00220 
00221     inline TC operator /( float f ) const { return TC( m_fU / f, m_fV / f ); };
00222 
00223     inline TC &operator +=( const TC &a ) { m_fU += a.m_fU, m_fV += a.m_fV; return *this; };
00224 
00225     inline TC &operator -=( const TC &a ) { m_fU -= a.m_fU, m_fV -= a.m_fV; return *this; };
00226 
00227     inline TC &operator *=( float f ) { m_fU *= f, m_fV *= f; return *this; };
00228 
00229     inline TC &operator /=( float f ) { m_fU /= f, m_fV /= f; return *this; };
00230 
00231     inline operator bool( void ) const throw() { return m_fU || m_fV; };
00232 
00233     inline operator Vector( void ) const throw() { return Vector( m_fU, m_fV, 0 ); };
00234 
00235     inline operator const float *( void ) const { return &u; };
00236 
00237     void Normalize( void );
00238 
00239     float Length( void );
00240 
00241     union
00242 
00243     {
00244 
00245         float m_fU;
00246 
00247         float u;
00248 
00249     };
00250 
00251     union
00252 
00253     {
00254 
00255         float m_fV;
00256 
00257         float v;
00258 
00259     };
00260 
00261 };
00262 
00263 
00264 
00266 
00268 
00270 
00272 
00274 
00276 
00278 
00280 
00282 
00284 
00286 
00288 
00290 
00291 class MBDLL_DECL FaceEnumerator
00292 
00293 {
00294 
00295 public:
00296 
00298 
00299     virtual void Operator(
00300 
00301         class Mesh *pMesh,          
00302 
00303         unsigned int iFaceIndex     
00304 
00305         );
00306 
00307     
00308 
00310 
00312 
00313     virtual bool Tester(
00314 
00315         class Mesh *pMesh,          
00316 
00317         unsigned int iFaceIndex     
00318 
00319         );
00320 
00321 };
00322 
00323 
00324 
00325 
00326 
00328 
00329 
00330 
00332 
00334 
00336 
00338 
00340 
00342 
00344 
00346 
00348 
00350 
00352 
00353 
00354 
00355 class MBDLL_DECL VertexEnumerator
00356 
00357 {
00358 
00359 public:
00360 
00361     virtual void Operator(
00362 
00363         class Mesh *pMesh,          
00364 
00365         unsigned int iVertexIndex,  
00366 
00367         unsigned int iFaceIndex     
00368 
00370 
00371         );
00372 
00373         
00374 
00375     virtual bool Tester(
00376 
00377         class Mesh *pMesh,          
00378 
00379         unsigned int iVertexIndex,  
00380 
00381         unsigned int iFaceIndex     
00382 
00384 
00385         );
00386 
00387 };
00388 
00389 
00390 
00391 
00392 
00394 
00396 
00398 
00400 
00402 
00404 
00406 
00408 
00410 
00412 
00413 class MBDLL_DECL AdjacentVertexEnumerator
00414 
00415 {
00416 
00417 public:
00418 
00419     virtual void ProcessAdjacentVertex(
00420 
00421         unsigned int iVertexIndex,  
00422 
00423         unsigned int iFaceIndex     
00424 
00426 
00427         );
00428 
00429         
00430 
00431     bool m_bEdge;  
00432 
00434 
00435 };
00436 
00437 
00438 
00439 
00440 
00442 
00444 
00446 
00448 
00450 
00452 
00453 class MBDLL_DECL Mesh : public Topology
00454 
00455 {
00456 
00457     DECLARE_CLASS;
00458 
00459 
00460 
00461 protected:
00462 
00464 
00466 
00468 
00470 
00472 
00474 
00476 
00477     Mesh(
00478 
00479         FaceType eFaceType = typeQuadric    
00480 
00482 
00483         );
00484 
00485 
00486 
00487 public:
00488 
00490 
00491     virtual class Geometry *Geometry( void ) const;
00492 
00493 
00494 
00496 
00498 
00499     virtual class MeshRenderer *Renderer(
00500 
00501         float fLODLevel = 1.0f  
00502 
00503         );
00504 
00505 
00506 
00508 
00509     virtual void CopyTo( Mesh *pDestination ) const;
00510 
00511 
00512 
00514 
00515     virtual class Material *Material( void ) const;
00516 
00517 
00518 
00520 
00522 
00523     virtual class Material *MaterialOverride( void ) const;
00524 
00525 
00526 
00528 
00529     inline unsigned int VertexCount( void ) const { return m_iVertexCount; };
00530 
00531     
00532 
00534 
00535     void SetVertexCount(
00536 
00537         unsigned int iVertexCount   
00538 
00539         );
00540 
00541     
00542 
00544 
00545     inline unsigned int TCCount( void ) const { return m_pTCs.ItemCount(); };
00546 
00547 
00548 
00550 
00551     virtual void SetTCCount( 
00552 
00553         unsigned int iTCCount 
00554 
00555         );
00556 
00557     
00558 
00560 
00561     inline bool HasTC( void ) const { return (FaceComponents() & fcTCIndex) != 0 && TCCount() > 0; };
00562 
00563 
00564 
00566 
00567     virtual unsigned int UVlessPaintingStatus( void ) const;
00568 
00569 
00570 
00572 
00573     virtual void SetUVlessPaintingStatus(
00574 
00575         unsigned int iStatus    
00576 
00578 
00579         );
00580 
00581 
00582 
00584 
00586 
00588 
00590 
00591     inline const Vertex *VertexArray( void ) const { return &m_pVertices[0]; };
00592 
00593 
00594 
00596 
00597     inline const Vertex &VertexData(
00598 
00599         unsigned int iVertexIndex   
00600 
00601         ) const { return m_pVertices[iVertexIndex]; };
00602 
00603     
00604 
00606 
00607     inline Vertex &VertexData(
00608 
00609         unsigned int iVertexIndex   
00610 
00611         ) { return m_pVertices[iVertexIndex]; };
00612 
00613         
00614 
00616 
00617     inline const Vector &VertexPosition(
00618 
00619         unsigned int iVertexIndex   
00620 
00621         ) const { return m_pVertices[iVertexIndex].m_vPos; };
00622 
00623     
00624 
00626 
00627     inline Vector &VertexPosition(
00628 
00629         unsigned int iVertexIndex   
00630 
00631         ) { return m_pVertices[iVertexIndex].m_vPos; };
00632 
00633     
00634 
00636 
00638 
00640 
00641     virtual const Vector &VertexOriginalPosition(
00642 
00643         unsigned int iVertexIndex   
00644 
00645         ) const { return m_pVertices[iVertexIndex].m_vPos; };
00646 
00647     
00648 
00650 
00651     inline const TC &VertexTC(
00652 
00653         unsigned int iVertexTCIndex 
00654 
00655         ) const { return m_pTCs[iVertexTCIndex]; };
00656 
00657     
00658 
00660 
00661     inline Vector VertexNormal(
00662 
00663         unsigned int iVertexIndex   
00664 
00665         ) const { return Vector( m_pVertices[iVertexIndex].m_vNormal ); };
00666 
00667         
00668 
00670 
00671     inline unsigned int VertexStrokeID( unsigned int iVertexIndex ) const 
00672 
00673         { return m_pVertices[iVertexIndex].m_iStrokeID; };
00674 
00675     
00676 
00678 
00680 
00682 
00684 
00686 
00688 
00690 
00692 
00694 
00696 
00697     inline float VertexMask(
00698 
00699         unsigned int iVertexIndex   
00700 
00701         ) const { return m_pVertices[iVertexIndex].Mask(); };
00702 
00703     
00704 
00706 
00708 
00710 
00712 
00714 
00716 
00718 
00719     inline float VertexFreeze(
00720 
00721         unsigned int iVertexIndex   
00722 
00723         ) const { return m_pVertices[iVertexIndex].Freeze(); };
00724 
00725     
00726 
00728 
00730 
00731     virtual unsigned int FrozenVertexCount( void ) const;
00732 
00733 
00734 
00736 
00738 
00739     inline const tnormal *VertexNormalArray(
00740 
00741         unsigned int iVertexIndex   
00742 
00743         ) const { return m_pVertices[iVertexIndex].m_vNormal; };
00744 
00745     
00746 
00748 
00750 
00751     inline tnormalv VertexNormalValue(
00752 
00753         unsigned int iVertexIndex   
00754 
00755         ) const { return m_pVertices[iVertexIndex].m_iNormal; };
00756 
00757     
00758 
00759     // Do not use.  This obsolete method will be removed.
00760 
00761     inline unsigned int VertexNormalIndex( unsigned int iVertexIndex ) const 
00762 
00763         { return m_pVertices[iVertexIndex].m_iNormalIndex; };
00764 
00765     
00766 
00768 
00769     virtual AxisAlignedBoundingBox BoundingBox( void ) const;
00770 
00771 
00772 
00774 
00775     virtual AxisAlignedBoundingBox TCBoundingBox( void ) const;
00776 
00777 
00778 
00780 
00781     inline void SetVertexPosition(
00782 
00783         unsigned int iVertexIndex,  
00784 
00785         const Vector &vPosition     
00786 
00787         ) { m_pVertices[iVertexIndex].m_vPos = vPosition; };
00788 
00789         
00790 
00792 
00793     inline void AddVertexPosition(
00794 
00795         unsigned int iVertexIndex,  
00796 
00797         const Vector &vPosition     
00798 
00799         )
00800 
00801     { m_pVertices[iVertexIndex].m_vPos += vPosition; };
00802 
00803     
00804 
00806 
00807     inline void SetVertexNormal( unsigned int iVertexIndex, int *pNormal)
00808 
00809     {
00810 
00811         m_pVertices[iVertexIndex].m_vNormal[0] = tnormal(pNormal[3]);
00812 
00813         m_pVertices[iVertexIndex].m_vNormal[1] = tnormal(pNormal[2]);
00814 
00815         m_pVertices[iVertexIndex].m_vNormal[2] = tnormal(pNormal[1]);
00816 
00817     };
00818 
00819     
00820 
00822 
00823     inline void SetVertexNormal(
00824 
00825         unsigned int iVertexIndex,  
00826 
00827         const Vector &vNormal       
00828 
00829         )
00830 
00831         {
00832 
00833             m_pVertices[iVertexIndex].m_vNormal[0] = tnormal(vNormal.x * MB_NORMALMAX);
00834 
00835             m_pVertices[iVertexIndex].m_vNormal[1] = tnormal(vNormal.y * MB_NORMALMAX);
00836 
00837             m_pVertices[iVertexIndex].m_vNormal[2] = tnormal(vNormal.z * MB_NORMALMAX);
00838 
00839         };
00840 
00841         
00842 
00843     // Adds vNormal to the current normal of the vertex with the given index.
00844 
00845     //void AddVertexNormal(
00846 
00847     //  unsigned int iVertexIndex,  ///< [in] index of the vertex
00848 
00849     //  const Vector &vNormal       ///< [in] x,y,z offset to be added to the normal
00850 
00851     //  );
00852 
00853     
00854 
00856 
00857     inline void SetVertexNormal( unsigned int iVertexIndex, int iNormal )
00858 
00859         { m_pVertices[iVertexIndex].m_iNormalIndex = iNormal; };
00860 
00861     
00862 
00864 
00865     virtual void SetVertexFreeze(
00866 
00867         unsigned int iVertexIndex,  
00868 
00869         unsigned int iFaceIndex,    
00870 
00871         float fFreeze               
00872 
00874 
00875         );
00876 
00877 
00878 
00880 
00881     virtual void SetFreezeValues(
00882 
00883         Store<float> &aNewFreeze    
00884 
00885         );
00886 
00887 
00888 
00890 
00891     void SetVertexMask( unsigned int iVertexIndex, unsigned int iFaceIndex, float fFMask );
00892 
00893     
00894 
00896 
00897     inline void SetVertexStrokeID( unsigned int iVertexIndex, unsigned int iStrokeID ) const 
00898 
00899         { m_pVertices[iVertexIndex].m_iStrokeID = iStrokeID; };
00900 
00901 
00902 
00904 
00906 
00908 
00910 
00912 
00914 
00915     virtual void MarkVertex(
00916 
00917         unsigned int iVertexIndex   
00918 
00919         );
00920 
00921         
00922 
00924 
00926 
00928 
00930 
00932 
00934 
00935     virtual bool IsVertexMarked(
00936 
00937         unsigned int iVertexIndex   
00938 
00939         );
00940 
00941     
00942 
00944 
00946 
00948 
00950 
00952 
00954 
00956 
00957     virtual void ClearVertexMarks( void );
00958 
00959 
00960 
00962 
00964 
00966 
00968 
00970 
00972 
00974 
00976 
00978 
00979     virtual unsigned int VertexExternalIndex( 
00980 
00981         unsigned int iVertexIndex 
00982 
00983         ) const; 
00984 
00985 
00986 
00988 
00990 
00991     virtual void SetVertexExternalIndex( 
00992 
00993         unsigned int iVertexIndex, 
00994 
00995         unsigned int iExternalVertexIndex 
00996 
00997         );
00998 
00999     
01000 
01002 
01004 
01005     inline const Vector &TriangleVertexPosition(
01006 
01007         unsigned int iTriangleIndex,    
01008 
01009         unsigned int iCornerIndex       
01010 
01011         ) const { return VertexPosition( TriangleIndex( iTriangleIndex, iCornerIndex ) ); };
01012 
01013 
01014 
01016 
01017     inline const Vector &QuadVertexPosition(
01018 
01019         unsigned int iQuadIndex,    
01020 
01021         unsigned int iCornerIndex   
01022 
01023         ) const { return VertexPosition( QuadIndex( iQuadIndex, iCornerIndex ) ); };
01024 
01025         
01026 
01028 
01030 
01031     const TC &TriangleVertexTC(
01032 
01033         unsigned int iTriangleIndex,    
01034 
01035         unsigned int iCornerIndex       
01036 
01037         ) const { return VertexTC( TriangleTCI( iTriangleIndex, iCornerIndex ) ); };
01038 
01039         
01040 
01042 
01043     const TC &QuadVertexTC(
01044 
01045         unsigned int iQuadIndex,    
01046 
01047         unsigned int iCornerIndex   
01048 
01049         ) const { return VertexTC( QuadTCI( iQuadIndex, iCornerIndex ) ); };
01050 
01051 
01052 
01054 
01055     inline Vector TriangleVertexNormal(
01056 
01057         unsigned int iTriangleIndex,    
01058 
01059         unsigned int iCornerIndex       
01060 
01061         ) const { return VertexNormal( TriangleIndex( iTriangleIndex, iCornerIndex ) ); };
01062 
01063 
01064 
01066 
01067     inline Vector QuadVertexNormal(
01068 
01069         unsigned int iQuadIndex,    
01070 
01071         unsigned int iCornerIndex   
01072 
01073         ) const { return VertexNormal( QuadIndex( iQuadIndex, iCornerIndex ) ); };
01074 
01075 
01076 
01078 
01079     inline float TriangleVertexFreeze(
01080 
01081         unsigned int iTriangleIndex,    
01082 
01083         unsigned int iCornerIndex       
01084 
01085         ) const { return VertexFreeze( TriangleIndex( iTriangleIndex, iCornerIndex ) ); };
01086 
01087 
01088 
01090 
01092 
01093     inline float QuadVertexFreeze(
01094 
01095         unsigned int iQuadIndex,    
01096 
01097         unsigned int iCornerIndex   
01098 
01099         ) const { return VertexFreeze( QuadIndex( iQuadIndex, iCornerIndex ) ); };
01100 
01101 
01102 
01104 
01105     inline const tnormal *TriangleVertexNormalArray(
01106 
01107         unsigned int iTriangleIndex,    
01108 
01109         unsigned int iCornerIndex       
01110 
01111         ) const { return VertexNormalArray( TriangleIndex( iTriangleIndex, iCornerIndex ) ); };
01112 
01113 
01114 
01116 
01117     inline const tnormal *QuadVertexNormalArray(
01118 
01119         unsigned int iQuadIndex,    
01120 
01121         unsigned int iCornerIndex   
01122 
01123         ) const { return VertexNormalArray( QuadIndex( iQuadIndex, iCornerIndex ) ); };
01124 
01125 
01126 
01128 
01129     inline tnormalv TriangleVertexNormalValue(
01130 
01131         unsigned int iTriangleIndex,    
01132 
01133         unsigned int iCornerIndex       
01134 
01135         ) const { return VertexNormalValue( TriangleIndex( iTriangleIndex, iCornerIndex ) ); };
01136 
01137 
01138 
01140 
01141     inline tnormalv QuadVertexNormalValue(
01142 
01143         unsigned int iQuadIndex,    
01144 
01145         unsigned int iCornerIndex   
01146 
01147         ) const { return VertexNormalValue( QuadIndex( iQuadIndex, iCornerIndex ) ); };
01148 
01149 
01150 
01152 
01154 
01156 
01158 
01160 
01162 
01164 
01166 
01168 
01170 
01172 
01173     virtual void EnumerateFaces(
01174 
01175         unsigned int iFaceIndex,        
01176 
01177         FaceEnumerator *pEnumerator,    
01178 
01179         bool bSymmetry = false          
01180 
01182 
01183         );
01184 
01185 
01186 
01188 
01190 
01192 
01194 
01196 
01197     virtual void EnumerateNearestFaces(
01198 
01199         unsigned int iFaceIndex,        
01200 
01201         FaceEnumerator *pOperation      
01202 
01203         );
01204 
01205 
01206 
01208 
01210 
01212 
01214 
01215     virtual void EnumerateVertices(
01216 
01217         unsigned int iFaceIndex,        
01218 
01219         VertexEnumerator *pEnumerator   
01220 
01221         );
01222 
01223 
01224 
01226 
01228 
01230 
01232 
01234 
01235     unsigned int EnumerateAdjacentVertices(
01236 
01237         AdjacentVertexEnumerator *pEnumerator,  
01238 
01239         unsigned int iVertexIndex,              
01240 
01241         unsigned int iFaceIndex                 
01242 
01243         );
01244 
01245 
01246 
01248 
01249     virtual int MeshVersion( void ) const;
01250 
01251 
01252 
01254 
01255     virtual void SmoothTextureCoordinates( float fStrength);
01256 
01257 
01258 
01260 
01261     virtual void RecalculateNormals(
01262 
01263         bool bKeep = false  
01264 
01265         );
01266 
01267 
01268 
01270 
01271     virtual void RecalculateAdjacency( 
01272 
01273         bool bForce = true  
01274 
01275         );
01276 
01277 
01278 
01280 
01281     virtual unsigned int CollectionID( void ) const;
01282 
01283 
01284 
01286 
01287     virtual void IncreaseCollectionID( void );
01288 
01289 
01290 
01292 
01293     virtual bool IsSelected( void );
01294 
01295 
01296 
01298 
01299     virtual void SetSelected( bool bOn = true );
01300 
01301 
01302 
01304 
01305     virtual class LayerMeshData *AddLayer( void );
01306 
01307 
01308 
01310 
01312 
01313     virtual void RemoveLayer( 
01314 
01315         LayerMeshData* pLayer 
01316 
01317         );
01318 
01319 
01320 
01322 
01323     virtual class LayerMeshData *ActiveLayer( void ) const;
01324 
01325 
01326 
01328 
01329     virtual bool IsActiveLevel( void ) const;
01330 
01331 
01332 
01334 
01336 
01338 
01340 
01342 
01344 
01345     virtual bool Lock( 
01346 
01347         class MeshUnlocker *pUnlocker = NULL 
01348 
01350 
01351         );
01352 
01353 
01354 
01356 
01358 
01360 
01362 
01364 
01365     virtual bool Unlock( void );
01366 
01367 
01368 
01370 
01371     virtual bool IsLocked( void );
01372 
01373 
01374 
01376 
01378 
01380 
01381     class MeshChange *StartChange( void );
01382 
01383 
01384 
01386 
01387     virtual bool IsNSided( void );
01388 
01389 
01390 
01392 
01394 
01395     virtual bool HasExpandedTCs( void ) const;
01396 
01398 
01399     virtual void CreateExpandedTCs( void );
01400 
01402 
01403     virtual TC &ExpandedTC( unsigned int index );
01404 
01406 
01407     virtual bool SupportsTangentMirror() const;
01408 
01410 
01411     virtual unsigned int TangentMirroredFaceIndex( unsigned int iFaceIndex ) const;
01412 
01413 
01414 
01415     Store<TC> m_pTCs;
01416 
01417 
01418 
01420 
01421     aevent Modified;
01422 
01423 
01424 
01425 protected:
01426 
01427     Store<Vertex> m_pVertices;
01428 
01429     unsigned int m_iVertexCount;
01430 
01431 };
01432 
01433 
01434 
01436 
01437 class MBDLL_DECL MeshFreezer : public Node
01438 
01439 {
01440 
01441     DECLARE_CLASS;
01442 
01443 public:
01444 
01445     virtual void Freeze( Mesh *pMesh, Store<float> aFreezeData, bool bMerge = false );
01446 
01447 };
01448 
01449 
01450 
01452 
01453 class MBDLL_DECL MeshSelector : public Node
01454 
01455 {
01456 
01457     DECLARE_CLASS;
01458 
01459 public:
01460 
01461     virtual void Select( Mesh *pMesh, bool bState, const Store<unsigned int> &aSelectionData, bool bMerge = false );
01462 
01463 };
01464 
01465 
01466 
01468 
01470 
01472 
01474 
01476 
01478 
01480 
01482 
01484 
01486 
01488 
01490 
01492 
01494 
01496 
01498 
01500 
01502 
01504 
01506 
01508 
01510 
01512 
01514 
01516 
01518 
01519 class MBDLL_DECL TangentGenerator : public TreeNode
01520 
01521 {
01522 
01523     DECLARE_CLASS;
01524 
01525 public:
01526 
01528 
01529     virtual Vector ConvertToTangent(
01530 
01531         unsigned int iVertexIndex,  
01532 
01533         const Vector &vVector       
01534 
01535         ) const;
01536 
01537     
01538 
01540 
01541     virtual Vector ConvertToObject(
01542 
01543         unsigned int iVertexIndex,  
01544 
01545         const Vector &vVector       
01546 
01547         ) const;
01548 
01549         
01550 
01552 
01553     virtual Base LocalBase(
01554 
01555         unsigned int iFaceIndex,    
01556 
01557         unsigned int iCornerIndex   
01558 
01559         );
01560 
01561     
01562 
01564 
01565     virtual void SetNormalization(
01566 
01567         bool bNormalize     
01568 
01569         );
01570 
01571 };
01572 
01573 
01574 
01575 
01576 
01578 
01579 
01580 
01582 
01584 
01586 
01588 
01589 struct MBDLL_DECL SurfacePoint
01590 
01591 {
01592 
01593     class Mesh *m_pMesh;            
01594 
01595     unsigned int m_iFaceIndex;  
01596 
01597     float m_fRelativeRange;     
01598 
01599     Vector m_vLocalPosition;    
01600 
01601     Vector m_vLocalNormal;      
01602 
01603     bool m_bSide;               
01604 
01605     TangentGenerator *m_pTG;    
01606 
01607 
01608 
01610 
01611     SurfacePoint( void );
01612 
01613     
01614 
01616 
01617     SurfacePoint(
01618 
01619         class Mesh *pMesh,          
01620 
01621         unsigned int iVertexIndex,  
01622 
01623         unsigned int iFaceIndex     
01624 
01625         );
01626 
01627         
01628 
01630 
01631     class Mesh *Mesh( void ) const;
01632 
01633     
01634 
01636 
01637     unsigned int FaceIndex( void ) const;
01638 
01639         
01640 
01642 
01643     Vector LocalPosition( void ) const;
01644 
01645     
01646 
01648 
01649     Vector WorldPosition( void ) const;
01650 
01651     
01652 
01654 
01655     Vector LocalNormal( void ) const;
01656 
01657     
01658 
01660 
01661     Vector WorldNormal( void ) const;
01662 
01663 
01664 
01666 
01667     TC TextureCoordinate( void ) const;
01668 
01669     
01670 
01672 
01673     Base TangentBase( void ) const;
01674 
01675 
01676 
01678 
01679     Vector FaceCoordinates( void ) const;
01680 
01681 
01682 
01684 
01686 
01688 
01690 
01692 
01694 
01695     bool Fill(
01696 
01697         class Mesh *pMesh,  
01698 
01699         unsigned int iFaceIndex,    
01700 
01701         const Vector &vStart,       
01702 
01703         const Vector &vEnd,         
01704 
01705         bool bTwoSide = false,      
01706 
01707         bool bOriginalPosition = false
01708 
01709         );
01710 
01711 
01712 
01714 
01716 
01718 
01720 
01721     void Fill(
01722 
01723         class Mesh *pMesh,          
01724 
01725         unsigned int iFaceIndex,    
01726 
01727         float fFaceU,                       
01728 
01729         float fFaceV                        
01730 
01731         );
01732 
01733 
01734 
01736 
01738 
01740 
01742 
01743     void Fill(
01744 
01745         class Mesh *pMesh,          
01746 
01747         unsigned int iFaceIndex,        
01748 
01749         const Vector &vLocalPosition,   
01750 
01751         bool bRecalculatePosition   
01752 
01753         );
01754 
01755     
01756 
01758 
01760 
01762 
01764 
01766 
01767     void SetTangentGenerator( 
01768 
01769                              TangentGenerator *pGenerator   
01770 
01771                              );
01772 
01773 
01774 
01775     mutable Vector m_vFaceCoordinates;
01776 
01777 };
01778 
01779 
01780 
01782 
01784 
01786 
01788 
01790 
01792 
01794 
01796 
01798 
01800 
01802 
01804 
01806 
01808 
01810 
01811 class MBDLL_DECL Picker : public TreeNode
01812 
01813 {
01814 
01815     DECLARE_CLASS;
01816 
01817 
01818 
01819 public:
01820 
01821     virtual void SetMesh(
01822 
01823         Mesh *m_pMesh       
01824 
01825         );
01826 
01827     
01828 
01829     virtual bool Pick(
01830 
01831         const Vector &vLocalStart,  
01832 
01833         const Vector &vLocalEnd,    
01834 
01835         bool bBothSides,            
01836 
01837         SurfacePoint &cResult,      
01838 
01839         float fTarget = 0.5f        
01840 
01841         );
01842 
01843 };
01844 
01845 
01846 
01848 
01850 
01852 
01854 
01856 
01858 
01860 
01862 
01864 
01866 
01868 
01870 
01872 
01874 
01875 class MBDLL_DECL ScreenSpacePicker : public Node
01876 
01877 {
01878 
01879     DECLARE_CLASS;
01880 
01881 
01882 
01883 public:
01884 
01886 
01887     virtual void SetFramebufferSize(
01888 
01889         unsigned int iWidth,    
01890 
01891         unsigned int iHeight    
01892 
01893         );
01894 
01895     
01896 
01898 
01899     virtual bool Pick(
01900 
01901         const class Camera *pCamera,    
01902 
01903         float fXPosition,               
01904 
01905         float fYPosition,               
01906 
01907         SurfacePoint &sResult           
01908 
01909         );
01910 
01911 };
01912 
01913 
01914 
01916 
01918 
01920 
01922 
01924 
01926 
01928 
01930 
01932 
01934 
01936 
01938 
01940 
01942 
01944 
01946 
01948 
01950 
01952 
01954 
01956 
01958 
01960 
01962 
01964 
01965 class MBDLL_DECL MeshGrid : public TreeNode
01966 
01967 {
01968 
01969     DECLARE_CLASS;
01970 
01971 
01972 
01973 public:
01974 
01976 
01977     virtual unsigned int MeshGridCount( void ) const;
01978 
01979     
01980 
01982 
01984 
01985     virtual unsigned int MeshGridLevel( 
01986 
01987         unsigned int iMeshGridIndex 
01988 
01989         ) const;
01990 
01991     
01992 
01994 
01996 
01997     virtual unsigned int MeshGridFaceIndex( 
01998 
01999         unsigned int iMeshGridIndex, 
02000 
02001         unsigned int iX,            
02002 
02003         unsigned int iY         
02004 
02005         ) const;
02006 
02007     
02008 
02010 
02011     virtual unsigned int MeshGridVertexIndex( 
02012 
02013         unsigned int iMeshGridIndex, 
02014 
02015         unsigned int iX,            
02016 
02017         unsigned int iY         
02018 
02019         ) const;
02020 
02021     
02022 
02024 
02025     virtual unsigned int MeshGridTCIndex( 
02026 
02027         unsigned int iMeshGridIndex, 
02028 
02029         unsigned int iX,            
02030 
02031         unsigned int iY         
02032 
02033         ) const;
02034 
02035     
02036 
02038 
02039     virtual unsigned int MeshGridIndexByFaceIndex( 
02040 
02041         unsigned int iFaceIndex     
02042 
02043         ) const;
02044 
02045 };
02046 
02047 
02048 
02050 
02052 
02054 
02056 
02058 
02060 
02062 
02064 
02066 
02068 
02070 
02072 
02074 
02076 
02078 
02080 
02082 
02084 
02085 class MBDLL_DECL SurfaceSmoother : public TreeNode
02086 
02087 {
02088 
02089     DECLARE_CLASS;
02090 
02091 
02092 
02093 public:
02094 
02096 
02097     virtual Vector SmoothPosition( 
02098 
02099         unsigned int iFaceIndex, 
02100 
02101         double fUCoordinate, 
02102 
02103         double fVCoordinate 
02104 
02105         ) const;
02106 
02107     
02108 
02110 
02111     virtual Vector SmoothNormal( 
02112 
02113         unsigned int iFaceIndex, 
02114 
02115         double fUCoordinate, 
02116 
02117         double fVCoordinate 
02118 
02119         ) const;
02120 
02121     
02122 
02124 
02125     virtual Vector SmoothTextureCoordinate( 
02126 
02127         unsigned int iFaceIndex, 
02128 
02129         double fUCoordinate, 
02130 
02131         double fVCoordinate 
02132 
02133         ) const;
02134 
02135 
02136 
02138 
02139     virtual Base SmoothTangent( 
02140 
02141         unsigned int iFaceIndex, 
02142 
02143         double fUCoordinate, 
02144 
02145         double fVCoordinate 
02146 
02147         ) const;
02148 
02149 };
02150 
02151 
02152 
02154 
02156 
02158 
02160 
02162 
02164 
02165 class MBDLL_DECL MeshChange : public Node
02166 
02167 {
02168 
02169     MeshChange( Mesh *m_pMesh );
02170 
02171 
02172 
02173 public:
02174 
02176 
02177     struct VertexChange
02178 
02179     {
02180 
02182 
02183         Vector m_vPosition;
02184 
02186 
02187         unsigned int m_iID;
02188 
02190 
02191         union
02192 
02193         {
02194 
02195             tnormalv m_iNormal;
02196 
02197             tnormal m_vNormal[4];
02198 
02199         };
02200 
02202 
02203         float m_fData;
02204 
02206 
02207         unsigned int m_iVertexIndex;
02208 
02210 
02211         unsigned int m_iFaceIndex;
02212 
02214 
02215         unsigned int m_iLayerVertexIndex;
02216 
02217     };
02218 
02219     
02220 
02222 
02223     inline const Vector &OriginalPosition( 
02224 
02225         unsigned int iVertexIndex 
02226 
02227         ) const
02228 
02229     {
02230 
02231         Vertex &v = m_pMesh->VertexData( iVertexIndex );
02232 
02233         if ( v.m_iStrokeID < m_iVertexCount && m_pArray[v.m_iStrokeID].m_iVertexIndex == iVertexIndex )
02234 
02235             return m_pArray[v.m_iStrokeID].m_vPosition;
02236 
02237         else
02238 
02239             return v.m_vPos;
02240 
02241     };
02242 
02243     
02244 
02246 
02247     inline Vector OriginalNormal( 
02248 
02249         unsigned int iVertexIndex 
02250 
02251         ) const
02252 
02253     {
02254 
02255         Vertex &v = m_pMesh->VertexData( iVertexIndex );
02256 
02257         if ( v.m_iStrokeID < m_iVertexCount && m_pArray[v.m_iStrokeID].m_iVertexIndex == iVertexIndex )
02258 
02259             return m_pArray[v.m_iStrokeID].m_vNormal;
02260 
02261         else
02262 
02263             return v.m_vNormal;
02264 
02265     };
02266 
02267     
02268 
02269 
02270 
02271     // this function is not being inlined as it is too big, si it is split into a small inlined part,
02272 
02273     // and the larger not inlined part...
02274 
02275     private:
02276 
02277     VertexChange &Add_uncached(     // see arg list of Add just below....
02278 
02279         unsigned int  iVertexIndex, 
02280 
02281         unsigned int  iFaceIndex,
02282 
02283         Vertex       &v, 
02284 
02285         bool          bPrecalculateLayerIndex = false );
02286 
02287 
02288 
02289     public:
02290 
02292 
02294 
02295     inline VertexChange &Add( 
02296 
02297         unsigned int iVertexIndex, 
02298 
02299         unsigned int iFaceIndex,   
02300 
02301         bool bPrecalculateLayerIndex = false 
02302 
02304 
02305         )
02306 
02307     {
02308 
02309         Vertex &v = m_pMesh->VertexData( iVertexIndex );
02310 
02311         if ( v.m_iStrokeID < m_iVertexCount && 
02312 
02313              m_pArray[v.m_iStrokeID].m_iVertexIndex == iVertexIndex )
02314 
02315             return m_pArray[v.m_iStrokeID]; // 80% of the time it hits this...
02316 
02317         else 
02318 
02319             return Add_uncached(iVertexIndex, iFaceIndex, v, bPrecalculateLayerIndex);
02320 
02321     };
02322 
02323 
02324 
02326 
02327     void Finish( 
02328 
02329         bool bUndo = true,  
02330 
02332 
02333         bool bMerge = false 
02334 
02335         );
02336 
02337 
02338 
02339 private:
02340 
02341     Mesh *m_pMesh;
02342 
02343 
02344 
02345     Store<VertexChange> &m_pArray;
02346 
02347     unsigned int &m_iVertexCount;
02348 
02349 
02350 
02351     friend class Mesh;
02352 
02353 };
02354 
02355 
02356 
02358 
02360 
02362 
02364 
02366 
02367 class MBDLL_DECL MeshUnlocker
02368 
02369 {
02370 
02371 public:
02372 
02374 
02376 
02378 
02380 
02381     virtual bool Unlock( 
02382 
02383         Mesh *pMesh 
02384 
02385         );
02386 
02387 };
02388 
02389 
02390 
02391 }; // end of namespace mudbox
02392 
02393 
02394 
02395 
02396