-
Notifications
You must be signed in to change notification settings - Fork 7
/
draw.h
225 lines (189 loc) · 6.58 KB
/
draw.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
** Daedalus (Version 3.5) File: draw.h
** By Walter D. Pullen, Astara@msn.com, http://www.astrolog.org/labyrnth.htm
**
** IMPORTANT NOTICE: Daedalus and all Maze generation and general
** graphics routines used in this program are Copyright (C) 1998-2024 by
** Walter D. Pullen. Permission is granted to freely use, modify, and
** distribute these routines provided these credits and notices remain
** unmodified with any altered or distributed versions of the program.
** The user does have all rights to Mazes and other graphic output
** they make in Daedalus, like a novel created in a word processor.
**
** More formally: This program is free software; you can redistribute it
** and/or modify it under the terms of the GNU General Public License as
** published by the Free Software Foundation; either version 2 of the
** License, or (at your option) any later version. This program is
** distributed in the hope that it will be useful and inspiring, but
** WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details, a copy of which is in the
** LICENSE.HTM included with Daedalus, and at http://www.gnu.org
**
** This file contains definitions for advanced non-perspective and perspective
** graphics routines, unrelated to Mazes.
**
** Created: 6/15/1990.
** Last code change: 10/30/2024.
*/
/*
******************************************************************************
** Macros
******************************************************************************
*/
#define istarMax 8000
#define GetT3(c, x, y, z, d) \
((int)(((c).Get3(x, y, z) >> ((d) * 6)) & (cTexture-1)))
#define SetT3(c, x, y, z, d, t) ((c).Get3(x, y, z) & \
~((KV)(cTexture-1) << ((d) * 6)) | ((KV)(t) << ((d) * 6)))
#define SetU3(c, x, y, z, f, t) ((c).Get3(x, y, z) & \
~((KV)4095 << ((f) * 12)) | ((KV)(t) << ((f) * 12)))
/*
******************************************************************************
** Types
******************************************************************************
*/
typedef struct _starlocation {
short x; // Horizontal location of star
short y; // Vertical location of star
KV kv; // Color of star
} STAR;
typedef struct _drawsettings {
// Draw settings
int horsiz;
int versiz;
int depsiz;
int horbias;
int verbias;
int hormin;
int vermin;
int depmin;
flag fArrow;
int horv;
int verv;
int theta;
int phi;
int speedm;
int speedr;
flag fRight;
flag fMerge;
// Obscure draw settings
flag fReflect;
flag fSkyShade;
flag fGroundShade;
flag fEdges;
flag fShading;
flag fTouch;
int nBorder;
int nHoriz;
real rScale;
real rxScale;
real ryScale;
real rzScale;
KV kvTrim;
KV kvSkyHi;
KV kvSkyLo;
KV kvGroundHi;
KV kvGroundLo;
KV kvObject;
CVector vLight;
// Inside settings
flag fStar; // Used by Inside view too
int cStar; // Used by Inside view too
int nStereo; // Used by Inside view too
// Macro accessible only settings
long lStarColor; // Used by Inside view too
int nStarSize; // Used by Inside view too
flag fSkyAll; // Used by Inside view too
flag fArrowFree;
int nTrans;
int nFog;
int nWireWidth;
int nWireDistance;
flag fWireSort;
int nFaceOrigin;
flag fStereo3D; // Used by Inside view too
// Internal settings
flag fDidPatch;
int xmax;
real rHoriz;
long cCoorPatch;
STAR *rgstar;
} DS;
typedef struct _coordinates {
real x1, y1, z1;
real x2, y2, z2;
KV kv;
} COOR;
typedef struct _patn {
int x, y, z;
flag fLine;
} PATN;
typedef struct _patr {
real x, y, z;
flag fLine;
} PATR;
#define cPatch 4
typedef struct _patch {
PATR p[cPatch];
real rDistance;
KV kv;
short cpt;
short nTrans;
} PATCH;
extern DS ds;
/*
******************************************************************************
** Render Overview and Pyramid
******************************************************************************
*/
extern flag DrawOverview(CMap &, CONST CMon &);
extern flag DrawOverviewCube(CMap &, CONST CMon3 &);
extern flag DrawOverview2(CMon &);
extern flag DrawOverviewCube2(CMon3 &);
extern flag DrawOverviewAltitude(CMap &, CONST CCol &, int, int);
extern flag DrawPyramid(CMon &, CCol *);
/*
******************************************************************************
** File Reading and Writing Routines
******************************************************************************
*/
#define ReadCoordinates(file, x1, y1, z1, x2, y2, z2) \
fscanf(file, "%lf%lf%lf%lf%lf%lf", x1, y1, z1, x2, y2, z2)
extern long ReadWirelist(COOR **, FILE *);
#define ReadPatch1(file, stat) fscanf(file, "%d", stat)
#define ReadPatch2(file, x1, y1, z1, x2, y2, z2, x3, y3, z3) \
fscanf(file, "%lf%lf%lf%lf%lf%lf%lf%lf%lf", \
x1, y1, z1, x2, y2, z2, x3, y3, z3)
#define ReadPatch3(file, x1, y1, z1) fscanf(file, "%lf%lf%lf", x1, y1, z1)
extern long ReadPatchlist(PATCH **, FILE *);
extern void WriteWireframe(FILE *, CONST COOR *, long);
extern void WritePatches(FILE *, CONST PATCH *, long);
extern void WriteWireframeMetafile(FILE *, CONST COOR *, long);
extern void WriteWireframeVector(FILE *, CONST COOR *, long);
/*
******************************************************************************
** Create Wireframe and Patches
******************************************************************************
*/
extern void WriteCoordinates(COOR *, int, int, int, int, int, int, KV);
extern void WritePatch(PATCH *, PATN[cPatch], flag, KV);
extern long CreateWireframe(CONST CMon3 &, COOR **, flag, CONST CCol *);
extern long CreatePatches(CONST CMon3 &, PATCH **, flag, CONST CCol *);
extern flag FSetWireSize(COOR **, int, int);
extern flag FSetPatchSize(PATCH **, int, int);
extern flag CreateSolids(CONST char *);
/*
******************************************************************************
** Render Perspective
******************************************************************************
*/
extern KV KvStarRandom(void);
extern void CalculateCoordinate(int *, int *, real, real, real);
extern flag FRenderPerspectiveWireCore(CMap &, COOR *, long);
extern flag FRenderPerspectiveWire(CMap &, COOR *, long);
extern flag FRenderPerspectivePatchCore(CMap &, PATCH *, long);
extern flag FRenderPerspectivePatch(CMap &, PATCH *, long);
extern flag FRenderAerial(CMap &, CONST COOR *, long);
extern long ConvertPatchToWire(COOR **, CONST PATCH *, long);
/* draw.h */