source file REDIViewpointRenderList.h

Go to the documentation of this file.

#ifndef RED_IVIEWPOINTRENDERLIST_H
#define RED_IVIEWPOINTRENDERLIST_H

//************************************************************************************************************
// Copyright (c) 2005 Redway3D. All rights reserved. Redway3D is a registered trademark. Any reproduction and /
// or utilization of any material from this document without Redway3D?s express authorization are prohibited.
//************************************************************************************************************

#include "REDIImage.h"
#include "REDIMeshShape.h"
#include "REDSTL.h"
#include "REDState.h"
#include "REDWindowRenderInfo.h"


//******************************************************************************
//*** RED::IViewpointRenderList defines ****************************************
//******************************************************************************

#define RED_VRL_BACKGROUND_2D_MATERIAL          "VRL_Background_2D_Material"
#define RED_VRL_BACKGROUND_CUBE_MATERIAL        "VRL_Background_CUBE_Material"


//******************************************************************************
//*** RED::IViewpointRenderList interface **************************************
//******************************************************************************

namespace RED
{
  class LayerSet;
  class Matrix;
  class ISoftRayContext;
  class ISoftRenderingContext;
  class ISoftBucket;
  
  
  // IViewpointRenderList types:
  // ---------------------------
  
  enum VRL_SORT { VST_FRONT = 0,
                  VST_SCENE = 1,
                  VST_BACK  = 2 };
  
  
  enum VRL_SIZEPOS { VSP_ANCHOR_FIXED              = 1,
                     VSP_ANCHOR_STRETCHED          = 2,
                     VSP_SIZE_FIXED                = 4,
                     VSP_SIZE_STRETCHED            = 8,
                     VSP_SIZE_STRETCHED_AUTO_RATIO = 16 };
  
  
  typedef RED_RC ( *SOFT_PIXEL_ANALYSIS_CALLBACK )( bool&                             oNext,
                                                    const RED::ISoftRayContext&       iRayContext,
                                                    const RED::ISoftRenderingContext& iRenderingContext,
                                                    void*                             iUser );
  
    
  typedef RED_RC (*SOFT_BUCKET_CALLBACK)( const RED::Object*  iViewpoint,
                                          RED::ISoftBucket*   ioISoftBucket,
                                          void*               ioUserData );
  
  
  typedef bool (*SOFT_RAY_PROCESSING_INTERSECTION_CALLBACK)( double&              oTHit,
                                                             double&              oTHit1,
                                                             double&              oTHit2,
                                                             const double         iE[3],
                                                             const double         iP[3],
                                                             double               iTIn,
                                                             const RED::LayerSet* iLayerSet,
                                                             int                  iNumThread,
                                                             void*                ioUserData );
  
  
  typedef RED_RC (*SOFT_RAY_PROCESSING_SHADING_CALLBACK)( double          oDataChannel[ RED::MCL_SIZE ][ 4 ],
                                                          double          oGeoNormal[4],
                                                          RED::Object*&   oMaterial,
                                                          RED::LayerSet*& oLayerSet,
                                                          double          iTHit,
                                                          double          iTHit1,
                                                          double          iTHit2,
                                                          const double    iE[3],
                                                          const double    iP[3],
                                                          int             iNumThread,
                                                          void*           ioUserData );
  
  
  // IViewpointRenderList interface:
  // -------------------------------
  
  class REDFullExp IViewpointRenderList : public IREDObject
  {
    public:

    // Typing information:
    // -------------------
    
    SET_CID( CID_class_REDIViewpointRenderList );


    // Parameters of the VRL:
    // ----------------------
    
    virtual RED_RC GetSize( int &oWidth,
                            int &oHeight,
                            int  iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetSize( int               iWidth,
                            int               iHeight,
                            const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetPixelFormat( RED::FORMAT& oFormat,
                                   int          iNumColorBuffer,
                                   int          iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetPixelFormat( int               iNumColorBuffer,
                                   RED::FORMAT       iFormat,
                                   const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetHardwareAntiAlias( int& oMultiSamples,
                                         int  iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetEngineAntiAlias( int&  oMultiSamples,
                                       bool& oSuperScale,
                                       int   iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetEngineAntiAlias( int               iMultiSamples,
                                       bool              iSuperScale,
                                       const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetSoftAntiAlias( unsigned int& oAASamplesRate,
                                     int           iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetSoftAntiAlias( unsigned int       iAASamplesRate,
                                     const RED::State&  iState ) = 0;
    
    
    virtual RED_RC GetClearColor( RED::Color& oColor,
                                  int         iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetClearColor( const RED::Color& iColor,
                                  const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetClearDepth( float& oDepth,
                                  int    iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetClearDepth( float             iDepth,
                                  const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetBackgroundDepth( float& oDepth,
                                       int    iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetBackgroundCubeImage( RED::Object*& oImage,
                                           int iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetBackgroundCubeImageMatrix( RED::Matrix& oMatrix,
                                                 int iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetBackground2DImage( RED::Object*& oImage,
                                         int iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetBackground2DImageMatrix( RED::Matrix& oMatrix,
                                               int iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetBackgroundImagesDirectVisibility( bool& oVisibility,
                                                        int   iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetBackgroundImagesIntensityScale( double& oScaleCube,
                                                      double& oScale2D,
                                                      int   iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetBackgroundImages( RED::Object*       iCubeImage,
                                        const RED::Matrix& iCubeMatrix,
                                        RED::Object*       i2DImage,
                                        const RED::Matrix& i2DMatrix,
                                        bool               iDirectVisibility,
                                        double             iIntensityScaleCube,
                                        double             iIntensityScale2D,
                                        const RED::State&  iState ) = 0;
    
    
    virtual RED_RC GetViewpointGICaches( RED::Vector< RED::Object* >& oGICaches,
                                         RED::Object*                 iViewpoint,
                                         int                          iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetViewpointGICaches( const RED::Vector< RED::Object* >& iGICaches,
                                         RED::Object*                       iViewpoint,
                                         const RED::State&                  iState ) = 0;
    
    
    virtual RED_RC SetViewpointGICache( RED::Object*      iGICache,
                                        RED::Object*      iViewpoint,
                                        const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetViewpointSoftImages( RED::Object*& oColor,
                                           RED::Object*& oDepth,
                                           RED::Object*  iViewpoint,
                                           int           iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetViewpointSoftImages( RED::Object*      iColor,
                                           RED::Object*      iDepth,
                                           RED::Object*      iViewpoint,
                                           const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetViewpointSoftMatrix( RED::Matrix*& oMatrix,
                                           RED::Object*  iViewpoint,
                                           int           iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetViewpointSoftMatrix( RED::Matrix*      iMatrix,
                                           RED::Object*      iViewpoint,
                                           const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetViewpointSoftPixelAnalysisCallback( RED::SOFT_PIXEL_ANALYSIS_CALLBACK& oCallback,
                                                          void*&                             oUserData,
                                                          bool&                              oTwoSided,
                                                          RED::Object*                       iViewpoint,
                                                          int                                iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetViewpointSoftPixelAnalysisCallback( RED::SOFT_PIXEL_ANALYSIS_CALLBACK iCallback,
                                                          void*                             iUserData,
                                                          bool                              iTwoSided,
                                                          RED::Object*                      iViewpoint,
                                                          const RED::State&                 iState ) = 0;
    
    
    virtual RED_RC GetViewpointSoftBucketCallback( RED::SOFT_BUCKET_CALLBACK& oCallback,
                                                   void*&                     oUserData,
                                                   RED::Object*               iViewpoint,
                                                   int                        iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetViewpointSoftBucketCallback( RED::SOFT_BUCKET_CALLBACK  iCallback,
                                                   void*                      iUserData,
                                                   RED::Object*               iViewpoint,
                                                   const RED::State&          iState ) = 0;
    

    virtual RED_RC GetViewpointSoftTileOffset( int&         oOffsetX,
                                               int&         oOffsetY,
                                               RED::Object* iViewpoint,
                                               int          iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetViewpointSoftTileOffset( RED::Object*       iViewpoint,
                                               int                iOffsetX,
                                               int                iOffsetY,
                                               const RED::State&  iState ) = 0;
    
    
    virtual RED_RC GetViewpointSoftClipBox( double&      oBXMin,
                                            double&      oBXMax,
                                            double&      oBYMin,
                                            double&      oBYMax,
                                            double&      oBZMin,
                                            double&      oBZMax,
                                            RED::Matrix& oMatrix,
                                            RED::Object* iViewpoint,
                                            int          iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetViewpointSoftClipBox( double             iBXMin,
                                            double             iBXMax,
                                            double             iBYMin,
                                            double             iBYMax,
                                            double             iBZMin,
                                            double             iBZMax,
                                            const RED::Matrix& iMatrix,
                                            RED::Object*       iViewpoint,
                                            const RED::State&  iState ) = 0;
    
    
    virtual RED_RC ResetViewpointSoftClipBox( RED::Object*      iViewpoint,
                                              const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetViewpointSoftRayProcessingCallbacks( RED::SOFT_RAY_PROCESSING_INTERSECTION_CALLBACK& oIntersectCallback,
                                                           RED::SOFT_RAY_PROCESSING_SHADING_CALLBACK&      oShadingCallback,
                                                           void*&                                          oUserData,
                                                           RED::Object*                                    iViewpoint,
                                                           int                                             iStateNumber ) = 0;
    
    
    virtual RED_RC SetViewpointSoftRayProcessingCallbacks( RED::SOFT_RAY_PROCESSING_INTERSECTION_CALLBACK iIntersectCallback,
                                                           RED::SOFT_RAY_PROCESSING_SHADING_CALLBACK      iShadingCallback,
                                                           void*                                          iUserData,
                                                           RED::Object*                                   iViewpoint,
                                                           const RED::State&                              iState ) = 0;
    
    
    virtual RED_RC GetViewpointGeometryDatabase( RED::Object*& oGeometryDatabase,
                                                 RED::Object*  iViewpoint,
                                                 int           iStateNumber = -1 ) const = 0;
    
    
    // Viewpoint list manipulation - access:
    // -------------------------------------
    
    virtual RED_RC GetViewpoint( RED::Object*& oVP,
                                 int           iNumber,
                                 RED::VRL_SORT iListID,
                                 int           iStateNumber = -1 ) const = 0;
    
    
    
    virtual RED_RC GetViewpointList( RED::Vector< RED::Object* >*&  oVP,
                                     RED::VRL_SORT                  iListId,
                                     int                            iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetViewpointsCount( int& oCount,
                                       int  iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetViewpoint( RED::Object*& oVp,
                                 int           iNumber,
                                 int           iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetViewpointSortList( RED::VRL_SORT& oList,
                                         int            iNumber,
                                         int            iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC FindViewpoint( bool&        oFound,
                                  RED::Object* iViewpoint,
                                  int          iStateNumber = - 1 ) const = 0;
    
    
    virtual RED_RC GetViewpointBoundaries( const RED::Object* iViewpoint,
                                           int&               oXAnchor,
                                           int&               oYAnchor,
                                           int&               oXSize,
                                           int&               oYSize,
                                           int                iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetViewpointSizingModes( RED::Object* iViewpoint,
                                            int&         oAnchoringMode,
                                            int&         oSizingMode,
                                            int          iStateNumber = -1 ) const = 0;
    
    
    // Viewpoint list manipulation - edition:
    // --------------------------------------
    
    virtual RED_RC InsertViewpoint( RED::Object*      iViewpoint,
                                    RED::VRL_SORT     iFrontSceneOrBack,
                                    RED::LIST_POS     iFirstOrLastInList,
                                    int               iXAnchor,
                                    int               iYAnchor,
                                    int               iXSize,
                                    int               iYSize,
                                    float             iXAsymmetricOffset,
                                    float             iYAsymmetricOffset,
                                    RED::VRL_SIZEPOS  iAnchoringMode,
                                    RED::VRL_SIZEPOS  iSizingMode,
                                    const RED::State& iState ) = 0;
    
    
    virtual RED_RC InsertViewpoint( RED::Object*      iViewpoint,
                                    RED::VRL_SORT     iFrontSceneOrBack,
                                    int               iPosition,
                                    int               iXAnchor,
                                    int               iYAnchor,
                                    int               iXSize,
                                    int               iYSize,
                                    float             iXAsymmetricOffset,
                                    float             iYAsymmetricOffset,
                                    RED::VRL_SIZEPOS  iAnchoringMode,
                                    RED::VRL_SIZEPOS  iSizingMode,
                                    const RED::State& iState ) = 0;
    
    
    virtual RED_RC InsertViewpoint( RED::Object* iViewpoint,
                                    const RED::State& iState ) = 0;
    
    
    virtual RED_RC RemoveViewpoint( RED::Object*      iViewpoint,
                                    const RED::State& iState ) = 0;
    
    
    virtual RED_RC RemoveViewpointList( RED::VRL_SORT     iList,
                                        const RED::State& iState ) = 0;
    
    
    virtual RED_RC SetViewpointBoundaries( RED::Object*      iViewpoint,
                                           int               iXAnchor,
                                           int               iYAnchor,
                                           int               iXSize,
                                           int               iYSize,
                                           int               iAnchoringMode,
                                           int               iSizingMode,
                                           const RED::State& iState ) = 0;
    
    
    // Built-in render images:
    // -----------------------
    
    virtual RED::Object* GetRenderImage( int iColorBufferNumber = 0 ) const = 0;
    
    
    virtual RED::Object* GetRenderDepthImage() const = 0;
    
    
    virtual int GetRenderImagesCount() const = 0;
    
    
    // Asymmetric viewpoints:
    // ----------------------
    
    virtual RED_RC GetViewpointAsymmetricOffsets( RED::Object* iViewpoint,
                                                  float&       oXAsymmetricOffset,
                                                  float&       oYAsymmetricOffset,
                                                  int          iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetViewpointAsymmetricOffsets( RED::Object*      iViewpoint,
                                                  float             iXAsymmetricOffset,
                                                  float             iYAsymmetricOffset,
                                                  const RED::State& iState ) = 0;
    
    
    // Miscellaneous methods:
    // ----------------------
    
    virtual RED_RC Activate( bool iOnOff, const RED::State& iState ) = 0;
    
    
    virtual RED_RC IsActivated( bool& oOnOff, int iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetMustClear( bool iClear, const RED::State& iState ) = 0;
    
    
    virtual RED_RC MustClear( bool& oMustClear, int iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetHDROverride( bool iOverride,
                                   int iHDRValue,
                                   const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetHDROverride( bool& oOverride,
                                   int&  oHDRValue,
                                   int   iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC SetStereo( float             iInteraxialDistance,
                              float             iScreenDepth,
                              const RED::State& iState ) = 0;
    
    
    virtual RED_RC GetStereo( float& oInteraxialDistance,
                              float& oScreenDepth,
                              int    iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetViewportMatrix( RED::Matrix& oViewport,
                                      RED::Object* iCamera,
                                      int          iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetViewProjectionViewportMatrix( RED::Matrix&       oVPV,
                                                    const RED::Object* iCamera,
                                                    int                iStateNumber = -1 ) const = 0;

    
    virtual RED_RC GetFloatingViewProjectionViewportMatrix( RED::Matrix&       oVPV,
                                                            const RED::Object* iCamera,
                                                            int                iStateNumber = -1 ) const = 0;
    
    
    virtual RED_RC GetInverseProjectionViewportMatrix( RED::Matrix&       oIPV,
                                                       const RED::Object* iCamera,
                                                       int                iStateNumber = -1 ) const = 0;


#if defined( _WIN32 )
    
    virtual RED_RC GetOpenGLInfo( HDC&          oHDC,
                                  HGLRC&        oHGLRC,
                                  unsigned int& oFBOID ) = 0;
    
    
    virtual RED_RC UpdateOpenGLInfo( HDC          iHDC,
                                     HGLRC        iHGLRC,
                                     unsigned int iFBOID ) = 0;
    
    
#elif defined( _LIN32 )
    
    virtual RED_RC GetOpenGLInfo( Drawable&     oDrawable,
                                  GLXContext&   oGLXContext,
                                  unsigned int& oFBOID ) = 0;
    
    
    virtual RED_RC UpdateOpenGLInfo( Drawable     iDrawable,
                                     GLXContext   iGLXContext,
                                     unsigned int iFBOID ) = 0;
    
    
#endif
    
  };
};


#endif