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

📄 define.h

📁 liu7788414
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef DEFINE_H
#define DEFINE_H

//defination for render states
/*
typedef enum _RENDERSTATETYPE {
	G3DRS_ZENABLE = 0,
	G3DRS_CULLMODE = 1,
	G3DRS_ENABLEALPHABLEND = 2,
	G3DRS_ALPHABLENDMODE = 3,
	G3DRS_ENABLECOLORKEY = 4,
	G3DRS_COUNT,
}	RENDERSTATETYPE;	

typedef enum _G3DZBUFFERTYPE {
	G3DZB_FALSE = 0,
	G3DZB_TRUE = 1,
} G3DZBUFFERTYPE;

typedef enum _G3DCULLMODETYPE {
	G3DCULL_NONE = 1,
  G3DCULL_CW = 2,
  G3DCULL_CCW = 3,		
} G3DCULLMODETYPE;

typedef enum _G3DENABLEALPHATYPE {
	G3DALPHA_FALSE = 0,
	G3DALPHA_TRUE = 1,
} G3DENABLEALPHATYPE;

typedef enum _G3DENABLECOLORKEYTYPE {
	G3DCOLORKEY_FALSE = 0,
	G3DCOLORKEY_TRUE = 1,
} G3DENABLECOLORKEYTYPE;

typedef enum _G3DBLENDTYPE {
	G3DBLEND_ADD = 0,
	G3DBLEND_HALF = 1,
	G3DBLEND_SUB = 2,
} G3DBLENDTYPE;

//end defines
*/

const int RP_FLAT = 1;
const int RP_NOFRUSTUM = 2;
const int RP_MIRROR = 4;
const int RP_TRANSPARENT = 8;
const int RP_COLORKEY = 16;
const int RP_LIGHTNING = 32;
const int RP_EXTENDED = 64;

#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define min(a,b)    (((a) < (b)) ? (a) : (b))

struct Vertex
{
public:
	short x;
	short y;
	short z;
	Vertex() {x=0; y=0; z=0;}
  Vertex(short sx, short sy, short sz) {x = sx; y=sy; z=sz;	};
	//
	//to save memory, we remove the normal from vertex struct, we could add it back as need
	/*short normal_x;
	short normal_y;
	short normal_z;*/
	void	operator-=(const Vertex& v) {x-=v.x;y-=v.y;z-=v.z;}
	void VMax(Vertex & v2) { x = max(x, v2.x); y = max(y, v2.y); z = max(z, v2.z);	};
	void VMin(Vertex & v2) { x = min(x, v2.x); y = min(y, v2.y); z = min(z, v2.z);	};
};

typedef struct
{
	short u;
	short v;
}Texcoord;

typedef struct
{
	char texid;
	bool bAlphablend;
	char alphaBlendMode;
	char cullMode; 
}Material;

typedef struct
{
	char id;
	short width;
	short height;
}Texture;


typedef struct
{
	short ver[3];
	short tex[3];
	int normalx;
	int normaly;
	int normalz;
}Face;

typedef struct	{
	int x, y, z, u, v;
}Point;

typedef struct	{
	int x, y, z;
}Point3d;

const int RAD_FRAG = 31;
const Point3d SphereNormal[(RAD_FRAG+1)*(RAD_FRAG+1)] =	{
	{0,0,-16384}, {495,0,-16376}, {991,0,-16354}, {1486,0,-16316}, 
	{1982,0,-16263}, {2479,0,-16195}, {2976,0,-16111}, {3473,0,-16011}, 
	{3971,0,-15895}, {4470,0,-15762}, {4970,0,-15611}, {5471,0,-15443}, 
	{5973,0,-15256}, {6477,0,-15049}, {6981,0,-14821}, {7488,0,-14572}, 
	{7996,0,-14299}, {8507,0,-14002}, {9019,0,-13677}, {9534,0,-13323}, 
	{10052,0,-12937}, {10573,0,-12515}, {11098,0,-12052}, {11627,0,-11542}, 
	{12161,0,-10978}, {12700,0,-10350}, {13247,0,-9640}, {13802,0,-8827}, 
	{14369,0,-7870}, {14954,0,-6694}, {15569,0,-5101}, {16349,0,-1057}, 
	{0,495,-16376}, {495,495,-16369}, {991,495,-16346}, {1486,495,-16308}, 
	{1982,495,-16256}, {2479,495,-16187}, {2976,496,-16103}, {3473,496,-16003}, 
	{3971,496,-15887}, {4470,496,-15754}, {4970,497,-15603}, {5471,497,-15435}, 
	{5973,497,-15247}, {6477,498,-15041}, {6982,498,-14813}, {7488,499,-14563}, 
	{7997,499,-14291}, {8507,500,-13993}, {9020,501,-13668}, {9535,501,-13314}, 
	{10053,502,-12927}, {10574,503,-12504}, {11099,504,-12041}, {11628,505,-11531}, 
	{12161,506,-10966}, {12701,508,-10336}, {13248,509,-9626}, {13803,511,-8811}, 
	{14370,513,-7851}, {14955,515,-6671}, {15571,519,-5069}, {0, 0, -16384}, 
	{0,991,-16354}, {495,991,-16346}, {991,991,-16323}, {1486,991,-16286}, 
	{1983,991,-16233}, {2479,991,-16164}, {2976,992,-16080}, {3474,992,-15980}, 
	{3972,993,-15864}, {4471,993,-15730}, {4971,994,-15579}, {5472,994,-15411}, 
	{5974,995,-15223}, {6477,996,-15015}, {6982,997,-14787}, {7489,998,-14537}, 
	{7997,999,-14264}, {8508,1000,-13965}, {9021,1002,-13640}, {9536,1003,-13284}, 
	{10054,1005,-12896}, {10575,1007,-12472}, {11100,1009,-12007}, {11629,1011,-11496}, 
	{12163,1013,-10929}, {12703,1016,-10296}, {13250,1019,-9582}, {13806,1022,-8762}, 
	{14374,1026,-7795}, {14959,1031,-6601}, {15577,1038,-4969}, {0, 0, -16384}, 
	{0,1486,-16316}, {495,1486,-16308}, {991,1486,-16286}, {1487,1487,-16248}, 
	{1983,1487,-16195}, {2479,1487,-16126}, {2976,1488,-16042}, {3474,1489,-15941}, 
	{3972,1489,-15825}, {4472,1490,-15691}, {4972,1491,-15539}, {5473,1492,-15370}, 
	{5975,1493,-15182}, {6479,1495,-14974}, {6984,1496,-14745}, {7490,1498,-14494}, 
	{7999,1499,-14219}, {8510,1501,-13919}, {9022,1503,-13592}, {9538,1506,-13235}, 
	{10056,1508,-12846}, {10578,1511,-12419}, {11103,1514,-11952}, {11632,1517,-11437}, 
	{12166,1520,-10866}, {12707,1524,-10229}, {13254,1529,-9508}, {13810,1534,-8679}, 
	{14379,1540,-7699}, {14966,1548,-6483}, {15588,1558,-4796}, {0, 0, -16384}, 
	{0,1982,-16263}, {495,1982,-16256}, {991,1983,-16233}, {1487,1983,-16195}, 
	{1983,1983,-16142}, {2480,1984,-16073}, {2977,1985,-15988}, {3475,1985,-15887}, 
	{3973,1986,-15770}, {4473,1988,-15635}, {4973,1989,-15483}, {5474,1990,-15313}, 
	{5976,1992,-15124}, {6480,1994,-14915}, {6985,1995,-14684}, {7492,1998,-14432}, 
	{8001,2000,-14156}, {8512,2002,-13855}, {9025,2005,-13526}, {9541,2008,-13166}, 
	{10059,2011,-12774}, {10581,2015,-12345}, {11106,2019,-11874}, {11636,2023,-11354}, 
	{12171,2028,-10778}, {12712,2033,-10134}, {13260,2040,-9404}, {13817,2047,-8562}, 
	{14387,2055,-7563}, {14977,2065,-6312}, {15604,2080,-4539}, {0, 0, -16384}, 
	{0,2479,-16195}, {495,2479,-16187}, {991,2479,-16164}, {1487,2479,-16126}, 
	{1984,2480,-16073}, {2481,2481,-16003}, {2978,2482,-15918}, {3476,2483,-15817}, 
	{3975,2484,-15699}, {4474,2485,-15563}, {4974,2487,-15411}, {5476,2489,-15239}, 
	{5978,2491,-15049}, {6482,2493,-14838}, {6988,2495,-14607}, {7495,2498,-14353}, 
	{8004,2501,-14075}, {8515,2504,-13771}, {9028,2507,-13439}, {9544,2511,-13077}, 
	{10063,2515,-12682}, {10585,2520,-12248}, {11111,2525,-11772}, {11641,2530,-11247}, 
	{12177,2536,-10663}, {12718,2543,-10010}, {13267,2551,-9268}, {13826,2560,-8409}, 
	{14398,2571,-7383}, {14990,2584,-6084}, {15627,2604,-4175}, {0, 0, -16384}, 
	{0,2976,-16111}, {496,2976,-16103}, {992,2976,-16080}, {1488,2976,-16042}, 
	{1985,2977,-15988}, {2482,2978,-15918}, {2979,2979,-15832}, {3477,2980,-15730}, 
	{3976,2982,-15611}, {4476,2984,-15475}, {4976,2985,-15321}, {5478,2988,-15149}, 
	{5981,2990,-14957}, {6485,2993,-14745}, {6990,2996,-14511}, {7498,2999,-14255}, 
	{8007,3002,-13974}, {8518,3006,-13668}, {9032,3010,-13333}, {9548,3015,-12967}, 
	{10068,3020,-12567}, {10590,3025,-12129}, {11117,3031,-11646}, {11648,3038,-11114}, 
	{12184,3046,-10521}, {12726,3054,-9855}, {13276,3063,-9098}, {13837,3074,-8216}, 
	{14411,3088,-7155}, {15008,3105,-5790}, {15659,3131,-3661}, {0, 0, -16384}, 
	{0,3473,-16011}, {496,3473,-16003}, {992,3474,-15980}, {1489,3474,-15941}, 
	{1985,3475,-15887}, {2483,3476,-15817}, {2980,3477,-15730}, {3479,3479,-15627}, 
	{3978,3480,-15507}, {4478,3482,-15370}, {4978,3485,-15215}, {5480,3487,-15041}, 
	{5983,3490,-14847}, {6488,3493,-14633}, {6994,3497,-14397}, {7502,3500,-14138}, 
	{8011,3505,-13855}, {8523,3509,-13545}, {9037,3514,-13206}, {9554,3519,-12836}, 
	{10073,3525,-12430}, {10597,3532,-11985}, {11124,3539,-11496}, {11655,3547,-10954}, 
	{12192,3556,-10350}, {12736,3566,-9669}, {13287,3577,-8891}, {13850,3590,-7981}, 
	{14427,3606,-6874}, {15031,3628,-5415}, {15709,3665,-2867}, {0, 0, -16384}, 
	{0,3971,-15895}, {496,3971,-15887}, {993,3972,-15864}, {1489,3972,-15825}, 
	{1986,3973,-15770}, {2484,3975,-15699}, {2982,3976,-15611}, {3480,3978,-15507}, 
	{3980,3980,-15386}, {4480,3982,-15247}, {4981,3985,-15091}, {5483,3988,-14915}, 
	{5987,3991,-14719}, {6491,3994,-14502}, {6998,3998,-14264}, {7506,4003,-14002}, 
	{8016,4008,-13715}, {8528,4013,-13401}, {9042,4019,-13057}, {9560,4025,-12682}, 
	{10080,4032,-12270}, {10604,4039,-11817}, {11132,4048,-11319}, {11664,4057,-10765}, 
	{12202,4067,-10147}, {12747,4079,-9449}, {13301,4092,-8646}, {13866,4108,-7699}, 
	{14447,4127,-6530}, {15060,4154,-4935}, {0, 0, -16384}, {0, 0, -16384}, 
	{0,4470,-15762}, {496,4470,-15754}, {993,4471,-15730}, {1490,4472,-15691}, 

⌨️ 快捷键说明

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