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 |
|
* |
8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdio.h> |
11 |
+ |
#include <stdlib.h> |
12 |
|
#include <ctype.h> |
13 |
|
#include <math.h> |
14 |
|
|
25 |
|
#define MAXVERT 6 /* maximum number of vertices for markers */ |
26 |
|
#define MAXMARK 32 /* maximum number of markers */ |
27 |
|
|
30 |
– |
#ifdef DCL_ATOF |
31 |
– |
extern double atof(); |
32 |
– |
#endif |
33 |
– |
|
28 |
|
typedef struct { |
29 |
|
short beg, end; /* beginning and ending vertex */ |
30 |
|
float len2; /* length squared */ |
192 |
|
goto readerr; |
193 |
|
printf("%d", n); |
194 |
|
for (j = 0; j < n; j++) { |
195 |
< |
if (fscanf(fin, "%s", buf) != 1) |
195 |
> |
if (fgetword(buf, sizeof(buf), fin) == NULL) |
196 |
|
goto readerr; |
197 |
|
if (j%3 == 0) |
198 |
|
putchar('\n'); |
199 |
< |
printf("\t%s", buf); |
199 |
> |
putchar('\t'); |
200 |
> |
fputword(buf, stdout); |
201 |
|
} |
202 |
|
putchar('\n'); |
203 |
|
} |
217 |
|
int n; |
218 |
|
char buf[256]; |
219 |
|
|
220 |
+ |
buf[0] = '\0'; /* bug fix thanks to schorsch */ |
221 |
|
if (m->doxform) { |
222 |
|
sprintf(buf, "xform -e -n %s", mark); |
223 |
|
if (m->modout != NULL) |
258 |
|
|
259 |
|
int |
260 |
|
buildxf(xf, markscale, fin) /* build transform for marker */ |
261 |
< |
char *xf; |
261 |
> |
register char *xf; |
262 |
|
double markscale; |
263 |
|
FILE *fin; |
264 |
|
{ |
325 |
|
if (markscale > 0.0) { /* add scale factor */ |
326 |
|
sprintf(xf, " -s %f", xlen*markscale); |
327 |
|
n += 2; |
328 |
< |
xf += strlen(xf); |
328 |
> |
while (*xf) ++xf; |
329 |
|
} |
330 |
|
/* add rotation */ |
331 |
|
n += addrot(xf, xvec, yvec, zvec); |
332 |
< |
xf += strlen(xf); |
332 |
> |
while (*xf) ++xf; |
333 |
|
/* add translation */ |
334 |
|
n += 4; |
335 |
|
sprintf(xf, " -t %f %f %f", vlist[elist[1].beg][0], |
339 |
|
|
340 |
|
|
341 |
|
addrot(xf, xp, yp, zp) /* compute rotation (x,y,z) => (xp,yp,zp) */ |
342 |
< |
char *xf; |
342 |
> |
register char *xf; |
343 |
|
FVECT xp, yp, zp; |
344 |
|
{ |
345 |
|
int n; |
349 |
|
theta = atan2(yp[2], zp[2]); |
350 |
|
if (!FEQ(theta,0.0)) { |
351 |
|
sprintf(xf, " -rx %f", theta*(180./PI)); |
352 |
< |
xf += strlen(xf); |
352 |
> |
while (*xf) ++xf; |
353 |
|
n += 2; |
354 |
|
} |
355 |
|
theta = asin(-xp[2]); |
356 |
|
if (!FEQ(theta,0.0)) { |
357 |
|
sprintf(xf, " -ry %f", theta*(180./PI)); |
358 |
< |
xf += strlen(xf); |
358 |
> |
while (*xf) ++xf; |
359 |
|
n += 2; |
360 |
|
} |
361 |
|
theta = atan2(xp[1], xp[0]); |
362 |
|
if (!FEQ(theta,0.0)) { |
363 |
|
sprintf(xf, " -rz %f", theta*(180./PI)); |
364 |
< |
/* xf += strlen(xf); */ |
364 |
> |
/* while (*xf) ++xf; */ |
365 |
|
n += 2; |
366 |
|
} |
367 |
|
return(n); |