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

📄 chrender.h

📁 Windows上的MUD客户端程序
💻 H
📖 第 1 页 / 共 2 页
字号:
		GxTransform3Wf GetWorldToCameraTransform();
		GxTransform3Wf GetCameraToClipTransform();
		GxTransform3Wf GetClipToScreenTransform();

		ChRenderContext *SetModelTransform(GxTransform3Wf& transform);  
		ChQvTransformationInstance *GetDefaultTransform();
		QvNode *GetCurrentCamera() {return m_pCamera;};
		ChRenderContext *SetCurrentCamera(QvNode *pCamera = 0);
		ChRenderContext *SelectCamera(int iCamIndex);
		int GetCameraIndex();
		QvNode *GetDefaultCamera() {return m_pDefaultCamera;};
		ChRenderContext *NewDefaultCamera();
		bool IsCameraDefault() {return (m_pDefaultCamera == m_pCamera);};
		QvNode *GetCurrentProperty(ChQvState *pState, QvState::StackIndex index);
		ChRenderContext* AddCamera(QvNode *pCamera, string &strName);
		ChRenderContext* RemoveCamera(string &strName);
		int GetCameraCount(){return m_cameraCount;};
		bool GetCamera(int i, string &strName, QvNode **pCamera);
		#if defined(CH_USE_3DR)
		ChRenderContext* Add(ChQvLightInstance *pLightInst);
		ChRenderContext* Remove(ChQvLightInstance *pLightInst);
	 	inline int GetNextLight()
	 		{ 						
	 			if(m_numLightsOn < CH_MAX_LIGHTS) return m_numLightsOn;
	 			else return -1;
	 		};
	 	inline ChRenderContext*  TurnOnALight(bool boolOn = true)
	 		{
	 			if(boolOn)++m_numLightsOn;
	 			else --m_numLightsOn;
	 			return this;
	 		};
		#else
		#endif

		#if defined(CH_USE_3DR)
		void CreateHeadlight( GxVec3f& loc, GxVec3f& dir, QvState* state );
		#elif defined(CH_USE_RLAB) || defined(CH_USE_D3D)
		void CreateHeadlight( ); // attached to camera
		void DestroyHeadlight( );
		void AdjustHeadlight();
		#endif


		bool Draw();
		#if (defined(CH_USE_RLAB) || defined(CH_USE_D3D))
		void OnWindowActivate(UINT nState, BOOL bMinimized);
		void OnWindowPaint(HDC hDC);
		#endif

		ChRenderContext*  SetRoot(ChQvInstance *pRootInstance);
		inline ChQvInstance*  GetRoot() {return m_pRootInstance;};
		ChRenderContext*  ResetScene();

		float GetAdjustedLODRange(float range);
		ChQvSphereCacheData *GetSphere(int level);
		float GetQuality();
		#if defined(CH_USE_3DR)
 		ChTextureHandle LoadDIBTexture( ChDib *pDibIn, chuint32 luChromaClr, chuint uOption );
		#endif
		float GetPixelAngle();

		ChRenderContext * ClearTransformStack();
		ChRenderContext * ComposeTransform(GxTransform3Wf& transform);	// apply to object end
		ChRenderContext * PopTransform();
		ChRenderContext * PopTransform(GxTransform3Wf& transform);
		ChRenderContext * PushTransform();

		#if defined(CH_USE_3DR)
		void RebuildTransformStack( ChQvState* pState );
		#else
		inline ChNrFrame GetFrame() { return m_sceneFrame;};
		inline ChNrViewport GetViewport() {return m_viewport;};
		void Resize( int width = 0, int height = 0, bool boolForceNew = false );
		#endif

		void LockQv();
		void UnlockQv();

		#if defined(CH_USE_RLAB) || defined(CH_USE_D3D)
		ChDotsCache* GetDotsCache() {return &m_dotsCache;};
		bool IsAnchor( int iX, int iY, pChQvAnchorSensor &pAnchor );

		void LockScene();
		void UnlockScene();

		void LockConstruction();
		void UnlockConstruction();

		bool ConstructScene(ChQvInstance *pRoot);
		ChRenderContext *StartConstruction(ChQvInstance *pRoot = 0);
		void IncrementShapeCount()			{ m_iShapeCount++; }


		HANDLE GetEndConstructEvent()		{ return m_hConstructDoneEvent; }
		int    GetTotalReConstructEvents()	{ return maxEvents; }
		HANDLE* GetReConstructEvents()		{ return m_hReconstructEvents; }

		bool ReconstructInstance( DWORD lEvent ) 	{ return (lEvent == reconstructInstance); }
		bool AbortReconstruct( DWORD lEvent ) 	  	{ return (lEvent == abortReconstruct); }
		bool TerminateReconstruct( DWORD lEvent ) 	{ return (lEvent == endThread); }


		long NumPendingConstructionThreads(); 
		bool AddConstruction(ChQvInstance *pRoot );
		bool RemoveConstruction(ChQvInstance *pRoot );

		bool ContinueConstruction()		{ return m_boolContinueConstruction; };

		bool AddSynchReconstruction(int iWork);
		bool AddReconstruction(ChQvInstance *pInst);
		void ClearReconstruction( );
		bool RemoveReconstruction(ChQvInstance *pInst);
		ChQvInstance * GetNextReconstruction(bool boolRemove = false);
		void LockReconstruction();
		void UnlockReconstruction();
		void LowerConstructionThreads(bool);

		ChRenderContext *ForceUpdate();

		void Animate( bool boolRun = true ) { m_boolAnimating = boolRun;};
		bool IsAnimating( ) {return m_boolAnimating; };

		float GetCollisionRange();
		float GetCollisionRange(GxVec3f &look, bool boolRelative = false);
		bool GetHitPoint(int iX, int iY, GxVec3f &pt);
		float GetAvatarRadius();

		void AdjustTransparency(ChQvMaterialMap &map);
		#endif
  	
  		bool IsThreaded()					{ return m_boolThreaded; }
		int	 GetShapeCount()				{ return m_iShapeCount; }
		bool IsDirty() { return m_boolDirty;};
		ChRenderContext *  SetDirty(bool dirty = true) { m_boolDirty = dirty; return this;};
		void OptimizationChanged(bool boolDirty = true);

		bool ProcessEvent(ChEventMsg *pEventMsg);

		#if (defined(CH_USE_RLAB) || defined(CH_USE_D3D))
		ChNrFrame SetBackgroundImage(ChQvBackgroundInfoData *pData);
		bool MoveBackgroundImage();
		void OnDestroyBackground();
		QvNode *m_pBackGroundNode;
		ChNrFrame	m_backgroundFrame;
		#endif
		#if (defined(CH_USE_RLAB) || defined(CH_USE_D3D))
		ChNativeContext CreateDevice(int width, int height);
		ChNrFrame CreateFrame(ChNrFrame parent);
		ChNrMesh CreateMesh();
		ChNrFace CreateFace();
		ChNrLight CreateLight(ChNrLightType type, const ChColor & color);
		ChNrLight CreateLightRGB(ChNrLightType type, ChNrValue r, ChNrValue g, ChNrValue b);
		ChNrViewport CreateViewport(ChNativeContext dev, ChNrFrame camera, DWORD dwXPos, DWORD dwYPos, DWORD dwWidth, DWORD dwHeight);
		ChNrMaterial CreateMaterial(ChNrValue ks, ChNrValue pow);
		ChTextureHandle CreateTexture(ChNrImage *pImage );

		#if (defined(CH_USE_D3D))
		bool ChRenderContext::InitOffscreenDevice(ChDevice3D &device, int width, int height);
		bool ChRenderContext::InitWindowDevice(ChDevice3D &device, int width, int height);
		#endif

		#endif
							 // call this only from main thread
		inline void AddToTextureQueue( ChMazeTextureHTTPReq* pReq )	
						{
							m_textureQueue.AddHead( pReq );
						}
		void Add(ChQvTimeSensorRenderData *pSensor);
		void Remove(ChQvTimeSensorRenderData *pSensor);
		void RemoveTimeSensors();
		void TickSensors(double t = 0.);

	protected:
		#if defined(CH_USE_3DR)
		ApplyQvTail( QvElement* elt );
		#endif
		void TraverseLights();
		ChRenderContext* Reset();
		ChRenderContext* RemoveLights();

		#if defined(CH_USE_3DR)
		#else
		ChTransformStack *m_pStack;
		#endif

		protected:
		ChRenderContext* RemoveCameras();
		#if defined(CH_USE_RLAB) || defined(CH_USE_D3D)
		bool DoBackground();
		ChTexture *m_pBackgroundTexture;

		#endif

		void UpdateOptimization();
		void ProcessTextureQueue();  // call this only from the main thread

	#if (defined(CH_USE_D3D))

	public:
		HRESULT EnumDriver(LPGUID lpGuid, LPSTR lpDeviceDescription, LPSTR lpDeviceName,
        	LPD3DDEVICEDESC lpHWDesc, LPD3DDEVICEDESC lpHELDesc);

	protected:
		class ChD3dDriver
		{
			protected:
				string m_name;
				GUID 	m_guid;
				bool	m_boolHardware;
				bool	m_boolMono;

			public:
				ChD3dDriver() :
				   m_boolHardware(false), m_boolMono(false)
				   { };

				void Set(const string &name, const GUID &guid, bool boolHardware, bool boolMono)
				{
					m_name = name;
					m_guid = guid;
					m_boolHardware = boolHardware;
					m_boolMono = boolMono;
				};

				string &GetName() { return m_name;};
				GUID &GetGUID() {return m_guid;};
				bool IsHardware() {return m_boolHardware; };
				bool IsMono() {return m_boolMono;};
		};

		ChD3dDriver	m_drivers[renderOptimizationCount];

		int GetBPP();

		BOOL ChRenderContext::EnumDrivers();
		void SetBackgroundColor(unsigned long color);

	#endif

};

// Iterator for all the available cameras.
// Guaranteed to list in same order as World file Switch{ }
class ChMazeWnd;

class ChCameraIterator
{
	friend class ChRenderContext;

	public:
		ChCameraIterator() : m_pRC(0) {};
		ChCameraIterator(ChRenderContext *pRC) : m_pRC(0) 
		{
			Attach(m_pRC);
		};

		ChCameraIterator(ChMazeWnd *pWnd) : m_pRC(0) 
		{
			Attach(pWnd);
		};

		virtual ~ChCameraIterator() {};

		ChCameraIterator* Attach(ChRenderContext *pRC)
		{
			m_pRC = pRC;
			return this;
		};

		ChCameraIterator* Attach(ChMazeWnd *pWnd);

		bool Iterate();

		virtual bool DoCamera(string &strName, QvNode *pCamera) = 0;

	protected:

		 ChRenderContext *m_pRC;

};




#endif // _CHRENDER_H

⌨️ 快捷键说明

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