| 60 |
|
#define MG_EINCL 7 /* error in included file */ |
| 61 |
|
#define MG_EMEM 8 /* out of memory */ |
| 62 |
|
#define MG_ESEEK 9 /* file seek error */ |
| 63 |
+ |
#define MG_EBADMAT 10 /* bad material specification */ |
| 64 |
|
|
| 65 |
< |
#define MG_NERRS 10 |
| 65 |
> |
#define MG_NERRS 11 |
| 66 |
|
|
| 67 |
|
extern char *mg_err[MG_NERRS]; |
| 68 |
|
|
| 141 |
|
* Definitions for 3-d vector manipulation functions |
| 142 |
|
*/ |
| 143 |
|
|
| 144 |
< |
typedef double FVECT[3]; |
| 144 |
> |
#ifdef SMLFLT |
| 145 |
> |
#define FLOAT float |
| 146 |
> |
#define FTINY (1e-3) |
| 147 |
> |
#else |
| 148 |
> |
#define FLOAT double |
| 149 |
> |
#define FTINY (1e-6) |
| 150 |
> |
#endif |
| 151 |
> |
#define FHUGE (1e10) |
| 152 |
|
|
| 153 |
+ |
typedef FLOAT FVECT[3]; |
| 154 |
+ |
|
| 155 |
+ |
#define VCOPY(v1,v2) ((v1)[0]=(v2)[0],(v1)[1]=(v2)[1],(v1)[2]=(v2)[2]) |
| 156 |
+ |
#define DOT(v1,v2) ((v1)[0]*(v2)[0]+(v1)[1]*(v2)[1]+(v1)[2]*(v2)[2]) |
| 157 |
+ |
#define VSUM(vr,v1,v2,f) ((vr)[0]=(v1)[0]+(f)*(v2)[0], \ |
| 158 |
+ |
(vr)[1]=(v1)[1]+(f)*(v2)[1], \ |
| 159 |
+ |
(vr)[2]=(v1)[2]+(f)*(v2)[2]) |
| 160 |
+ |
|
| 161 |
+ |
#define is0vect(v) (DOT(v,v) < FTINY*FTINY) |
| 162 |
+ |
|
| 163 |
+ |
#define round0(x) if (x <= FTINY && x >= -FTINY) x = 0 |
| 164 |
+ |
|
| 165 |
|
#ifdef NOPROTO |
| 166 |
|
extern double normalize(); /* normalize a vector */ |
| 167 |
|
#else |
| 174 |
|
*/ |
| 175 |
|
|
| 176 |
|
typedef struct { |
| 177 |
< |
double cx, cy; /* XY chromaticity coordinates */ |
| 177 |
> |
float cx, cy; /* XY chromaticity coordinates */ |
| 178 |
|
} C_COLOR; /* color context */ |
| 179 |
|
|
| 180 |
|
typedef struct { |
| 181 |
< |
double rd; /* diffuse reflectance */ |
| 181 |
> |
char *name; /* material name */ |
| 182 |
> |
int clock; /* incremented each change -- resettable */ |
| 183 |
> |
float rd; /* diffuse reflectance */ |
| 184 |
|
C_COLOR rd_c; /* diffuse reflectance color */ |
| 185 |
< |
double td; /* diffuse transmittance */ |
| 185 |
> |
float td; /* diffuse transmittance */ |
| 186 |
|
C_COLOR td_c; /* diffuse transmittance color */ |
| 187 |
< |
double ed; /* diffuse emittance */ |
| 187 |
> |
float ed; /* diffuse emittance */ |
| 188 |
|
C_COLOR ed_c; /* diffuse emittance color */ |
| 189 |
< |
double rs; /* specular reflectance */ |
| 189 |
> |
float rs; /* specular reflectance */ |
| 190 |
|
C_COLOR rs_c; /* specular reflectance color */ |
| 191 |
< |
double rs_a; /* specular reflectance roughness */ |
| 192 |
< |
double ts; /* specular transmittance */ |
| 191 |
> |
float rs_a; /* specular reflectance roughness */ |
| 192 |
> |
float ts; /* specular transmittance */ |
| 193 |
|
C_COLOR ts_c; /* specular transmittance color */ |
| 194 |
< |
double ts_a; /* specular transmittance roughness */ |
| 194 |
> |
float ts_a; /* specular transmittance roughness */ |
| 195 |
|
} C_MATERIAL; /* material context */ |
| 196 |
|
|
| 197 |
|
typedef struct { |
| 198 |
|
FVECT p, n; /* point and normal */ |
| 199 |
|
} C_VERTEX; /* vertex context */ |
| 200 |
|
|
| 201 |
+ |
#define isgrey(cxy) ((cxy)->cx > .31 && (cxy)->cx < .35 && \ |
| 202 |
+ |
(cxy)->cy > .31 && (cxy)->cy < .35) |
| 203 |
+ |
|
| 204 |
|
#define C_DEFCOLOR {.333,.333} |
| 205 |
< |
#define C_DEFMATERIAL {0.,C_DEFCOLOR,0.,C_DEFCOLOR,0.,C_DEFCOLOR,\ |
| 206 |
< |
0.,C_DEFCOLOR,0.,0.,C_DEFCOLOR,0.} |
| 205 |
> |
#define C_DEFMATERIAL {NULL,1,0.,C_DEFCOLOR,0.,C_DEFCOLOR,0.,C_DEFCOLOR,\ |
| 206 |
> |
0.,C_DEFCOLOR,0.,0.,C_DEFCOLOR,0.} |
| 207 |
|
#define C_DEFVERTEX {{0.,0.,0.},{0.,0.,0.}} |
| 208 |
|
|
| 209 |
|
extern C_COLOR *c_ccolor; /* the current color */ |
| 233 |
|
|
| 234 |
|
#ifdef NOPROTO |
| 235 |
|
extern int obj_handler(); /* handle an object entity */ |
| 236 |
+ |
extern void obj_clear(); /* clear object stack */ |
| 237 |
|
#else |
| 238 |
|
extern int obj_handler(int, char **); /* handle an object entity */ |
| 239 |
+ |
extern void obj_clear(void); /* clear object stack */ |
| 240 |
|
#endif |
| 241 |
|
|
| 242 |
|
/************************************************************************** |
| 243 |
|
* Definitions for hierarchical transformation handler |
| 244 |
|
*/ |
| 245 |
|
|
| 246 |
< |
typedef double MAT4[4][4]; |
| 246 |
> |
typedef FLOAT MAT4[4][4]; |
| 247 |
|
|
| 248 |
|
#ifdef BSD |
| 249 |
|
#define copymat4(m4a,m4b) bcopy((char *)m4b,(char *)m4a,sizeof(MAT4)) |
| 262 |
|
/* regular transformation */ |
| 263 |
|
typedef struct { |
| 264 |
|
MAT4 xfm; /* transform matrix */ |
| 265 |
< |
double sca; /* scalefactor */ |
| 265 |
> |
FLOAT sca; /* scalefactor */ |
| 266 |
|
} XF; |
| 267 |
|
|
| 268 |
|
#define identxf(xp) (void)(setident4((xp)->xfm),(xp)->sca=1.0) |
| 297 |
|
extern void xf_xfmvect(); /* transform vector */ |
| 298 |
|
extern void xf_rotvect(); /* rotate vector */ |
| 299 |
|
extern double xf_scale(); /* scale a value */ |
| 300 |
+ |
extern void xf_clear(); /* clear xf stack */ |
| 301 |
|
|
| 302 |
|
/* The following are support routines you probably won't call directly */ |
| 303 |
|
|
| 308 |
|
|
| 309 |
|
#else |
| 310 |
|
|
| 311 |
< |
extern int xf_handler(); /* handle xf entity */ |
| 312 |
< |
extern void xf_xfmpoint(); /* transform point */ |
| 313 |
< |
extern void xf_xfmvect(); /* transform vector */ |
| 314 |
< |
extern void xf_rotvect(); /* rotate vector */ |
| 315 |
< |
extern double xf_scale(); /* scale a value */ |
| 311 |
> |
extern int xf_handler(int, char **); /* handle xf entity */ |
| 312 |
> |
extern void xf_xfmpoint(FVECT, FVECT); /* transform point */ |
| 313 |
> |
extern void xf_xfmvect(FVECT, FVECT); /* transform vector */ |
| 314 |
> |
extern void xf_rotvect(FVECT, FVECT); /* rotate vector */ |
| 315 |
> |
extern double xf_scale(double); /* scale a value */ |
| 316 |
> |
extern void xf_clear(void); /* clear xf stack */ |
| 317 |
|
|
| 318 |
|
/* The following are support routines you probably won't call directly */ |
| 319 |
|
|