face.h

来自「手机 GAME c++ 版」· C头文件 代码 · 共 144 行

H
144
字号
////////////////////////////////////////////////////////////////////////
//
// Face.h
//
// Copyright (c) 2003 Nokia Phones Ltd  All rights reserved.
//
////////////////////////////////////////////////////////////////////////

#ifndef _FACE_H
#define _FACE_H

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

#include "Geometry3D.h"

////////////////////////////////////////////////////////////////////////

class TCamera;
class TScanConverter;

////////////////////////////////////////////////////////////////////////

class TShadedColor
	{
	//
	// NB: This class assumes 16 bpp and a pixel format of 444 RGB.
	//
	public:
		TShadedColor(){}
		TShadedColor( TUint16 aFlatColor );
		TUint16 GetValue( TInt aIllumination );

		enum
		{
			illuminationUnityLog = 8,
			illuminationUnity	 = ( 1 << illuminationUnityLog ),
		};

	private:

		enum
		{
			redMask		= 0x0f00,
			greenMask	= 0x00f0,
			blueMask	= 0x000f,
		};

		TInt	iFlatColor;
	};

////////////////////////////////////////////////////////////////////////

class TScreenVertex
	{
	public:
		TVector3	iSpacePos;
		TInt		iScreenX;
		TInt		iScreenY;
		TUint16		iOutcodes;
	};

////////////////////////////////////////////////////////////////////////

class TFace
	{
	public:
		TFace(){ iNumVerts = 0; }
		TFace(TUint16 aFlatColor, TInt aNumVerts, TInt aVertIndex[], const TVector3 * aVertPtr);

		void SetIllumination( TInt aIllumination ){ iIllumination = aIllumination; }
		
		void Render
			(
			TScanConverter &aScanConverter, 
			TMathLookup &aMath, 
			const TScreenVertex * aTransVertPtr, 
			TVector3 &aCameraInModelSpace
			);

	private:
		
		enum
		{
			maxNumVerts		=  8,
		};

		TShadedColor	iBaseColor;
		TInt			iIllumination;

		TInt		iNumVerts;
		TInt		iVertIndex[maxNumVerts];

		TPlane		iPlane;
	};

////////////////////////////////////////////////////////////////////////

class TClipFace
	{
	public:

		TClipFace(TUint16 aFlatColor);
		void Reset();

		void AddVertex(const TScreenVertex &aVertex);

		void Render( TScanConverter &aScanConverter, TMathLookup &aMath );
		void RenderUnclipped( TScanConverter &aScanConverter, TMathLookup &aMath );

		void ClipSelf
			( 
			TClipFace &aDestFace, 
			TPlane &aClipPlane, 
			TInt aBoundIndex, 
			TCamera &aCamera, 
			TMathLookup &aMath 
			);

		TBool IsDrawable();

	private:
		
		enum
		{
			maxNumVerts	=  16,
		};

		TUint16			iFlatColor;
		TInt			iNumVerts;
		TScreenVertex	iVertex[maxNumVerts];

		TUint16			iOutcodeOr;
		TUint16			iOutcodeAnd;
	};

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

#endif

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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