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

📄 graphics3d.h

📁 liu7788414
💻 H
字号:
#ifndef CGRAPHIC3D_H
#define CGRAPHIC3D_H

#include "define.h"
#include "Matrix.h"
#include "rendertarget.h"
#include "texture.h"

class CGraphics3D
{
protected:
	enum	{
		COLORKEY = 0x0,
		LINEZDIFFERIGNORE = 10,
		ZDIFFERIGNORE = 15,
		ZRATIOIGNORE = 15,
		MAXTEXTURES = 40
	};
	// camera transformation matrix
	// world->view
	CMatrix44 m_matView;
	// self->world
	CMatrix44 m_matWorld;
	// self->inverse world
	CMatrix44 m_matInvWorld;
	// self->camera
	CMatrix44 m_matTransCamera, m_matTrans;
	// self->inverse camera
	CMatrix44 m_matInvCamera, m_matInvTrans;
	
	CTexture *m_curTexture;
	//CEngine * m_pEngine;
	char m_TextureNames[MAXTEXTURES][MAX_PATH];
	CRenderTarget *m_pCurrentRenderTarget;
	int m_curTextureid;
	// env map
	int m_envTextureid;
	CTexture* m_envTexture;

	// z attr
	// near z
	int m_zNear;
	// far z
	int m_zFar;
	// scr dist from eye
	int m_zDist;

	int m_FOV;

	// frustum face normal
	Vector4s m_eye, m_leftFace, m_rightFace, m_upFace, m_bottomFace;

	int m_random;
	int m_onBallLight;
	int m_faceLight;

	// wireframe only
	void Skeleton(Point *pPoint, int = 0);

public:
	CGraphics3D(void);
	~CGraphics3D();

	// skeleton mode
	int m_skeleton;

	int m_textureCount;
	CTexture *m_pTextures;

	// filename; 1: store as index, 0: expand
	char LoadTexture(char *, int = 1);
	void SetTexture(int index);
	void SetEnvTexture(int index);
	void SetTexture(CTexture*const);
	void SetEye(Vector4s *v);	
	Vector4s GetEye() {return m_eye;};
	void ReleaseTextures() {m_textureCount = 0;	m_envTexture = NULL;};
//	CEngine * GetEngine() const	{	return m_pEngine;	}
	void SetRenderTarget(CRenderTarget *pTarget)	{	m_pCurrentRenderTarget = pTarget;	}
	void EnableBallLight(int);
	void SetMatrix(int MatrixType, CMatrix44 *pMat); 

	// precise mat for model or not
	void SetPreciseMat(int = 0);
	CMatrix44 * GetMatrix(int MatrixType) {	
		switch (MatrixType)	{
			case 0:
				return &m_matWorld;
			case 1:
				return &m_matView;
	}};

	// render triangle strip
	void RenderIndexdPrimitives(Vertex *pVertics, Texcoord *pTexcoords, Face *pindics, int length);

	// render single triangle with perspective correction
	void RenderTriangle2(Point *pPoint);

	// render single triangle without perspective correction
	void RenderFlatTriangle(Point *pPoint);

	// frustum cut: polygon vertex list
	void FrustumCut(Point *pPoint);

	// ball
	void DrawBall();

	// bounding box check, param: diagonally points
	int BBCheck(const Vertex&, const Vertex&) const;
	int BBCheck(const Vector4s&) const;

	// get scr pos of 3d points: x,y,z in 3d; x,y in 2d
	int get2DPos(int, int, int, int&, int&) const;

	// set fov
	void setZDist(int);

	//get fov
	int getZDist(void);

	// dynamic object texture: tex id, src buffer
	void WriteOnTex(int, unsigned short *);

	// for stats
	int m_pixelWritten;
	int m_triRendered;
	int m_flatRendered;
	int m_alphaRendered;

	// render attr
	int *recipTable;
	int m_renderParam;
};

#endif

⌨️ 快捷键说明

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