⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 render.h

📁 hl2 source code. Do not use it illegal.
💻 H
📖 第 1 页 / 共 2 页
字号:
			INode *vnode,     	// view node (camera or light), or NULL
			ViewParams *viewPar,// view params for rendering ortho or user viewport
			RendParams &rp,  	// common renderer parameters
			HWND hwnd, 				// owner window, for messages
			DefaultLight* defaultLights=NULL, // Array of default lights if none in scene
			int numDefLights=0	// number of lights in defaultLights array
			)=0;
						
		//
		// Render a frame -- will use camera or view from open
		//
		virtual int Render(
			TimeValue t,   			// frame to render.
   			Bitmap *tobm, 			// optional target bitmap
			FrameRendParams &frp,	// Time dependent parameters
			HWND hwnd, 				// owner window
			RendProgressCallback *prog=NULL,
			ViewParams *viewPar=NULL  // override viewPar given on Open.
			)=0;
		virtual void Close(	HWND hwnd )=0;		

		// Adds rollup page(s) to renderer configure dialog
		// If prog==TRUE then the rollup page should just display the parameters
		// so the user has them for reference while rendering, they should not be editable.
		virtual RendParamDlg *CreateParamDialog(IRendParams *ir,BOOL prog=FALSE)=0;
		virtual void ResetParams()=0;
		virtual int	GetAAFilterSupport(){ return 0; } // point sample, no reconstruction filter

	};


class ShadowBuffer;
class ShadowQuadTree;

class RendContext {
	public:
		virtual int Progress(int done, int total) const { return 1; }
		virtual Color GlobalLightLevel() const = 0;
	};

struct SubRendParams {
	RendType rendType;	
	BOOL fieldRender;
	BOOL evenLines; // when field rendering
	BOOL doingMirror;
	BOOL doEnvMap;  // do environment maps?
	int devWidth, devHeight;
	float devAspect;
	int xorg, yorg;           // location on screen of upper left corner of output bitmap
	int xmin,xmax,ymin,ymax;  // area of screen being rendered
	virtual int Execute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0) { return 0; } 
	};

// flags passed to RenderMapsContext::Render()
#define RENDMAP_SHOW_NODE  1  // *Dont* exclude this node from the render.


// A pointer to this data structure is passed to MtlBase::BuildMaps();
// when rendering reflection and refraction maps.
class RenderMapsContext { 
	public:
	    virtual INode *GetNode()=0;
		virtual int NodeRenderID()=0;
		virtual void GetCurrentViewParams(ViewParams &vp)=0;
		virtual void GetSubRendParams(SubRendParams &srp)=0;
		virtual int SubMtlIndex()=0;
		virtual void SetSubMtlIndex(int mindex)=0;
	    virtual void FindMtlPlane(float pl[4])=0;
		virtual void FindMtlScreenBox(Rect &sbox, Matrix3* viewTM=NULL, int mtlIndex=-1)=0;
		virtual Box3 CameraSpaceBoundingBox()=0;
		virtual Box3 ObjectSpaceBoundingBox()=0;
		virtual Matrix3 ObjectToWorldTM()=0;
		virtual RenderGlobalContext *GetGlobalContext() { return NULL; }
		// ClipPlanes is a pointer to an array of Point4's,  each of which
		// represents a clip plane.  nClip Planes is the number of planes (up to 6);
		// The planes are in View space.
		virtual	int Render(Bitmap *bm, ViewParams &vp, SubRendParams &srp, Point4 *clipPlanes=NULL, int nClipPlanes=0)=0; 
		virtual int Execute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0) { return 0; } 
	};	




#define DONT_CLIP 1.0E38f

class SFXParamDlg {
	public:
		virtual Class_ID ClassID()=0;
		virtual void SetThing(ReferenceTarget *m)=0;
		virtual ReferenceTarget* GetThing()=0;
		virtual void SetTime(TimeValue t) { }		
		virtual void DeleteThis()=0;		
		virtual int Execute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0) { return 0; } 
		virtual void InvalidateUI() { }	

	};


// Special Effect: Base class for Atmospherics, Effects, shaders
class SpecialFX: public ReferenceTarget {
	public:
		TSTR name;
		// This name will appear in the track view and the list of current atmospheric effects.
		virtual TSTR GetName() {return _T("");}		

		// Is effect active 
		virtual BOOL Active(TimeValue t) { 
			return !TestAFlag(A_ATMOS_DISABLED); 
			}

		// Called when the render steps to a new frame
		virtual	void Update(TimeValue t, Interval& valid) {}

		// Saves and loads name. These should be called at the start of
		// a plug-in's save and load methods.
		CoreExport IOResult Save(ISave *isave);
		CoreExport IOResult Load(ILoad *iload);

		// If an atmospheric has references to gizmos or other objects in the scene it can optionally 
		// provide access to the object list.
		virtual int NumGizmos() {return 0;}
		virtual INode *GetGizmo(int i) {return NULL;}
		virtual void DeleteGizmo(int i) {}
		virtual void AppendGizmo(INode *node) {}
		virtual BOOL OKGizmo(INode *node) { return FALSE; } // approve a node for possible use as gizmo
		virtual void EditGizmo(INode *node) {} // selects this gizmo & displays params for it if any
		virtual	void InsertGizmo(int i, INode *node) { assert(0); } // must be defined to use DeleteGizmoRestore

		// Animatable overides...
		CoreExport SvGraphNodeReference SvTraverseAnimGraph(IGraphObjectManager *gom, Animatable *owner, int id, DWORD flags);
	};


// Classes used for implementing UNDO in Atmosphere and Effects classes.
class AppendGizmoRestore: public RestoreObj {
	public:
		SpecialFX *fx;
		INode *node;
		AppendGizmoRestore(SpecialFX *f, INode *n) {	fx= f;	node = n;	}
		void Redo() {	fx->AppendGizmo(node);		}
		void Restore(int isUndo) {	fx->DeleteGizmo(fx->NumGizmos()-1);	} 
		TSTR Description() { return TSTR("AppendGizmoRestore"); }
	};

class DeleteGizmoRestore: public RestoreObj {
	public:
		SpecialFX *fx;
		INode *node;
		int num;
		DeleteGizmoRestore(SpecialFX *a, INode *n, int i) {	fx = a; node = n; num = i;	}
		void Redo() {	fx->DeleteGizmo(num);		}
		void Restore(int isUndo) {	fx->InsertGizmo(num,node);		} 
		TSTR Description() { return TSTR("DeleteGizmoRestore"); }
	};

//--- Atmospheric plug-in interfaces -----------------------------------------------


// Atmospheric plug-in base class

// Returned by an  Atmospheric when it is asked to put up its rollup page.
typedef SFXParamDlg AtmosParamDlg;

class Atmospheric : public SpecialFX {
	public:
		RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, 
	         PartID& partID,  RefMessage message) {return REF_SUCCEED;}
		SClass_ID SuperClassID() {return ATMOSPHERIC_CLASS_ID;}
		
		// Saves and loads name. These should be called at the start of
		// a plug-in's save and load methods.
		IOResult Save(ISave *isave) { return SpecialFX::Save(isave); }
		IOResult Load(ILoad *iload) { return SpecialFX::Load(iload); }

		// Put up a modal dialog that lets the user edit the plug-ins parameters.
		virtual AtmosParamDlg *CreateParamDialog(IRendParams *ip) {return NULL;}
		// Implement this if you are using the ParamMap2 AUTO_UI system and the 
		// atmosphere has secondary dialogs that don't have the effect as their 'thing'.
		// Called once for each secondary dialog for you to install the correct thing.
		// Return TRUE if you process the dialog, false otherwise.
		virtual BOOL SetDlgThing(AtmosParamDlg* dlg) { return FALSE; }

		// This is the function that is called to apply the effect.
		virtual void Shade(ShadeContext& sc,const Point3& p0,const Point3& p1,Color& color, Color& trans, BOOL isBG=FALSE)=0;


	};

#define SFXBASE_CHUNK	0x39bf
#define SFXNAME_CHUNK	0x0100

// Chunk IDs saved by base class
#define ATMOSHPERICBASE_CHUNK	SFXBASE_CHUNK
#define ATMOSHPERICNAME_CHUNK	SFXNAME_CHUNK


//--------------------------------------------------------------------------
// Interface into the default scanline renderer, Class_ID(SREND_CLASS_ID,0)
//---------------------------------------------------------------------------
class FilterKernel;
class IScanRenderer: public Renderer {
	public:
	virtual void SetAntialias(BOOL b) = 0;
	virtual BOOL GetAntialias() = 0;
	virtual void SetFilter(BOOL b) = 0;
	virtual BOOL GetFilter() = 0;
	virtual void SetShadows(BOOL b) = 0;
	virtual BOOL GetShadows() = 0;
	virtual void SetMapping(BOOL b) = 0;
	virtual BOOL GetMapping() = 0;
	virtual void SetForceWire(BOOL b) = 0;
	virtual BOOL GetForceWire() = 0;
	virtual	void SetAutoReflect(BOOL b)=0;
	virtual	BOOL GetAutoReflect()=0;
	virtual void SetObjMotBlur(BOOL b) = 0;
	virtual BOOL GetObjMotBlur() = 0;
	virtual void SetVelMotBlur(BOOL b) = 0;
	virtual BOOL GetVelMotBlur() = 0;

	// Obsolete, use setfiltersz. pixel sz = 1.0 for all filtering
	virtual void SetPixelSize(float size) = 0;
	
	virtual void SetAutoReflLevels(int n) = 0;
	virtual void SetWireThickness(float t) = 0;
	virtual void SetObjBlurDuration(float dur) = 0;
	virtual void SetVelBlurDuration(float dur) = 0;
	virtual void SetNBlurFrames(int n) = 0;
	virtual void SetNBlurSamples(int n) = 0;
	virtual void SetMaxRayDepth(int n) = 0;
	virtual int GetMaxRayDepth() { return 7; }

	virtual void SetAntiAliasFilter( FilterKernel * pKernel ) = 0;
	virtual FilterKernel * GetAntiAliasFilter() = 0;
	virtual void SetAntiAliasFilterSz(float size) = 0;
	virtual float GetAntiAliasFilterSz() = 0;

	virtual void SetPixelSamplerEnable( BOOL on ) = 0;
	virtual BOOL GetPixelSamplerEnable() = 0;
};


// Render Post effects;

// Returned by an  effect when it is asked to put up its rollup page.
typedef SFXParamDlg EffectParamDlg;

class CheckAbortCallback {
	public:
	virtual BOOL Check()=0;  // returns TRUE if user has done something to cause an abort.
	virtual	BOOL Progress(int done, int total)=0;
	virtual void SetTitle(const TCHAR *title)=0;
	};

class Effect : public SpecialFX {
	public:
		RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, 
	         PartID& partID,  RefMessage message) {return REF_SUCCEED;}
		SClass_ID SuperClassID() {return RENDER_EFFECT_CLASS_ID;}

		// Saves and loads name. These should be called at the start of
		// a plug-in's save and load methods.
		IOResult Save(ISave *isave) { return SpecialFX::Save(isave); }
		IOResult Load(ILoad *iload) { return SpecialFX::Load(iload); }

		// Put up a dialog that lets the user edit the plug-ins parameters.
		virtual EffectParamDlg *CreateParamDialog(IRendParams *ip) {return NULL;}
		// Implement this if you are using the ParamMap2 AUTO_UI system and the 
		// effect has secondary dialogs that don't have the effect as their 'thing'.
		// Called once for each secondary dialog for you to install the correct thing.
		// Return TRUE if you process the dialog, false otherwise.
		virtual BOOL SetDlgThing(EffectParamDlg* dlg) { return FALSE; }

		// What G-buffer channels does this Effect require in the output bitmap?
		virtual DWORD GBufferChannelsRequired(TimeValue t) { return 0; /*BMM_CHAN_NONE;*/ }

		// This is the function that is called to apply the effect.
		virtual void Apply(TimeValue t, Bitmap *bm, RenderGlobalContext *gc, CheckAbortCallback *cb )=0;

	};

// Chunk IDs saved by base class
#define EFFECTBASE_CHUNK	SFXBASE_CHUNK
#define EFFECTNAME_CHUNK	SFXNAME_CHUNK

////////////////////////////////////////////////////////////////////////
//
// Filter Kernel Plug-ins;
//
#define AREA_KERNEL_CLASS_ID			0x77912301
#define DEFAULT_KERNEL_CLASS_ID			AREA_KERNEL_CLASS_ID

// Returned by a kernel when it is asked to put up its rollup page.
typedef SFXParamDlg FilterKernelParamDlg;

class FilterKernel : public SpecialFX {
	public:
		RefResult NotifyRefChanged( Interval changeInt, 
									RefTargetHandle hTarget, 
							        PartID& partID, 
									RefMessage message ) { return REF_SUCCEED; }

		SClass_ID SuperClassID() { return FILTER_KERNEL_CLASS_ID; }
		
		// Saves and loads name. These should be called at the start of
		// a plug-in's save and load methods.
		IOResult Save(ISave *isave) { return SpecialFX::Save(isave); }
		IOResult Load(ILoad *iload) { return SpecialFX::Load(iload); }

		// Put up a dialog that lets the user edit the plug-ins parameters.
		virtual FilterKernelParamDlg *CreateParamDialog( IRendParams *ip ) {return NULL;}

		// filter kernel section
		// This is the function that is called to sample kernel values.
		virtual double KernelFn( double x, double y = 0.0 )=0;

		// integer number of pixels from center to filter 0 edge, must not truncate filter
		// x dimension for 2D filters
		virtual long GetKernelSupport()=0;
		// for 2d returns y support, for 1d returns 0
		virtual long GetKernelSupportY()=0;

		virtual bool Is2DKernel()=0;
		virtual bool IsVariableSz()=0;
		// 1-D filters ignore the y parameter
		virtual void SetKernelSz( double x, double y = 0.0 )=0;
		virtual void GetKernelSz( double& x, double& y )=0;

		// returning true will disable the built-in normalizer
		virtual bool IsNormalized(){ return FALSE; }

		// this is for possible future optimizations, not sure its needed
		virtual bool HasNegativeLobes()=0;

		virtual TCHAR* GetDefaultComment()=0;

		// there are 2 optional 0.0 ...1.0 parameters, for whatever
		virtual long GetNFilterParams(){ return 0; }
		virtual TCHAR * GetFilterParamName( long nParam ){ return _T(""); }
		virtual double GetFilterParamMax( long nParam ){ return 1.0; }
		virtual double GetFilterParam( long nParam ){ return 0.0; }
		virtual void SetFilterParam( long nParam, double val ){};
	};

// Chunk IDs saved by base class
#define FILTERKERNELBASE_CHUNK	0x39bf
#define FILTERKERNELNAME_CHUNK	0x0100


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -