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

📄 chrender.h

📁 Windows上的MUD客户端程序
💻 H
📖 第 1 页 / 共 2 页
字号:
/*----------------------------------------------------------------------------
                        _                              _ _       
        /\             | |                            | (_)      
       /  \   _ __   __| |_ __ ___  _ __ ___   ___  __| |_  __ _ 
      / /\ \ | '_ \ / _` | '__/ _ \| '_ ` _ \ / _ \/ _` | |/ _` |
     / ____ \| | | | (_| | | | (_) | | | | | |  __/ (_| | | (_| |
    /_/    \_\_| |_|\__,_|_|  \___/|_| |_| |_|\___|\__,_|_|\__,_|

    The contents of this file are subject to the Andromedia Public
	License Version 1.0 (the "License"); you may not use this file
	except in compliance with the License. You may obtain a copy of
	the License at http://www.andromedia.com/APL/

    Software distributed under the License is distributed on an
	"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
	implied. See the License for the specific language governing
	rights and limitations under the License.

    The Original Code is Pueblo client code, released November 4, 1998.

    The Initial Developer of the Original Code is Andromedia Incorporated.
	Portions created by Andromedia are Copyright (C) 1998 Andromedia
	Incorporated.  All Rights Reserved.

	Andromedia Incorporated                         415.365.6700
	818 Mission Street - 2nd Floor                  415.365.6701 fax
	San Francisco, CA 94103

    Contributor(s):
	--------------------------------------------------------------------------
	   Chaco team:  Dan Greening, Glenn Crocker, Jim Doubek,
	                Coyote Lussier, Pritham Shetty.

					Wrote and designed original codebase.

------------------------------------------------------------------------------

	Declaration for the ChRenderContext and ChQvRenderData classes and derivations, 
	which are used to store renderer specific data for 3d graphics renderers for contexts
	and in QvNodes. 

----------------------------------------------------------------------------*/

// $Header: /home/cvs/chaco/modules/client/msw/ChGraphx/ChRender.h,v 2.59 1996/07/16 20:13:32 jimd Exp $
//
#if !defined( _CHRENDER_H )
#define _CHRENDER_H

#include "ChGrRend.h"
#include <ChSplay.h>

#include <ChGraphx.h>
#include "ChGrType.h"
#include "GxTrnsfm.h"
#include "ChColor.h"

#include <QvState.h>
#include "QvNode.h"
#include "QvInfo.h"
#include "QvWWWInline.h"
#ifdef HUGE
#undef HUGE
#endif

//#include "ChGrVw.h"

class ChRenderContext;
class ChQvState;
class ChQvInstance;
class ChQvLightInstance;
class ChQvShapeInstance;
class ChQvTransformationInstance;
class ChQvSphereCacheData;
class ChCameraEntry;
class ChEventMsg;
class ChQvBackgroundInfoData;
class ChMazeTextureHTTPReq;
class ChScrollWnd;
class ChQvTimeSensorRenderData;

#if !defined( ChViewBaseClass )
	#if defined( CH_VRML_PLUGIN )
	#define ChViewBaseClass		CWnd
	#elif defined( CH_VRML_VIEWER )
	#define ChViewBaseClass		CView
	#else
	#define ChViewBaseClass		ChScrollWnd
	#endif
#endif

// Constant that's close enough to zero for our purposes, to prevent underflow and
// divide by zero problems
#define SMIDGEON	(1e-12) 

// Sphere tesselation limits
#define CH_MAX_SPHERE_LEVEL		10
#define CH_MIN_SPHERE_LEVEL		1


#if defined(CH_USE_3DR)
#define CH_MAX_LIGHTS	 G3D_MAX_LIGHTS
#else
#define CH_MAX_LIGHTS	 100000L	// No set limit
#endif


#if defined( CH_USE_RLAB ) || defined(CH_USE_D3D)
UINT ConstructionThread( LPVOID pData );
UINT ReConstructInstanceThread( LPVOID pData );

// This class is used to pass data to the construction thread.
class ChUnderConstruction
{
	public:
		ChUnderConstruction(ChRenderContext *pContext, ChQvInstance *pRoot)
			: m_pContext(pContext), m_pRoot(pRoot) {};
		
		ChRenderContext	 	*GetContext() {return m_pContext;};
		ChQvInstance 		*GetRoot() {return m_pRoot;};

	protected:
		ChRenderContext	 	*m_pContext;
		ChQvInstance 		*m_pRoot;
		ChPtrList<ChQvInstance>	m_usedInstances;
};

#endif

#define RELEASE_INTERFACE(intfc)	\
		if(intfc) { (intfc)->Release(); (intfc)= 0; }



class ChTransformStack: public ChList<GxTransform3Wf>
{
	public:
		ChTransformStack() : ChList<GxTransform3Wf>() {} ;
		virtual ~ChTransformStack() {};
};

class ChTexture;
class ChDotsCache: public ChPtrSplay<ChTexture>
{
	public:
		ChDotsCache() : ChPtrSplay<ChTexture>() {} ;
		virtual ~ChDotsCache() {};
};

class ChDib;
class QvNode;
class QvInfo;
class ChQvAnchorSensor;
typedef ChQvAnchorSensor * pChQvAnchorSensor;
class ChCameraIterator;
class ChCollisionView;
class ChQvMaterialMap;
class ChDevice3D;

/*----------------------------------------------------------------------------
	ChRenderContext class
----------------------------------------------------------------------------*/

class ChRenderContext
{
	friend class ChCameraIterator;

	protected:
		#if defined( CH_USE_3DR )

		G3dHandle_t		m_hGC;				// only sometimes valid
		ChNativeContext	m_hRC;
		HDC				m_hDC;

		#elif defined(CH_USE_RLAB) || defined(CH_USE_D3D)
		// Microsoft Reality Lab or D3D
		enum tagEvents { reconstructInstance = 0, abortReconstruct, endThread, maxEvents };
		enum tagConsts { MaxWorkPerRender = 50 };

		ChNativeContext	m_hRC;
		HDC				m_hDC;
		ChNrFrame			m_sceneFrame;
		ChNrFrame			m_cameraFrame;
		ChNrFrame			m_headlightFrame;
		ChNrViewport		m_viewport;

		CRITICAL_SECTION 	m_sceneCriticalSection;
		CRITICAL_SECTION 	m_constructionCriticalSection;
		CRITICAL_SECTION 	m_reconstructionCriticalSection;
		HANDLE				m_hReconstructEvents[maxEvents];
		HANDLE				m_hConstructDoneEvent;
		bool				m_boolContinueConstruction;

		#if defined(CH_USE_D3D)
		LPDIRECTDRAW	m_DD;           /* DirectDraw object */
		LPDIRECT3D		m_D3D;           /* Direct3D (Immediate Mode) object */
		LPDIRECT3DRM	m_D3DRM;           /* Direct3DRM object */

		LPDIRECTDRAWCLIPPER m_DDClipper;/* DirectDrawClipper object for window */

		#endif
		#endif // 3DR

		CRITICAL_SECTION 	m_qvCriticalSection;
 	
 		bool				m_boolThreaded;
			   
		ChViewBaseClass* 				m_pWnd;
		ChShadingLevel					m_userShading;
		QvNode							**m_ppDefaults;
		bool							m_boolDirty;
		bool							m_boolSettingsDirty;
		// Scene State
		int								m_iShapeCount;
		#if defined( CH_USE_3DR )
		GxVec3f 						m_cameraLoc;  // do we need w too?
		#endif // 3DR
		ChQvInstance					*m_pRootInstance;
		QvNode*							m_pCamera;
		QvNode*							m_pDefaultCamera;
		ChPtrList<ChCameraEntry>		m_cameras;
		int 							m_cameraCount;
		#if defined( CH_USE_3DR )
		ChPtrList<ChQvLightInstance>	m_lights;
		int								m_numLightsOn;
		#else
			// lights are in scene for RL
		#endif
		float							m_moveQuality;
		float							m_standingQuality;
		ChQvSphereCacheData				*m_pSpheres[CH_MAX_SPHERE_LEVEL+1];
		#if defined(CH_USE_RLAB) || defined(CH_USE_D3D)
		ChDotsCache						m_dotsCache;
		ChPtrList<ChQvInstance>			m_constructionThreadList;
		ChPtrList<ChQvInstance>			m_reconstructionThreadList;
		ChCollisionView	 				*m_pCollisionSensor;
		float							m_maxTransparency;
		#endif
		ChPtrList<ChMazeTextureHTTPReq>	m_textureQueue;

		int								m_iTotalWork;
		int								m_iFrameCount;
		bool							m_boolAnimating;
		ChPtrList<ChQvTimeSensorRenderData>	m_timeSensors;

	public:
		ChRenderContext();
		virtual ~ChRenderContext();

		void Init( ChViewBaseClass* pWnd, CDC* pDC );
		void Term();

		void AbortConstruction();


		#if defined(CH_USE_3DR)
		inline ChRenderContext* SetGC( G3dHandle_t hGC ) { m_hGC = hGC; return this; }
		inline G3dHandle_t GetGC() { return m_hGC; }
		#endif

		inline ChRenderContext* SetRC( ChNativeContext hRC ) { m_hRC = hRC; return this; }
		inline ChRenderContext* SetDC( HDC hDC ) { m_hDC = hDC; return this; }
		inline ChNativeContext GetRC() { return m_hRC; }
		inline HDC GetDC() { return m_hDC; }
		inline ChViewBaseClass* GetWnd() { return m_pWnd; }

		ChRenderContext* SetTexture( ChTextureHandle hTex = 0 ); 
		ChTextureHandle GetTexture(); 
		void SetModulation( bool boolUseTexture = true, bool boolPureEmissive = false );
		
		ChRenderContext* SetShading( ChQvShapeInstance *pInstance );

		#if defined(CH_USE_3DR)
		inline void SetShadingPref( ChShadingLevel	userShading )
			{ m_userShading = userShading; };

		inline ChRenderContext *SetCameraLoc(GxVec3f &cameraLoc) { m_cameraLoc = cameraLoc; return this;};
		inline GxVec3f GetCameraLoc() {return m_cameraLoc;};
		#else
		ChRenderContext *SetCameraLoc(GxVec3f &cameraLoc);
		GxVec3f GetCameraLoc();
		GxVec3f GetCameraUp();
		GxVec3f GetCameraDir();
		#endif
 		Ch3DViewerMode GetViewerMode();
		int GetFrameCount() { return m_iFrameCount;};

		// These 4 transforms yield the standard pipeline
		GxTransform3Wf GetModelTransform();	// Renderer's current Model to world

⌨️ 快捷键说明

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