viewport.h

Go to the documentation of this file.
00001 
00002 //**************************************************************************/
00003 // Copyright (c) 2008 Autodesk, Inc.
00004 // All rights reserved.
00005 //
00006 // Use of this software is subject to the terms of the Autodesk license
00007 // agreement provided at the time of installation or download, or which
00008 // otherwise accompanies this software in either electronic or hard copy form.
00009 //
00010 //**************************************************************************/
00011 // DESCRIPTION:
00012 // CREATED: October 2008
00013 //**************************************************************************/
00014 
00015 namespace mudbox {
00016 
00017 class ViewPortFilter;
00018 
00020 struct ViewPortState
00021 {
00022     Texture *m_pColor;
00023     Texture *m_pDepth;
00024     Texture *m_pPosition;
00025     Texture *m_pNormal;
00026     Texture *m_pLinearDepth;
00027     Texture *m_pFaceNormal;
00028     bool m_bHDRNeeded;
00029 };
00030 
00037 class MBDLL_DECL ViewPortFilter : public Layer
00038 {
00039     DECLARE_CLASS;
00040 public:
00041 
00046     typedef int RequirementValue;
00047     enum
00048     {
00049         eNone = 0,
00050         eColor = 1,
00051         eHDR = 2,
00052         eDepth24 = 4,
00053 //      ePosition16 = 8, // not implemented
00054         eNormal16 = 16,
00055         ePosition32 = 32,
00056 //      eNormal32 = 64, // not implemented
00057         eNormalDepth16 = 128,
00058 //      eNormalDepth32 = 256, // not implemented
00059         eLinearDepth = 512,
00060         eFaceNormal = 1024,
00061     };
00062 
00064     virtual QString StringID( const ClassDesc *pClass = 0 ) const;
00065 
00067     virtual QString DisplayName( void ) const;
00068 
00070     virtual void Initialize(void);
00071 
00078     virtual RequirementValue Requirement( void ) const;
00079 
00087     virtual void Process(
00088         ViewPortState &sState   
00089         );
00090 
00092     virtual float Transparency( void ) const;
00093 
00095     virtual void SetTransparency(float fTransparency);
00096 
00098     virtual Layer *Children( void ) const;
00099 
00101     virtual Layer *Next( void ) const;
00102 
00104     virtual Layer *Prev( void ) const;
00105 
00107     virtual class LayerContainer *Container( void ) const;
00108 
00110     void SetVisible(
00111         bool bVisible  
00112         );
00113 
00128     virtual void LockCalibration(
00129         bool bLock  
00130         );
00131 
00133     bool CalibrationLocked(void);
00134 
00136     class ViewPort *m_pViewPort;
00137 
00138 protected:
00139     bool m_bCalibrationLocked;
00140 };
00141 
00142 
00147 class MBDLL_DECL ViewPort : public LayerContainer
00148 {
00149     DECLARE_CLASS;
00150 
00151 protected:
00160     ViewPort( void );
00161 public:
00162 
00164     virtual unsigned int FilterCount( void ) const;
00165 
00167     virtual ViewPortFilter *Filter(
00168         unsigned int iIndex 
00169         ) const;
00170 
00172     virtual void AddFilter(
00173         ViewPortFilter *pFilter 
00174         );
00175 
00177     virtual void RemoveFilter(
00178         unsigned int iIndex 
00179         );
00180 
00182     void LockFilterCalibration(
00183         bool bLocked 
00184         );
00185 
00192     virtual void SaveScreenshot(
00193         const QString &sFileName    
00194         ) const;
00195 
00197     virtual int Width( void );
00198 
00200     virtual int Height( void );
00201 
00203     class ImagePlaneInterface *ActiveImagePlane();
00204 
00206     virtual float CursorXPosition( void ) const;
00207 
00209     virtual float CursorYPosition( void ) const;
00210 
00212     const SurfacePoint *CursorSurfacePoint( 
00213          bool bMirrored = false 
00214          ) const;
00215 
00217     unsigned int LayerCount( void ) const;
00218 
00220     class Layer *Layer(
00221         unsigned int iLayerIndex    
00222         ) const;
00223 
00225     void UnlinkLayer(
00226         class Layer *pLayer 
00227         );
00228 
00230     class Layer *CreateLayer( void );
00231 
00233     void AddLayer(
00234         class Layer *pLayer 
00235         );
00236 
00238     class Layer *ActiveLayer( void ) const;
00239 
00241     void SetActiveLayer(
00242         class Layer *pLayer 
00243         );
00244 
00246     ViewPortFilter::RequirementValue ViewPortFilterRequirements( void ) const;
00247 
00249     enum RedrawType
00250     {
00251         eFull, 
00252         eArea, 
00253         eOverlayOnly 
00254     };
00255 
00257     void Redraw( 
00258         RedrawType eType = eFull, 
00259         float fXStart = 0, 
00260         float fYStart = 0, 
00261         float fXEnd = 0, 
00262         float fYEnd = 0 
00263         );
00264 
00266     enum SceneRenderMode {
00267         srmNormal = 0,          
00268         srmFlatTexturesOnBlack, 
00269         srmFlatTexturesOnWhite, 
00270         srmFlatNoTextures,      
00271         srmNoTextures           
00272     };
00273 
00288     Image *RenderScene(
00289         const QString &sChannel, 
00290         int  iWidth,        
00291         int  iHeight,       
00292         SceneRenderMode renderMode, 
00293         enum Image::Format fmt = Image::e8integer, 
00294         bool bTiledImg = true 
00295         );
00296 
00311     Image *RenderScene(
00312         int  iWidth,        
00313         int  iHeight,       
00314         SceneRenderMode renderMode, 
00315         enum Image::Format fmt = Image::e8integer, 
00316         bool bTiledImg = true 
00317         );
00318 
00330     Image *RenderScene(
00331         int  iWidth,          
00332         int  iHeight,         
00333         enum Image::Format fmt = Image::e8integer, 
00334         bool bTiledImg = true 
00335         ) const;
00336 
00338     virtual struct ViewPortState ViewPortState( void );
00339 
00341     virtual bool ShowCurves( void ) const;
00342 
00344     static aevent PreRenderEvent;
00345     
00347     static aevent FrameEvent;
00348     
00350     static aevent EndRenderEvent;
00351     
00354     static aevent PostRenderEvent;
00355 
00357     static aevent MouseMoveEvent;
00358 
00360     static aevent LeftMouseButtonPressEvent;
00361 
00363     static aevent LeftMouseButtonReleaseEvent;
00364 
00366     static aevent ContextMenuEvent;
00367 
00370     static aevent SceneRenderEvent;
00371 
00373     static aevent ViewportResizeEvent;
00374 
00375 protected:
00376     virtual Image* RenderRegion( ImgTile bounds, ImgTile region, enum Image::Format eFormat, bool bTiled ) const;
00377 };
00378 
00379 }; // end of namespace mudbox