render.h

Go to the documentation of this file.
00001 //
00002 // Copyright 2010 Autodesk, Inc. All rights reserved.
00003 //
00004 // Use of this software is subject to the terms of the Autodesk license
00005 // agreement provided at the time of installation or download, or which
00006 // otherwise accompanies this software in either electronic or hard copy form.  
00007 //
00008 //
00009 
00010 
00011 #pragma once
00012 
00013 // includes
00014 #include "maxheap.h"
00015 #include "sfx.h"
00016 #include "buildver.h"
00017 #include "iTargetedIO.h"
00018 #include "RendType.h"
00019 #include "object.h"
00020 
00021 #define FIELD_EVEN 0
00022 #define FIELD_ODD 1
00023 
00024 #pragma warning(push)
00025 #pragma warning(disable:4100)
00026 
00038 class DefaultLight: public MaxHeapOperators
00039 {
00040 public:
00041     LightState ls;  
00042     Matrix3 tm;     
00043 };
00044 
00112 class ViewParams : public BaseInterfaceServer {
00113     public:
00114         Matrix3 prevAffineTM; // world space to camera space transform 2 ticks previous 
00115         Matrix3 affineTM;  // world space to camera space transform
00116         int projType;      // PROJ_PERSPECTIVE or PROJ_PARALLEL
00117         float hither,yon;
00118         float distance; // to view plane
00119         // Parallel projection params
00120         float zoom;  // Zoom factor 
00121         // Perspective params
00122         float fov;  // field of view
00123         float nearRange; // for fog effects
00124         float farRange;  // for fog effects
00125         // Generic expansion function
00141         virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0) { return 0; } 
00142     };
00143 
00144 
00145 // Common renderer parameters
00146 
00147 /*
00148 class Atmospheric;
00149 class IRenderElement;
00150 */
00151 class RadiosityEffect;
00152 class ToneOperator;
00153 
00155 
00156 
00158 #define RENDER_R25SHADOWS             (1L << 2)
00159 
00162 #define RENDER_HIDE_FROZEN            (1L << 3)
00163 
00164 
00165 // These parameters are passed to the renderer when the renderer is opend.
00272 class RendParams: public MaxHeapOperators
00273 {
00274 private:
00275     IRenderElementMgr *mpIRenderElementMgr; // The render element manager, may be NULL -- declared in maxsdk/include/RenderElements.h
00276 
00277 public:
00279     enum RenderMode
00280     {
00281         RM_Default,         
00282         RM_IReshade,        
00283     };
00284 
00286     enum Execute_Commands {
00289         kCommand_IsToneOpPreview = 0x4e80014c
00290     };
00291 
00292     RendType rendType;      // normal, region, blowup, selection
00293 
00294     // JOHNSON RELEASE SDK
00295     //BOOL isIterativeRender;       // is this an iterative mode render?
00296     BOOL isNetRender;       // is this a render on a network slave? 
00297     BOOL fieldRender;
00298     int fieldOrder;         // 0->even, 1-> odd
00299     TimeValue frameDur;     // duration of one frame
00300     
00301     BOOL colorCheck;
00302     int vidCorrectMethod;   // 0->FLAG, 1->SCALE_LUMA 2->SCALE_SAT
00303     int ntscPAL;            // 0 ->NTSC,  1 ->PAL
00304     BOOL superBlack;        // impose superBlack minimum intensity?
00305     int sbThresh;           // value used for superBlack
00306     BOOL rendHidden;        // render hidden objects?
00307     BOOL force2Side;        // force two-sided rendering?
00308     BOOL inMtlEdit;         // rendering in the mtl editor?
00309     float mtlEditTile;      // if in mtl editor, scale tiling by this value
00310     BOOL mtlEditAA;         // if in mtl editor, antialias? 
00311     BOOL multiThread;       // for testing only
00312     BOOL useEnvironAlpha;   // use alpha from the environment map.
00313     BOOL dontAntialiasBG;   // Don't antialias against background (for video games)     
00314     BOOL useDisplacement;   // Apply displacment mapping        
00315     bool useRadiosity;      // Include radiosity in rendering
00316     bool computeRadiosity;  // Compute radiosity before rendering
00317     Texmap *envMap;         // The environment map, may be NULL
00318     Atmospheric *atmos;     // The atmosphere effects, may be NULL.
00319     Effect *effect;         // The postprocessing effects, may be NULL.
00320     RadiosityEffect* pRadiosity;    // The radiosity effect
00321     ToneOperator* pToneOp;  // The tone operator, may be NULL
00322     TimeValue firstFrame;   // The first frame that will be rendered
00323     int scanBandHeight;     // height of a scan band (default scanline renderer)
00324     ULONG extraFlags;       // for expansion
00325     int width,height;       // image width,height.
00326     BOOL filterBG;          // filter background
00327     BOOL alphaOutOnAdditive;// produce alpha on additive transparency
00328 #ifdef SIMPLIFY_AREA_LIGHTS
00329     bool simplifyAreaLights;
00330 #endif
00331 
00334     RendParams()
00335     {
00336         rendType = RENDTYPE_NORMAL;
00337         isNetRender = FALSE;
00338         fieldRender = FALSE;
00339         fieldOrder = 0;
00340         frameDur = 0;
00341         colorCheck = 0;
00342         vidCorrectMethod = 0;
00343         ntscPAL = 0;
00344         superBlack = 0;
00345         sbThresh = 0;
00346         rendHidden = 0;
00347         force2Side = 0;
00348         inMtlEdit = 0;
00349         mtlEditTile = 0;
00350         mtlEditAA = 0;
00351         multiThread = 0;
00352         useEnvironAlpha = 0;
00353         dontAntialiasBG = 0;
00354         useDisplacement = 0;
00355         useRadiosity = true;
00356         computeRadiosity = true;
00357         envMap = NULL;
00358         atmos = NULL;
00359         mpIRenderElementMgr = NULL;
00360         effect = NULL;
00361         pRadiosity = NULL;
00362         pToneOp = NULL;
00363         firstFrame = 0;
00364         scanBandHeight = 0;
00365         extraFlags = 0;
00366         width=height = 0;
00367         filterBG = 0;
00368 #ifdef SIMPLIFY_AREA_LIGHTS
00369         simplifyAreaLights = false;
00370 #endif
00371     }
00372 
00374     virtual ~RendParams() {}
00375 
00381     RenderMode GetRenderMode() { return RM_Default; } // mjm - 06.08.00
00386     void SetRenderElementMgr(IRenderElementMgr *pIRenderElementMgr) { mpIRenderElementMgr = pIRenderElementMgr; } // mjm - 06.30.00
00387 
00388 #define RP_ANTIALIAS_OFF 200 //!< An index to an external command. Can be accepted as the argument to Execute() 
00389 
00391     IRenderElementMgr *GetRenderElementMgr() { 
00392         return( Execute(RP_ANTIALIAS_OFF) ? NULL : mpIRenderElementMgr); 
00393     }
00394 
00410     virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0) { return 0; }
00411 
00412     // Call this function to determine whether we are doing a tone operator preview rendering
00413     bool IsToneOperatorPreviewRender();
00414 };
00415 
00416 inline bool RendParams::IsToneOperatorPreviewRender() {
00417 
00418     // Execute the special command on the render params
00419     INT_PTR result = Execute(kCommand_IsToneOpPreview);
00420     return (result != 0);
00421 }
00422 
00423 // These are passed to the renderer on every frame
00467 class FrameRendParams : public BaseInterfaceServer {
00468     public:
00469     Color ambient;
00470     Color background;
00471     Color globalLightLevel;
00472     float frameDuration; // duration of one frame, in current frames
00473     float relSubFrameDuration;  // relative fraction of frameDuration used by subframe.
00474 
00475     // boundaries of the region for render region or crop (device coords).
00476     int regxmin,regxmax;
00477     int regymin,regymax;
00478 
00479     // parameters for render blowup.
00480     Point2 blowupCenter;
00481     Point2 blowupFactor;
00482 
00485     FrameRendParams() { frameDuration = 1.0f; relSubFrameDuration = 1.0f; }
00501     virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0) { return 0; } 
00502     };
00503 
00504 // Since this dialog is modless and non-interactive, as the user changes
00505 // parameters in the dialog, the renderer does not need to update it's
00506 // state. When the user is through, they may choose 'OK' or 'Cancel'.
00507 //
00508 // If the user OKs the dialog, AcceptParams() will be called, at which time the
00509 // renderer can read the parameter out of the UI and modify its state.
00510 // 
00511 // If RejectParams() is called, typically the renderer will not have to do anything
00512 // since it has not yet modify its state, but if for some reason it has, it
00513 // should restore its state.
00523 class RendParamDlg: public MaxHeapOperators {
00524     public:
00526         virtual ~RendParamDlg() { }
00530         virtual void AcceptParams()=0;
00536         virtual void RejectParams() {}
00539         virtual void DeleteThis()=0;        
00540     };
00541 
00542 
00546 #define BROWSE_MATSONLY     (1<<0)  //!< Materials only
00547 #define BROWSE_MAPSONLY     (1<<1)  //!< Maps only
00548 #define BROWSE_INCNONE      (1<<2)  //!< Include 'None' as an option
00549 #define BROWSE_INSTANCEONLY (1<<3)  //!< Only allow instances, no copy
00550 #define BROWSE_TO_MEDIT_SLOT (1<<4) //!< browsing to medit slot
00551 #define BROWSE_EXISTING_ONLY (1<<5) //!< Browse for existing materials only; no new materials.
00552 
00553  
00554 // passed to SetPickMode. This is a callback that gets called as
00555 // the user tries to pick objects in the scene.
00560 class RendPickProc: public MaxHeapOperators
00561 {
00562 public:
00564     virtual ~RendPickProc() { }
00565 
00566     // Called when the user picks something.
00567     // return TRUE to end the pick mode.
00573     virtual BOOL Pick(INode *node)=0;
00574 
00575     // Return TRUE if this is an acceptable hit, FALSE otherwise.
00580     virtual BOOL Filter(INode *node)=0;
00581 
00582     // These are called as the mode is entered and exited
00586     virtual void EnterMode() {}
00590     virtual void ExitMode() {}
00591 
00592     // Provides two cursor, 1 when over a pickable object and 1 when not.
00597     virtual HCURSOR GetDefCursor() {return NULL;}
00602     virtual HCURSOR GetHitCursor() {return NULL;}
00603 
00604     // Return TRUE to allow the user to pick more than one thing.
00605     // In this case the Pick method may be called more than once.
00612     virtual BOOL AllowMultiSelect() {return FALSE;}
00613 };
00614 
00615 class ITabbedDialog;
00616 class ITabPage;
00617 
00618 // This is the interface given to a renderer when it needs to display its parameters
00619 // It is also given to atmospheric effects to display thier parameters.
00625 class IRendParams : public InterfaceServer
00626 {
00627 public:
00628     // The current position of the frame slider
00630     virtual TimeValue GetTime()=0;
00631 
00637     virtual void RegisterTimeChangeCallback(TimeChangeCallback *tc)=0;
00643     virtual void UnRegisterTimeChangeCallback(TimeChangeCallback *tc)=0;
00644 
00645     // Brings up the material browse dialog allowing the user to select a material.
00646     // newMat will be set to TRUE if the material is new OR cloned.
00647     // Cancel will be set to TRUE if the user cancels the dialog.
00648     // The material returned will be NULL if the user selects 'None'
00661     virtual MtlBase *DoMaterialBrowseDlg(HWND hParent,DWORD flags,BOOL &newMat,BOOL &cancel)=0;
00662 
00663     // Adds rollup pages to the render params dialog. Returns the window
00664     // handle of the dialog that makes up the page.
00700     virtual HWND AddRollupPage(
00701         HINSTANCE hInst, 
00702         MCHAR *dlgTemplate, 
00703         DLGPROC dlgProc, 
00704         MCHAR *title, 
00705         LPARAM param=0, 
00706         DWORD flags=0, 
00707         int category = ROLLUP_CAT_STANDARD)=0;
00708 
00744     virtual HWND AddRollupPage(
00745         HINSTANCE hInst, 
00746         DLGTEMPLATE *dlgTemplate, 
00747         DLGPROC dlgProc, 
00748         MCHAR *title, 
00749         LPARAM param=0, 
00750         DWORD flags=0, 
00751         int category = ROLLUP_CAT_STANDARD)=0;
00752 
00753     // Removes a rollup page and destroys it.
00759     virtual void DeleteRollupPage(HWND hRollup)=0;
00760 
00761     // When the user mouses down in dead area, the plug-in should pass
00762     // mouse messages to this function which will pass them on to the rollup.
00778     virtual void RollupMouseMessage(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)=0;
00779 
00780     // This will set the command mode to a standard pick mode.
00781     // The callback implements hit testing and a method that is
00782     // called when the user actually picks an item.
00789     virtual void SetPickMode(RendPickProc *proc)=0;
00790     
00791     // If a plug-in is finished editing its parameters it should not
00792     // leave the user in a pick mode. This will flush out any pick modes
00793     // in the command stack.
00797     virtual void EndPickMode()=0;
00798         
00799     // When a plugin has a Texmap, clicking on the button
00800     // associated with that map should cause this routine
00801     // to be called.
00808     virtual void PutMtlToMtlEditor(MtlBase *mb)=0;
00809 
00810     // This is for use only by the scanline renderer.
00812     virtual float GetMaxPixelSize() = 0;
00813 
00829     virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0) { return 0; } 
00830 
00831     // JBW 12/1/98: get interface to rollup window interface
00832     virtual IRollupWindow* GetIRollup()=0;
00833 
00834     // Adds rollup pages to the render params dialog. Returns the window
00835     // handle of the dialog that makes up the page.
00836     virtual HWND AddTabRollupPage(const Class_ID& id, HINSTANCE hInst, MCHAR *dlgTemplate, 
00837         DLGPROC dlgProc, MCHAR *title, LPARAM param=0, DWORD flags=0, int category = ROLLUP_CAT_STANDARD)
00838     {
00839         return AddRollupPage(hInst, dlgTemplate, dlgProc, title, param, flags, category);
00840     }
00841 
00842     virtual HWND AddTabRollupPage(const Class_ID& id, HINSTANCE hInst, DLGTEMPLATE *dlgTemplate, 
00843         DLGPROC dlgProc, MCHAR *title, LPARAM param=0, DWORD flags=0, int category = ROLLUP_CAT_STANDARD)
00844     {
00845         return AddRollupPage(hInst, dlgTemplate, dlgProc, title, param, flags, category);
00846     }
00847 
00848     // Removes a rollup page and destroys it.
00849     virtual void DeleteTabRollupPage(const Class_ID& id, HWND hRollup)
00850     {
00851         DeleteRollupPage(hRollup);
00852     }
00853 
00854     // When the user mouses down in dead area, the plug-in should pass
00855     // mouse messages to this function which will pass them on to the rollup.
00856     virtual void RollupTabMouseMessage(const Class_ID& id, HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
00857     {
00858         RollupMouseMessage(hDlg, message, wParam, lParam);
00859     }
00860 
00861     // JBW 12/1/98: get interface to rollup window interface
00862     virtual IRollupWindow* GetTabIRollup(const Class_ID& id)
00863     {
00864         return GetIRollup();
00865     }
00866 
00867     // Return the tabbed dialog for these render params
00868     virtual ITabbedDialog* GetTabDialog()
00869     {
00870         return NULL;
00871     }
00872 
00873     // Return the page with the given class id.
00874     virtual ITabPage* GetTabPage(const Class_ID& id)
00875     {
00876         return NULL;
00877     }
00878 };
00879 
00880 
00882 
00883 #define INST_HIDE           (1<<0) //!< instance is hidden
00884 #define INST_CLIP           (1<<1) //!< clip instance: ray tracers should skip it 
00885 #define INST_BLUR           (1<<2) //!< secondary motion blur instance 
00886 #define INST_RCV_SHADOWS    (1<<3) //!< instance receives shadows
00887 #define INST_TM_NEGPARITY   (1<<4) //!< mesh is inside-out: need to reverse normals on-the-fly
00888 #define INST_MTL_BYFACE     (1<<5) //!<instance's object supports mtl-by-face interface ( chkmtlapi.h)
00889 
00890 
00891 
00950 class RenderInstance: public MaxHeapOperators
00951 {
00952 public:
00953     ULONG flags;
00954     Mtl *mtl;               // from inode, for convenience
00955     float wireSize;         // Mtl wireframe size
00956     Mesh *mesh;             // result of GetRenderMesh call
00957     float vis;              // Object visibility
00958     int nodeID;             // unique within scene during render- corresponds to ShadeContext::NodeID()
00959     int objMotBlurFrame;    // Object motion blur sub frame (= NO_MOTBLUR for non-blurred objects)
00960     int objBlurID;          // Blur instances for an object share a objBlurID value.
00961     Matrix3 objToWorld;     // transforms object coords to world coords
00962     Matrix3 objToCam;       // transforms object coords to cam coords
00963     Matrix3 normalObjToCam; // for transforming surface normals from obj to camera space
00964     Matrix3 camToObj;       // transforms camera coords to object coords
00965     Box3 obBox;             // Object space extents
00966     Point3 center;          // Bounding sphere center (camera coords)
00967     float radsq;            // square of bounding sphere's radius
00968 
00970     virtual ~RenderInstance() {}
00971 
00978     void SetFlag(ULONG f, BOOL b) { if (b) flags |= f; else flags &= ~f; }
00983     void SetFlag(ULONG f) {  flags |= f; }
00988     void ClearFlag(ULONG f) {  flags &= ~f; }
00994     BOOL TestFlag(ULONG f) { return flags&f?1:0; }
00995     BOOL Hidden() { return TestFlag(INST_HIDE); }
00996     BOOL IsClip() { return TestFlag(INST_CLIP); }
00997 
01001     virtual RenderInstance *Next()=0;   // next in list
01002 
01005     virtual Interval MeshValidity()=0;
01007     virtual int NumLights()=0;
01013     virtual LightDesc *Light(int n)=0; 
01014 
01021     virtual BOOL CastsShadowsFrom(const ObjLightDesc& lt)=0; // is lt shadowed by this instance?
01022 
01024     virtual INode *GetINode()=0;                         // get INode for instance
01029     virtual Object *GetEvalObject()=0;                   // evaluated object for instance
01042     virtual ULONG MtlRequirements(int mtlNum, int faceNum)=0;    // node's mtl requirements. DS 3/31/00: added faceNum to support mtl-per-face objects
01048     virtual Point3 GetFaceNormal(int faceNum)=0;         // geometric normal in camera coords
01056     virtual Point3 GetFaceVertNormal(int faceNum, int vertNum)=0;  // camera coords
01064     virtual void GetFaceVertNormals(int faceNum, Point3 n[3])=0;   // camera coords
01070     virtual Point3 GetCamVert(int vertnum)=0;            // coord for vertex in camera coords       
01078     virtual void GetObjVerts(int fnum, Point3 obp[3])=0; // vertices of face in object coords
01086     virtual void GetCamVerts(int fnum, Point3 cp[3])=0; // vertices of face in camera(view) coords
01104     virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0) { return 0; } 
01105 
01106     // Material-by-face access
01107     // Objects can provide a material as a function of face number via the IChkMtlAPI interface (chkmtlapi.h).
01108     // This method will return RenderInstance::mtl if flag INST_MTL_BYFACE is not set. If INST_MTL_BYFACE is
01109     // set it will return the proper by-face mtl. // DS 4/3/00
01119     virtual Mtl *GetMtl(int faceNum)=0;  
01120 };
01121 
01122 //----------------------------------------------------------------
01123 
01125 
01126 #define RENDPROG_CONTINUE   1   //!< Continue to Process
01127 #define RENDPROG_ABORT      0   //!< Stop Processing
01128 
01129 
01131 
01132 #define FIELD_FIRST     0
01133 #define FIELD_SECOND    1
01134 #define FIELD_NONE      -1
01135 
01136 
01137 
01146 // A callback passed in to the renderer
01147 class RendProgressCallback: public MaxHeapOperators
01148 {
01149 public:
01151     virtual ~RendProgressCallback() { }
01157     virtual void SetTitle(const MCHAR *title)=0;
01168     virtual int Progress(int done, int total)=0;
01175     virtual void SetCurField(int which) {}
01190     virtual void SetSceneStats(int nlights, int nrayTraced, int nshadowed, int nobj, int nfaces) {}
01191 };
01192 
01193 
01194 //==============================================================================
01195 // class Renderer
01196 //
01198 
01213 class Renderer : public ReferenceTarget
01214 {
01215 public:
01216 
01218     SClass_ID SuperClassID() {return RENDERER_CLASS_ID;}
01219     
01222 
01238     virtual int Open(
01239         INode *scene,
01240         INode *vnode,
01241         ViewParams *viewPar,
01242         RendParams &rp,
01243         HWND hwnd,
01244         DefaultLight* defaultLights=NULL,
01245         int numDefLights=0,
01246         RendProgressCallback* prog = NULL
01247     ) = 0;
01248     
01250 
01263     virtual int Render(
01264         TimeValue t,
01265         Bitmap *tobm,
01266         FrameRendParams &frp,
01267         HWND hwnd,
01268         RendProgressCallback *prog=NULL,
01269         ViewParams *viewPar=NULL
01270     )=0;
01271 
01274 
01281     virtual void Close( HWND hwnd, RendProgressCallback* prog = NULL )=0;   
01282 
01283     // apply render effects at the requested time value - should be called between Renderer::Open() and Renderer::Close()
01284     // this can be used during a multi-pass rendering, in order to apply the render effects to the final, blended bitmap.
01285     // 'updateDisplay' indicates that Bitmap's display should be refreshed by the renderer
01286     // return value indicats if effects were successfully applied.
01288 
01298     virtual bool ApplyRenderEffects(TimeValue t, Bitmap *pBitmap, bool updateDisplay=true) { return false; }
01299 
01300     // Adds rollup page(s) to renderer configure dialog
01301     // If prog==TRUE then the rollup page should just display the parameters
01302     // so the user has them for reference while rendering, they should not be editable.
01305 
01313     virtual RendParamDlg *CreateParamDialog(IRendParams *ir,BOOL prog=FALSE)=0;
01314 
01316     virtual void ResetParams()=0;
01317     virtual int GetAAFilterSupport(){ return 0; } // point sample, no reconstruction filter
01318 
01320 
01324     virtual bool SupportsTexureBaking() { return false; }
01325 
01327 
01328     virtual bool SupportsCustomRenderPresets() { return false; }
01329 
01331 
01333     virtual int  RenderPresetsFileVersion() { return -1; }
01334 
01336 
01338     virtual BOOL RenderPresetsIsCompatible( int version ) { return false; }
01339 
01341 
01344     virtual MCHAR * RenderPresetsMapIndexToCategory( int catIndex ) { return NULL; }
01345 
01347 
01349     virtual int RenderPresetsMapCategoryToIndex( const MCHAR* category )  { return 0; }
01350 
01351     // \deprecated Implement RenderPresetsMapCategoryToIndex( const MCHAR* category ) 
01352     virtual int RenderPresetsMapCategoryToIndex( MCHAR* category ) { return RenderPresetsMapCategoryToIndex( const_cast<const MCHAR*>(category));}
01353 
01355 
01375     virtual int RenderPresetsPreSave( ITargetedIO * root, BitArray saveCategories ) { return -1; }
01376 
01378 
01380     virtual int RenderPresetsPostSave( ITargetedIO * root, BitArray loadCategories ) { return -1; }
01381 
01383 
01390     virtual int RenderPresetsPreLoad( ITargetedIO * root, BitArray saveCategories ) { return -1; }
01391 
01393 
01403     virtual int RenderPresetsPostLoad( ITargetedIO * root, BitArray loadCategories ) { return -1; }
01404 };
01405 
01406 
01407 class ShadowBuffer;
01408 class ShadowQuadTree;
01409 
01418 class RendContext: public MaxHeapOperators
01419 {
01420 public:
01422     virtual ~RendContext() {}
01432     virtual int Progress(int done, int total) const { return 1; }
01434 
01436     virtual Color GlobalLightLevel() const = 0;
01437 };
01438 
01443 struct SubRendParams : public BaseInterfaceServer
01444 {
01446     RendType rendType;
01448     BOOL fieldRender;
01450     BOOL evenLines; // when field rendering
01452     BOOL doingMirror;
01453     BOOL doEnvMap;  // do environment maps?
01455     int devWidth, devHeight;
01457     float devAspect;
01459     int xorg, yorg;
01461     int xmin,xmax,ymin,ymax;
01462 
01463     // parameters for render blowup.
01466     Point2 blowupCenter;
01469     Point2 blowupFactor;
01470 
01487     virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0) { return 0; }
01488 };
01489 
01490 #define RENDMAP_SHOW_NODE  1  // DO NOT exclude this node from the render. An argument for RenderMapsContext::Render()
01491 
01492 
01493 // A pointer to this data structure is passed to MtlBase::BuildMaps();
01494 // when rendering reflection and refraction maps.
01503 class RenderMapsContext: public MaxHeapOperators
01504 { 
01505 public:
01507     virtual ~RenderMapsContext() { }
01511     virtual INode *GetNode()=0;
01518     virtual int NodeRenderID()=0;
01523     virtual void GetCurrentViewParams(ViewParams &vp)=0;
01528     virtual void GetSubRendParams(SubRendParams &srp)=0;
01531     virtual int SubMtlIndex()=0;
01532     virtual void SetSubMtlIndex(int mindex)=0;
01541     virtual void FindMtlPlane(float pl[4])=0;
01553     virtual void FindMtlScreenBox(Rect &sbox, Matrix3* viewTM=NULL, int mtlIndex=-1)=0;
01557     virtual Box3 CameraSpaceBoundingBox()=0;
01561     virtual Box3 ObjectSpaceBoundingBox()=0;
01563     virtual Matrix3 ObjectToWorldTM()=0;
01566     virtual RenderGlobalContext *GetGlobalContext() { return NULL; }
01567     // ClipPlanes is a pointer to an array of Point4's,  each of which
01568     // represents a clip plane.  nClip Planes is the number of planes (up to 6);
01569     // The planes are in View space.
01590     virtual int Render(Bitmap *bm, ViewParams &vp, SubRendParams &srp, Point4 *clipPlanes=NULL, int nClipPlanes=0)=0; 
01606     virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0) { return 0; } 
01607 };  
01608 
01609 
01610 #define DONT_CLIP 1.0E38f
01611 
01612 
01614 
01615 #define SCANLINE_RENDERER_INTERFACE  Interface_ID(0x342323, 0x551665)
01616 #define SCANLINE_RENDERER3_INTERFACE Interface_ID(0x44e40bbc, 0x52bc7cd1)
01617 
01618 
01619 #define GetScanRendererInterface(obj) ((IScanRenderer2*)obj->GetInterface(SCANLINE_RENDERER_INTERFACE)) 
01620 #define GetScanRendererInterface3(obj) ((IScanRenderer3*)obj->GetInterface(SCANLINE_RENDERER3_INTERFACE)) 
01621 
01622 //--------------------------------------------------------------------------
01623 // Interface into the default scanline renderer, Class_ID(SREND_CLASS_ID,0)
01624 //---------------------------------------------------------------------------
01625 class FilterKernel;
01632 class IScanRenderer: public Renderer {
01633     public:
01639     virtual void SetAntialias(BOOL b) = 0;
01641     virtual BOOL GetAntialias() = 0;
01642 
01647     virtual void SetFilter(BOOL b) = 0;
01648 
01650     virtual BOOL GetFilter() = 0;
01651 
01656     virtual void SetShadows(BOOL b) = 0;
01659     virtual BOOL GetShadows() = 0;
01664     virtual void SetMapping(BOOL b) = 0;
01666     virtual BOOL GetMapping() = 0;
01671     virtual void SetForceWire(BOOL b) = 0;
01673     virtual BOOL GetForceWire() = 0;
01679     virtual void SetAutoReflect(BOOL b)=0;
01681     virtual BOOL GetAutoReflect()=0;
01682 
01683 
01688     virtual void SetObjMotBlur(BOOL b) = 0;
01689 
01691     virtual BOOL GetObjMotBlur() = 0;
01692 
01693 
01698     virtual void SetVelMotBlur(BOOL b) = 0;
01699 
01701     virtual BOOL GetVelMotBlur() = 0;
01702 
01703     // Obsolete, use setfiltersz. pixel sz = 1.0 for all filtering
01705     virtual void SetPixelSize(float size) = 0;
01706     
01712     virtual void SetAutoReflLevels(int n) = 0;
01717     virtual void SetWireThickness(float t) = 0;
01718 
01719     virtual void SetObjBlurDuration(float dur) = 0;
01720     virtual void SetVelBlurDuration(float dur) = 0;
01725     virtual void SetNBlurFrames(int n) = 0;
01731     virtual void SetNBlurSamples(int n) = 0;
01732 
01733 
01739     virtual void SetMaxRayDepth(int n) = 0;
01741     virtual int GetMaxRayDepth() { return 7; }
01742 
01743 
01748     virtual void SetAntiAliasFilter( FilterKernel * pKernel ) = 0;
01749 
01752     virtual FilterKernel * GetAntiAliasFilter() = 0;
01753 
01758     virtual void SetAntiAliasFilterSz(float size) = 0;
01759 
01761     virtual float GetAntiAliasFilterSz() = 0;
01762 
01763 
01768     virtual void SetPixelSamplerEnable( BOOL on ) = 0;
01769 
01771     virtual BOOL GetPixelSamplerEnable() = 0;
01772 };
01773 
01774 //--------------------------------------------------------------------------
01775 // Extended Interface into the default scanline renderer, Class_ID(SREND_CLASS_ID,0)
01776 //---------------------------------------------------------------------------
01777 class IScanRenderer2: public IScanRenderer, public FPMixinInterface {
01778     public:
01779 
01780     enum {  get_mapping, set_mapping,  
01781             get_shadows, set_shadows,  
01782             get_autoReflect, set_autoReflect,  
01783             get_forceWire, set_forceWire,  
01784             get_antialias, set_antialias,  
01785             get_filter, set_filter,  
01786             get_objMotBlur, set_objMotBlur,  
01787             get_velMotBlur, set_velMotBlur,  
01788             get_applyVelBlurEnv, set_applyVelBlurEnv,  
01789             get_velBlurTrans, set_velBlurTrans,  
01790             get_memFrugal, set_memFrugal,  
01791             get_pixelSamplerEnable, set_pixelSamplerEnable,  
01792             get_wireThickness, set_wireThickness,  
01793             get_objBlurDuration, set_objBlurDuration,  
01794             get_velBlurDuration, set_velBlurDuration,  
01795             get_antiAliasFilterSz, set_antiAliasFilterSz,  
01796             get_NBlurSamples, set_NBlurSamples,  
01797             get_NBlurFrames, set_NBlurFrames,  
01798             get_autoReflLevels, set_autoReflLevels,  
01799             get_colorClampType, set_colorClampType,  
01800             get_antiAliasFilter, set_antiAliasFilter,  
01801             get_enableSSE, set_enableSSE,  
01802             //new in R6
01803             get_globalSamplerEnabled, set_globalSamplerEnabled, 
01804             get_globalSamplerClassByName, set_globalSamplerClassByName,
01805             get_globalSamplerSampleMaps, set_globalSamplerSampleMaps, 
01806             get_globalSamplerQuality, set_globalSamplerQuality, 
01807             get_globalSamplerAdaptive, set_globalSamplerAdaptive, 
01808             get_globalSamplerAdaptiveThresh, set_globalSamplerAdaptiveThresh,
01809             get_globalSamplerParam1, set_globalSamplerParam1,
01810             get_globalSamplerParam2, set_globalSamplerParam2,
01811         };
01812 
01813     //Function Map For Mixin Interface
01814     //*************************************************
01815     #pragma warning(push)
01816     #pragma warning(disable:4238)
01817     BEGIN_FUNCTION_MAP
01818         PROP_FNS(get_mapping, GetMapping,                       set_mapping, SetMapping, TYPE_BOOL);
01819         PROP_FNS(get_shadows, GetShadows,                       set_shadows, SetShadows, TYPE_BOOL);
01820         PROP_FNS(get_autoReflect, GetAutoReflect,               set_autoReflect, SetAutoReflect, TYPE_BOOL);
01821         PROP_FNS(get_forceWire, GetForceWire,                   set_forceWire, SetForceWire, TYPE_BOOL);
01822         PROP_FNS(get_antialias, GetAntialias,                   set_antialias, SetAntialias, TYPE_BOOL);
01823         PROP_FNS(get_filter, GetFilter,                         set_filter, SetFilter, TYPE_BOOL);
01824         PROP_FNS(get_objMotBlur, GetObjMotBlur,                 set_objMotBlur, SetObjMotBlur, TYPE_BOOL);
01825         PROP_FNS(get_velMotBlur, GetVelMotBlur,                 set_velMotBlur, SetVelMotBlur, TYPE_BOOL);
01826         PROP_FNS(get_applyVelBlurEnv, GetApplyVelBlurEnv,       set_applyVelBlurEnv, SetApplyVelBlurEnv, TYPE_BOOL);
01827         PROP_FNS(get_velBlurTrans, GetVelBlurTrans,             set_velBlurTrans, SetVelBlurTrans, TYPE_BOOL);
01828         PROP_FNS(get_memFrugal, GetMemFrugal,                   set_memFrugal, SetMemFrugal, TYPE_BOOL);
01829         PROP_FNS(get_pixelSamplerEnable, GetPixelSamplerEnable, set_pixelSamplerEnable, SetPixelSamplerEnable, TYPE_BOOL);
01830 
01831         PROP_FNS(get_wireThickness, GetWireThickness,           set_wireThickness, SetWireThickness, TYPE_FLOAT);
01832         PROP_FNS(get_objBlurDuration, GetObjBlurDuration,       set_objBlurDuration, SetObjBlurDuration, TYPE_FLOAT);
01833         PROP_FNS(get_velBlurDuration, GetVelBlurDuration,       set_velBlurDuration, SetVelBlurDuration, TYPE_FLOAT);
01834         PROP_FNS(get_antiAliasFilterSz, GetAntiAliasFilterSz,   set_antiAliasFilterSz, SetAntiAliasFilterSz, TYPE_FLOAT);
01835 
01836         PROP_FNS(get_NBlurSamples, GetNBlurSamples,             set_NBlurSamples, SetNBlurSamples, TYPE_INT);
01837         PROP_FNS(get_NBlurFrames, GetNBlurFrames,               set_NBlurFrames, SetNBlurFrames, TYPE_INT);
01838         PROP_FNS(get_autoReflLevels, GetAutoReflLevels,         set_autoReflLevels, SetAutoReflLevels, TYPE_INT);
01839         PROP_FNS(get_colorClampType, GetColorClampType,         set_colorClampType, SetColorClampType, TYPE_INT);
01840 
01841         PROP_FNS(get_antiAliasFilter, GetAntiAliasFilter,       set_antiAliasFilter, SetAntiAliasFilterRT, TYPE_REFTARG);
01842 
01843         PROP_FNS(get_enableSSE, IsSSEEnabled,                   set_enableSSE, SetEnableSSE, TYPE_BOOL);
01844 
01845         PROP_FNS(get_globalSamplerEnabled, GetGlobalSamplerEnabled,                 set_globalSamplerEnabled, SetGlobalSamplerEnabled, TYPE_BOOL); 
01846         PROP_FNS(get_globalSamplerClassByName, GetGlobalSamplerClassByName,         set_globalSamplerClassByName, SetGlobalSamplerClassByName, TYPE_TSTR_BV);
01847         PROP_FNS(get_globalSamplerSampleMaps, GetGlobalSamplerSampleMaps,           set_globalSamplerSampleMaps, SetGlobalSamplerSampleMaps, TYPE_BOOL);
01848         PROP_FNS(get_globalSamplerQuality, GetGlobalSamplerQuality ,                set_globalSamplerQuality, SetGlobalSamplerQuality, TYPE_FLOAT);
01849         PROP_FNS(get_globalSamplerAdaptive, GetGlobalSamplerAdaptive,               set_globalSamplerAdaptive, SetGlobalSamplerAdaptive, TYPE_BOOL);
01850         PROP_FNS(get_globalSamplerAdaptiveThresh, GetGlobalSamplerAdaptiveThresh,   set_globalSamplerAdaptiveThresh, SetGlobalSamplerAdaptiveThresh, TYPE_FLOAT);
01851         PROP_FNS(get_globalSamplerParam1, GetGlobalSamplerParam1,                   set_globalSamplerParam1, SetGlobalSamplerParam1, TYPE_FLOAT);
01852         PROP_FNS(get_globalSamplerParam2, GetGlobalSamplerParam2,                   set_globalSamplerParam2, SetGlobalSamplerParam2, TYPE_FLOAT);
01853 
01854     END_FUNCTION_MAP
01855     #pragma warning(pop)
01856 
01857     FPInterfaceDesc* GetDesc();    // <-- must implement 
01858         //**************************************************
01859 
01860     void SetAntiAliasFilterRT(ReferenceTarget* op) {
01861         if (op && op->SuperClassID( ) == FILTER_KERNEL_CLASS_ID)
01862             SetAntiAliasFilter(static_cast< FilterKernel* >(op));
01863     }
01864 
01865     virtual float GetWireThickness() = 0;
01866     virtual void SetColorClampType (int i) = 0;
01867     virtual int GetColorClampType () = 0;
01868     virtual float GetObjBlurDuration() = 0;
01869     virtual int GetNBlurSamples() = 0;
01870     virtual int GetNBlurFrames() = 0;
01871     virtual float GetVelBlurDuration() = 0;
01872     virtual void SetApplyVelBlurEnv(BOOL b) = 0;
01873     virtual BOOL GetApplyVelBlurEnv() = 0;
01874     virtual void SetVelBlurTrans(BOOL b) = 0;
01875     virtual BOOL GetVelBlurTrans() = 0;
01876     virtual int GetAutoReflLevels() = 0;
01877     virtual void SetMemFrugal(BOOL b) = 0;
01878     virtual BOOL GetMemFrugal() = 0;
01879     virtual void SetEnableSSE(BOOL b) = 0;
01880     virtual BOOL IsSSEEnabled() = 0;
01881 
01882     //new for R6
01883     virtual BOOL GetGlobalSamplerEnabled() = 0;
01884     virtual void SetGlobalSamplerEnabled(BOOL enable) = 0;
01885     virtual MSTR GetGlobalSamplerClassByName() = 0;
01886     virtual void SetGlobalSamplerClassByName(const MSTR) = 0;
01887     virtual BOOL GetGlobalSamplerSampleMaps() = 0;
01888     virtual void SetGlobalSamplerSampleMaps(BOOL enable) = 0;
01889     virtual float GetGlobalSamplerQuality() = 0;
01890     virtual void SetGlobalSamplerQuality(float f) = 0;
01891     virtual BOOL GetGlobalSamplerAdaptive() = 0;
01892     virtual void SetGlobalSamplerAdaptive(BOOL enable) = 0;
01893     virtual float GetGlobalSamplerAdaptiveThresh() = 0;
01894     virtual void SetGlobalSamplerAdaptiveThresh(float f) = 0;
01895     virtual float GetGlobalSamplerParam1() = 0;
01896     virtual void SetGlobalSamplerParam1(float f) = 0;
01897     virtual float GetGlobalSamplerParam2() = 0;
01898     virtual void SetGlobalSamplerParam2(float f) = 0;
01899 };
01900 
01901 #if defined(SINGLE_SUPERSAMPLE_IN_RENDER)
01902 //--------------------------------------------------------------------------
01903 // Extended Interface into the default scanline renderer, Class_ID(SREND_CLASS_ID,0)
01904 //---------------------------------------------------------------------------
01905 class IScanRenderer3: public IScanRenderer2 {
01906     public:
01907 
01908     virtual float GetSamplerQuality() = 0;
01909     virtual void SetSamplerQuality(float) = 0;
01910 
01911     virtual BOOL GetRenderWatermark() = 0;
01912     virtual void SetRenderWatermark(BOOL on) = 0;
01913     virtual Bitmap* GetWatermarkBitmap() = 0;
01914     virtual void SetWatermarkBitmap(Bitmap* bm) = 0;
01915     virtual int GetWatermarkTop() = 0;
01916     virtual void SetWatermarkTop(int top) = 0;
01917     virtual int GetWatermarkLeft() = 0;
01918     virtual void SetWatermarkLeft(int left) = 0;
01919     virtual float GetWatermarkBlend() = 0;
01920     virtual void SetWatermarkBlend(float blend) = 0;
01921     virtual BOOL GetWatermarkUI() = 0;
01922     virtual void SetWatermarkUI(BOOL on) = 0;
01923 };
01924 #endif  // defined(SINGLE_SUPERSAMPLE_IN_RENDER)
01925 
01926 //==============================================================================
01927 // class IRendererRequirements
01928 //
01929 // This interface is used to query special requirement flags from renderers.
01930 //==============================================================================
01931 #define IRENDERERREQUIREMENTS_INTERFACE_ID Interface_ID(0x27c85c29, 0xfab6ee0) //!< Interface ID for the class IRendererRequirements
01932 class IRendererRequirements : public BaseInterface {
01933 public:
01934 
01935     enum Requirement {
01938         kRequirement_NoPauseSupport = 0,
01943         kRequirement_NoVFB = 1,
01948         kRequirement_DontSaveRenderOutput = 2,
01955         kRequirement8_Wants32bitFPOutput = 3,
01959         kRequirement11_WantsObjectSelection = 4,
01960     };
01961 
01962     // Returns true if the renderer has the given requirement, or returns false otherwise.
01963     virtual bool HasRequirement(Requirement requirement) = 0;
01964 
01965     // -- from BaseInterface
01966     virtual Interface_ID GetID();
01967 };
01968 
01969 #pragma warning(pop)
01970 
01971 inline Interface_ID IRendererRequirements::GetID() {
01972 
01973     return IRENDERERREQUIREMENTS_INTERFACE_ID;
01974 }
01975 
01976 inline IRendererRequirements* GetRendererRequirements(Renderer* renderer) {
01977     return (renderer != NULL) ? static_cast<IRendererRequirements*>(renderer->GetInterface(IRENDERERREQUIREMENTS_INTERFACE_ID)) : NULL;
01978 }
01979 
01980 inline bool RendererHasRequirement(Renderer* renderer, IRendererRequirements::Requirement requirement) {
01981     IRendererRequirements* iRequirements = GetRendererRequirements(renderer);
01982     return (iRequirements != NULL) ? iRequirements->HasRequirement(requirement) : false;
01983 }
01984 
01985