This repository has been archived by the owner on Jul 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
engine3d.h
140 lines (104 loc) · 1.99 KB
/
engine3d.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#define vbn 512
#define MAXDATA 262144
#define POINTS 1
#define WIRE 2
#define FLAT 4
#define GOURAUD 8
#define ENVMAP 16
#define TEXTURE 32
#define VBALLS 0
#define TEXTUREPLASMA 128
#define ZBUFFER 256
#define LIGHTVIEW 0
#define LIGHTMOVE 1
#define PI 3.14151693
#define D2R 180.0/PI
typedef struct vector3d
{
int x;
int y;
int z;
} vector3d;
typedef struct point2d
{
int x;
int y;
unsigned short c;
} point2d;
typedef struct point3d
{
int x;
int y;
int z;
unsigned short c;
} point3d;
typedef struct texture
{
unsigned int tshr;
unsigned short *bitmap;
}texture;
typedef struct material
{
int rmode;
int nshade;
int ntexture;
unsigned short **shade;
texture **txtr;
} material;
typedef struct tcord
{
int u, v;
} tcord;
typedef struct poly2d
{
int p0; tcord tc0;
int p1; tcord tc1;
int p2; tcord tc2;
int c;
int m;
} poly2d;
typedef struct line2d
{
int p0;
int p1;
int c;
}line2d;
typedef struct rot3d
{
float x;
float y;
float z;
}rot3d;
typedef struct pos3d
{
float x;
float y;
float z;
}pos3d;
typedef struct object3d
{
int npts, npls, nlns;
point3d *point;
poly2d *poly;
line2d *line;
vector3d *normal;
vector3d *pt_normal;
material *mtrl;
rot3d rot;
pos3d pos;
}object3d;
vector3d CrossProduct(vector3d v1, vector3d v2);
int DotProduct(vector3d v1, vector3d v2);
vector3d Normalize(vector3d v);
vector3d NegVec(vector3d v);
void Init3d();
void RunScene3d(unsigned short *vram, int sn);
void Calc3d(object3d *obj);
void rotate3d (object3d *obj);
void translate3d (object3d *obj);
void project3d (object3d *obj);
void rotate3d_normals (object3d *obj);
void rotate3d_pt_normals (object3d *obj);
void CalcPointColor(object3d *obj);
void CalcPolyColor(object3d *obj);
void quicksort (int lo, int hi, int data[]);