1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Replace markers in Radiance scene description with objects or instances. |
6 |
|
* |
7 |
|
* Created: 17 Feb 1991 Greg Ward |
8 |
|
*/ |
9 |
|
|
10 |
< |
#include <stdio.h> |
10 |
> |
#include <stdlib.h> |
11 |
|
#include <ctype.h> |
12 |
|
#include <math.h> |
13 |
+ |
#include <stdio.h> |
14 |
|
|
15 |
+ |
#include "platform.h" |
16 |
+ |
#include "rtprocess.h" |
17 |
|
#include "fvect.h" |
18 |
|
|
19 |
|
#ifdef M_PI |
20 |
< |
#define PI M_PI |
20 |
> |
#define PI ((double)M_PI) |
21 |
|
#else |
22 |
|
#define PI 3.14159265358979323846 |
23 |
|
#endif |
27 |
|
#define MAXVERT 6 /* maximum number of vertices for markers */ |
28 |
|
#define MAXMARK 32 /* maximum number of markers */ |
29 |
|
|
30 |
– |
#ifdef DCL_ATOF |
31 |
– |
extern double atof(); |
32 |
– |
#endif |
33 |
– |
|
30 |
|
typedef struct { |
31 |
|
short beg, end; /* beginning and ending vertex */ |
32 |
|
float len2; /* length squared */ |
148 |
|
char *fname; |
149 |
|
FILE *fin; |
150 |
|
{ |
151 |
< |
FILE *pin, *popen(); |
151 |
> |
FILE *pin; |
152 |
|
char buf[512], *fgetline(); |
153 |
|
|
154 |
|
fgetline(buf, sizeof(buf), fin); |
170 |
|
char *fname; |
171 |
|
FILE *fin; |
172 |
|
{ |
173 |
+ |
extern char *fgetword(); |
174 |
|
char buf[128], typ[16], nam[128]; |
175 |
|
int i, n; |
176 |
|
register int j; |
195 |
|
goto readerr; |
196 |
|
printf("%d", n); |
197 |
|
for (j = 0; j < n; j++) { |
198 |
< |
if (fscanf(fin, "%s", buf) != 1) |
198 |
> |
if (fgetword(buf, sizeof(buf), fin) == NULL) |
199 |
|
goto readerr; |
200 |
|
if (j%3 == 0) |
201 |
|
putchar('\n'); |
202 |
< |
printf("\t%s", buf); |
202 |
> |
putchar('\t'); |
203 |
> |
fputword(buf, stdout); |
204 |
|
} |
205 |
|
putchar('\n'); |
206 |
|
} |
220 |
|
int n; |
221 |
|
char buf[256]; |
222 |
|
|
223 |
+ |
buf[0] = '\0'; /* bug fix thanks to schorsch */ |
224 |
|
if (m->doxform) { |
225 |
|
sprintf(buf, "xform -e -n %s", mark); |
226 |
|
if (m->modout != NULL) |
261 |
|
|
262 |
|
int |
263 |
|
buildxf(xf, markscale, fin) /* build transform for marker */ |
264 |
< |
char *xf; |
264 |
> |
register char *xf; |
265 |
|
double markscale; |
266 |
|
FILE *fin; |
267 |
|
{ |
328 |
|
if (markscale > 0.0) { /* add scale factor */ |
329 |
|
sprintf(xf, " -s %f", xlen*markscale); |
330 |
|
n += 2; |
331 |
< |
xf += strlen(xf); |
331 |
> |
while (*xf) ++xf; |
332 |
|
} |
333 |
|
/* add rotation */ |
334 |
|
n += addrot(xf, xvec, yvec, zvec); |
335 |
< |
xf += strlen(xf); |
335 |
> |
while (*xf) ++xf; |
336 |
|
/* add translation */ |
337 |
|
n += 4; |
338 |
|
sprintf(xf, " -t %f %f %f", vlist[elist[1].beg][0], |
342 |
|
|
343 |
|
|
344 |
|
addrot(xf, xp, yp, zp) /* compute rotation (x,y,z) => (xp,yp,zp) */ |
345 |
< |
char *xf; |
345 |
> |
register char *xf; |
346 |
|
FVECT xp, yp, zp; |
347 |
|
{ |
348 |
|
int n; |
352 |
|
theta = atan2(yp[2], zp[2]); |
353 |
|
if (!FEQ(theta,0.0)) { |
354 |
|
sprintf(xf, " -rx %f", theta*(180./PI)); |
355 |
< |
xf += strlen(xf); |
355 |
> |
while (*xf) ++xf; |
356 |
|
n += 2; |
357 |
|
} |
358 |
|
theta = asin(-xp[2]); |
359 |
|
if (!FEQ(theta,0.0)) { |
360 |
|
sprintf(xf, " -ry %f", theta*(180./PI)); |
361 |
< |
xf += strlen(xf); |
361 |
> |
while (*xf) ++xf; |
362 |
|
n += 2; |
363 |
|
} |
364 |
|
theta = atan2(xp[1], xp[0]); |
365 |
|
if (!FEQ(theta,0.0)) { |
366 |
|
sprintf(xf, " -rz %f", theta*(180./PI)); |
367 |
< |
/* xf += strlen(xf); */ |
367 |
> |
/* while (*xf) ++xf; */ |
368 |
|
n += 2; |
369 |
|
} |
370 |
|
return(n); |