forked from quadrant04/SEProject-FTS-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefs.h
executable file
·121 lines (106 loc) · 2.82 KB
/
defs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef _DEFS_H
#define _DEFS_H
typedef double Flt;
typedef double Vec[3];
typedef Flt Matrix[4][4];
#define MakeVector(x, y, z, v) (v)[0]=(x),(v)[1]=(y),(v)[2]=(z)
#define VecNegate(a) (a)[0]=(-(a)[0]); (a)[1]=(-(a)[1]); (a)[2]=(-(a)[2]);
#define VecDot(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])
#define VecLen(a) ((a)[0]*(a)[0]+(a)[1]*(a)[1]+(a)[2]*(a)[2])
#define VecLenSq(a) sqrtf((a)[0]*(a)[0]+(a)[1]*(a)[1]+(a)[2]*(a)[2])
#define VecCopy(a,b) (b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];
#define VecAdd(a,b,c) (c)[0]=(a)[0]+(b)[0]; (c)[1]=(a)[1]+(b)[1]; (c)[2]=(a)[2]+(b)[2]
#define VecSub(a,b,c) (c)[0]=(a)[0]-(b)[0]; (c)[1]=(a)[1]-(b)[1]; (c)[2]=(a)[2]-(b)[2]
#define VecS(A,a,b) (b)[0]=(A)*(a)[0]; (b)[1]=(A)*(a)[1]; (b)[2]=(A)*(a)[2]
#define VecAddS(A,a,b,c) (c)[0]=(A)*(a)[0]+(b)[0]; (c)[1]=(A)*(a)[1]+(b)[1]; (c)[2]=(A)*(a)[2]+(b)[2]
#define VecCross(a,b,c) (c)[0]=(a)[1]*(b)[2]-(a)[2]*(b)[1]; (c)[1]=(a)[2]*(b)[0]-(a)[0]*(b)[2]; (c)[2]=(a)[0]*(b)[1]-(a)[1]*(b)[0]
#define VecZero(v) (v)[0]=0.0;(v)[1]=0.0;v[2]=0.0
#define ABS(a) (((a)<0)?(-(a)):(a))
#define SGN(a) (((a)<0)?(-1):(1))
#define SGND(a) (((a)<0.0)?(-1.0):(1.0))
typedef struct t_rect {
int left;
int top;
int right;
int bot;
int width;
int height;
int center;
int centerx;
int centery;
} Rect;
typedef struct t_mouse {
int x,y;
int lastx,lasty;
int lbuttondown;
} Mouse;
typedef struct t_bsphere {
Vec center;
Flt radius;
Flt radiusSqr;
} Bsphere;
typedef struct t_bbox {
Flt min[3];
Flt max[3];
} Bbox;
typedef struct t_texmap {
int xres, yres;
unsigned char *c;
unsigned int *i;
} Texmap;
typedef struct t_screen {
int x_res, y_res;
int screen_x_res, screen_y_res;
float gl_perspective_viewangle;
Flt xcenter, ycenter;
Flt fy_res, fx_res;
} Screen;
#define MAX_LIGHTS (4)
typedef struct t_lights {
int onoff;
int nlights;
Vec light;
float glAmb[4];
float glDif[4];
float glPos[4];
} Lights;
typedef struct t_keys {
int autorepeatstate, shiftstate, ctrlstate, shiftlockstate;
} Keys;
typedef struct t_camera {
Vec pos;
Vec move;
Vec dir;
Vec rot;
Flt ang;
Flt tilt;
Matrix m;
} Camera;
typedef struct t_mats {
Matrix worldSpace;
Matrix cameraSpace;
Matrix playerSpace;
} Mats;
typedef struct t_frustum {
Flt frontPlaneDistance;
Vec frontPlaneNormal;
Vec frontPlanePoint;
Flt farPlaneDistance;
Vec farPlanePoint;
Flt farObjectPlaneDistance;
Vec farObjectPlanePoint;
Flt missile_view_distance2;
//#1 is left plane normal
//#2 is right plane normal
//#3 is top plane normal
//#4 is bottom plane normal
//#5 is front plane normal
//#6 is far plane normal
Vec planes[6];
Flt glplanesd[6][4];
float glplanesf[6][4];
float glFarPlaneDistance;
float glNearPlaneDistance;
Vec save_planes[6];
} Frustum;
#endif