home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume21 / t3d / part01 < prev    next >
Encoding:
Text File  |  1994-01-05  |  33.5 KB  |  1,387 lines

  1. Newsgroups: comp.sources.x
  2. From: paysan@informatik.tu-muenchen.de (Bernd Paysan)
  3. Subject: v21i086:  t3d - 3D Flying Balls as Clock, Part01/01
  4. Message-ID: <1994Jan5.230811.24505@sparky.sterling.com>
  5. X-Md4-Signature: aed08c2a4840dac83e9a6b3ba12c52bf
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Wed, 5 Jan 1994 23:08:11 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: paysan@informatik.tu-muenchen.de (Bernd Paysan)
  12. Posting-number: Volume 21, Issue 86
  13. Archive-name: t3d/part01
  14. Environment: X11
  15.  
  16.       Time 3D is a clock. It uses flying balls to display the time. This
  17.       balls moves and wobbers around to give you the impression your graphic
  18.       workstation with its many XStones is doing something.
  19.  
  20. #!/bin/sh
  21. # This is a shell archive (produced by shar 3.49)
  22. # To extract the files from this archive, save it to a file, remove
  23. # everything above the "!/bin/sh" line above, and type "sh file_name".
  24. #
  25. # made 11/24/1993 10:05 UTC by paysan@unknown
  26. # Source directory /usr/share/hphalle4/stud/acher/exp/t3d
  27. #
  28. # existing files will NOT be overwritten unless -c is specified
  29. #
  30. # This shar contains:
  31. # length  mode       name
  32. # ------ ---------- ------------------------------------------
  33. #  21021 -rw-r--r-- t3d.c
  34. #    848 -rw-rw-r-- t3d.icon
  35. #    353 -rw-r--r-- patchlevel.h
  36. #    338 -rw-rw-r-- Imakefile
  37. #   3658 -rw-r--r-- README
  38. #   2987 -rw-r--r-- t3d.man
  39. #
  40. # ============= t3d.c ==============
  41. if test -f 't3d.c' -a X"$1" != X"-c"; then
  42.     echo 'x - skipping t3d.c (File already exists)'
  43. else
  44. echo 'x - extracting t3d.c (Text)'
  45. sed 's/^X//' << 'SHAR_EOF' > 't3d.c' &&
  46. /*   
  47. X    t3d
  48. X
  49. Flying Balls Demo for X
  50. by Georg Acher , acher@informatik.tu-muenchen.de
  51. (developed on HP9000/720 (55 MIPS,20 MFLOPS) )
  52. NO warranty at all ! Complaints to /dev/null !
  53. X
  54. Clock Demo for X
  55. by Bernd Paysan , paysan@informatik.tu-muenchen.de
  56. */
  57. X
  58. #include <X11/Xlib.h>
  59. #include <X11/Xutil.h>
  60. #include <X11/Xos.h>
  61. #include <stdlib.h>
  62. /* #include <unistd.h>*/
  63. #include <stdio.h>
  64. #include <math.h>
  65. /* #include <time.h>*/
  66. #include "patchlevel.h"
  67. X
  68. int maxk=34;
  69. X
  70. #define   WIDTH      200
  71. #define   HEIGHT     200
  72. #define   norm       20.0
  73. X
  74. int timewait=40000;
  75. X
  76. #define   ROOT       0x1
  77. #define PI M_PI
  78. #define TWOPI 2*M_PI
  79. X
  80. #define kmax ((minutes?60:24))
  81. /* Anzahl der Kugeln */
  82. #define sines 52
  83. /* Werte in der Sinus-Tabelle */
  84. /*-----------------------------------------------------------------*/
  85. #define setink(inkcolor) \
  86. X    XSetForeground (dpy,gc,inkcolor)
  87. X
  88. #define drawline(xx1,yy1,xx2,yy2) \
  89. X    XDrawLine(dpy,win,gc,xx1,yy1,xx2,yy2) 
  90. X
  91. #define drawseg(segments,nr_segments) \
  92. X    XDrawSegments(dpy,win,gc,segments,nr_segments) 
  93. X
  94. X
  95. #define polyfill(ppts,pcount) \
  96. X    XFillPolygon(dpy,win,gc,ppts,pcount,Convex,CoordModeOrigin)
  97. X
  98. X
  99. #define frac(argument) argument-floor(argument)
  100. X
  101. #define abs(x) ((x)<0.0 ? -(x) : (x))
  102. X
  103. Colormap cmap;
  104. XXColor gray1;
  105. double r=1.0,g=1.0,b=1.0;
  106. double hue=0.0,sat=0.0,val=1.0;
  107. X
  108. typedef struct {
  109. double x,y,z,r,d,r1;
  110. int x1,y1;
  111. } kugeldat;
  112. X
  113. /* Felder fuer 3D */
  114. X
  115. kugeldat kugeln[100];
  116. X
  117. double  a[3],m[3],am[3],x[3],y[3],v[3];
  118. double zoom,speed,zaehler,vspeed,AE;
  119. double vturn,aturn;
  120. XXPoint track[sines];
  121. double sinus[sines];
  122. double cosinus[sines];
  123. X
  124. int startx,starty;
  125. double magx,magy,mag=10;
  126. double lastx,lasty,lastz;
  127. int lastcx,lastcy,lastcz;
  128. /* int move=1; */
  129. int minutes=0;
  130. int cycl=0;
  131. double hsvcycl=0.0;
  132. double movef =0.5, wobber=2.0, cycle=6.0;
  133. X
  134. /* time */
  135. X
  136. double sec;
  137. X
  138. /* Windows */
  139. GC    gc;
  140. GC orgc;
  141. GC andgc;
  142. Window    win;
  143. Font font;
  144. Display    *dpy;
  145. int    screen, scrnWidth = WIDTH, scrnHeight = HEIGHT;
  146. Pixmap  buffer;
  147. #define maxfast 100
  148. int fastch=40;
  149. #ifdef FASTDRAW
  150. #    ifdef FASTCOPY
  151. #        define sum1ton(a) (((a)*(a)+1)/2)
  152. #        define fastcw sum1ton(fastch)
  153. X        Pixmap fastcircles;
  154. X        Pixmap fastmask;
  155. #    else
  156. X        XImage* fastcircles[maxfast];
  157. X        XImage* fastmask[maxfast];
  158. #    endif
  159. #endif
  160. X
  161. int fastdraw=0;
  162. int scrnW2,scrnH2;
  163. unsigned short flags = 0;
  164. char *text;
  165. XXColor colors[64];
  166. struct tm *zeit;
  167. X
  168. int planes;
  169. /* compute time */
  170. X
  171. double gettime ()
  172. {
  173. X    struct timeval time1;
  174. X    struct timezone zone1;
  175. X    struct tm *zeit;
  176. X
  177. X    gettimeofday(&time1,&zone1);
  178. X    zeit=localtime(&time1.tv_sec);
  179. X
  180. X    return (zeit->tm_sec+60*(zeit->tm_min+60*(zeit->tm_hour))
  181. X              + time1.tv_usec*1.0E-6);
  182. X
  183. }
  184. X
  185. /* --------------------COLORMAP---------------------*/ 
  186. X
  187. void hsv2rgb(h, s, v, r, g, b)
  188. double h, s, v, *r, *g, *b;
  189. {
  190. X    h/=360.0;    h=6*(h-floor(h));
  191. X
  192. X    if(s==0.0)
  193. X    {
  194. X        *r=*g=*b=v;
  195. X    }
  196. X    else
  197. X    {    int i=(int)h;
  198. X        double t,u,w;
  199. X
  200. X        h=h-floor(h);
  201. X
  202. X        u=v*(s*(1.0-h));
  203. X        w=v*(1.0-s);
  204. X        t=v*(s*h+1.0-s);
  205. X
  206. X        switch(i)
  207. X        {
  208. X            case 0:    *r=v;    *g=t;    *b=w;    break;
  209. X            case 1:    *r=u;    *g=v;    *b=w;    break;
  210. X            case 2:    *r=w;    *g=v;    *b=t;    break;
  211. X            case 3:    *r=w;    *g=u;    *b=v;    break;
  212. X            case 4:    *r=t;    *g=w;    *b=v;    break;
  213. X            case 5:    *r=v;    *g=w;    *b=u;    break;
  214. X        }
  215. X    }
  216. #ifdef PRTDBX
  217. X    printf("HSV: %f %f %f to\nRGB: %f %f %f\n",h,s,v,*r,*g,*b);
  218. #endif
  219. }
  220. X
  221. void changeColor (r, g, b)
  222. double r,g,b;
  223. {
  224. X    int n,n1;
  225. X
  226. X    n1=0;
  227. X    for(n=30;n<64;n+=3)
  228. X    {
  229. X        colors[n1].red   =1023+ n*(int)(1024.*r);
  230. X        colors[n1].blue  =1023+ n*(int)(1024.*b);
  231. X        colors[n1].green =1023+ n*(int)(1024.*g);
  232. X
  233. X        n1++;
  234. X    }
  235. X
  236. X    if (!(XStoreColors (dpy, cmap, colors, 12)))
  237. X    {
  238. X       (void) fprintf (stderr, "Error:  Cannot set colors\n");
  239. X       exit (1);
  240. X    }
  241. }
  242. X
  243. void initColor (r, g, b)
  244. double r,g,b;
  245. {
  246. X    int n,n1;
  247. X    unsigned long pixels[12];
  248. X    long dummy;
  249. X
  250. X   cmap = DefaultColormap (dpy, screen);
  251. X
  252. X    if(hsvcycl!=0.0 && XAllocColorCells(dpy, cmap, 0, &dummy, 0, pixels, 12))
  253. X    {
  254. X        for(n1=0;n1<12;n1++)
  255. X        {
  256. X            colors[n1].pixel=pixels[n1];
  257. X            colors[n1].flags=DoRed | DoGreen | DoBlue;
  258. X        }
  259. X
  260. X        changeColor(r,g,b);
  261. X    }
  262. X    else
  263. X    {
  264. X        n1=0;
  265. X        for(n=30;n<64;n+=3)
  266. X        {
  267. X            colors[n1].red   =1023+ n*(int)(1024.*r);
  268. X            colors[n1].blue  =1023+ n*(int)(1024.*b);
  269. X            colors[n1].green =1023+ n*(int)(1024.*g);
  270. X
  271. X           if (!(XAllocColor (dpy, cmap, &colors[n1]))) {
  272. X              (void) fprintf (stderr, "Error:  Cannot allocate colors\n");
  273. X              exit (1);
  274. X           }
  275. X
  276. X            n1++;
  277. X        }
  278. X    }
  279. }
  280. X
  281. /* ----------------WINDOW-------------------*/
  282. X
  283. void initialize (argc,argv)
  284. int argc;
  285. char *argv[];
  286. {    XGCValues *xgc;
  287. X    XGCValues *xorgc;
  288. X    XGCValues *xandgc;
  289. X    char* display = getenv("DISPLAY");
  290. X    char* geometry = "";
  291. X    XSetWindowAttributes xswa;
  292. X    XSizeHints hints;
  293. X    Font font;
  294. X    int xswamask=0, retval=0;
  295. X    int x=0, y=0, w=scrnWidth, h=scrnHeight;
  296. X    int wr,hr,hx,hy;
  297. X    int niced=19;
  298. X    double magfac;
  299. X    Pixmap icon;
  300. X
  301. X    while (++argv, --argc)
  302. X    {
  303. X        if (!strcmp(*argv,"-cycle"))
  304. X            {    cycle=60.0/atof(*(++argv));argc--;}
  305. X        else if (!strcmp(*argv,"-display"))
  306. X            {    display=*(++argv);argc--;}
  307. X        else if (!strcmp(*argv,"-geometry") )
  308. X            {    geometry=*(++argv);argc--;}
  309. X        else if (!strcmp(*argv,"-move") )
  310. X            {    movef = atof(*(++argv))/2 ;argc--;}
  311. X        else if (!strcmp(*argv,"-wobber") )
  312. X            {    wobber *= atof(*(++argv));argc--;}
  313. X        else if (!strcmp(*argv,"-nice") )
  314. X            {    niced=(atoi(*(++argv)));argc--;}
  315. X        else if (!strcmp(*argv,"-mag"))
  316. X            {
  317. X                magfac = atof(*(++argv));argc--;
  318. X                mag *= magfac;
  319. X                w = (int)(w*magfac);
  320. X                h = (int)(h*magfac);
  321. X                fastch=(int)(fastch*magfac);
  322. X            }
  323. X        else if (!strcmp(*argv,"-minutes"))
  324. X            {    minutes=1; maxk+=60-24;}
  325. X        else if (!strcmp(*argv,"-wait"))
  326. X            {    timewait=(atoi(*(++argv)));argc--;}
  327. X        else if (!strcmp(*argv,"-fast"))
  328. X            {    fastch=(atoi(*(++argv)));argc--;}
  329. X        else if (!strcmp(*argv,"-colcycle"))
  330. X            {    cycl=1;}
  331. X        else if (!strcmp(*argv,"-hsvcycle"))
  332. X            {
  333. X                hsvcycl=atof(*(++argv));
  334. X                argc--;
  335. X            }
  336. X        else if (!strcmp(*argv,"-rgb"))
  337. X            {
  338. X                r=atof(*(++argv));
  339. X                g=atof(*(++argv));
  340. X                b=atof(*(++argv));
  341. X                argc-=3;
  342. X            }
  343. X        else if (!strcmp(*argv,"-hsv"))
  344. X            {
  345. X                hue=atof(*(++argv));
  346. X                sat=atof(*(++argv));
  347. X                val=atof(*(++argv));
  348. X                hsv2rgb(hue,sat,val,&r,&g,&b);
  349. X                argc-=3;
  350. X            }
  351. X        else if (!strcmp(*argv,"-help"))
  352. X            {
  353. X                puts("Time 3D (c) Bernd Paysan\nusage: t3d {option }");
  354. X                puts("\t-display <host>:<dpy>\n\t-geometry <geometry string>");
  355. X                puts("\t-move <factor>\n\t-wobber <factor>\n\t-nice <factor>");
  356. X                puts("\t-minutes\n\t-mag <factor>\n\t-cycle <period>");
  357. X                puts("\t-wait <microsec>\n\t-fast <precalc radius>");
  358. X                puts("\t-colcycle\n\t-rgb <red> <green> <blue>");
  359. X                puts("\t-hsv <hue> <value> <saturation>\n\t-hsvcycle <speed>\n\t-help");
  360. X                exit(0);
  361. X            }
  362. X        else
  363. X            {
  364. X                printf("unrecognised option '%s'\ntype 't3d -help' for help\n",*argv);
  365. X            }
  366. X    }
  367. X
  368. X    if (fastch>maxfast)
  369. X        fastch=maxfast;
  370. X
  371. #ifdef PRTDBX
  372. X    printf("Set options:\ndisplay: '%s'\ngeometry: '%s'\n",display,geometry);
  373. X    printf("move\t%.2f\nwobber\t%.2f\nmag\t%.2f\ncycle\t%.4f\n",
  374. X            movef,wobber,mag/10,cycle);
  375. X    printf("nice\t%i\nfast\t%i\nmarks\t%i\nwait\t%i\n",niced,fastch,maxk,timewait);
  376. #endif
  377. X
  378. X    (void)nice(niced);
  379. X
  380. X    xgc=( XGCValues *) malloc(sizeof(XGCValues) );
  381. X    xorgc=( XGCValues *) malloc(sizeof(XGCValues) );
  382. X    xandgc=( XGCValues *) malloc(sizeof(XGCValues) );
  383. X   if (!(dpy = XOpenDisplay (display))) {
  384. X      (void) fprintf (stderr, "Error:  Can't open display '%s'!\n",display);
  385. X      exit (1);
  386. X   }
  387. X
  388. X    screen = DefaultScreen (dpy);
  389. X    if(geometry[00])
  390. X        retval=XParseGeometry(geometry,&x,&y,&w,&h);
  391. X    if (retval & XValue && retval & XNegative)
  392. X        x = XDisplayWidth(dpy,screen)-w-abs(x);
  393. X    if (retval & YValue && retval & YNegative)
  394. X        y = XDisplayHeight(dpy,screen)-h-abs(y);
  395. X    hints.flags = 0;
  396. X    if(retval & (XValue | YValue))
  397. X        hints.flags |= USPosition;
  398. X    hints.flags |= USSize;
  399. X    hints.x = x; hints.y = y;
  400. X    hints.width = w; hints.height = h;
  401. X
  402. X    if (flags & ROOT)
  403. X        {
  404. X          win = DefaultRootWindow (dpy);
  405. X          scrnWidth = DisplayWidth (dpy, screen);
  406. X          scrnHeight = DisplayHeight (dpy, screen);
  407. X       }
  408. X    else
  409. X        {  xswamask |= CWBackPixel | CWBorderPixel;
  410. X            xswa.background_pixel=BlackPixel(dpy, screen);
  411. X            xswa.border_pixel=BlackPixel(dpy, screen);
  412. X
  413. X            scrnWidth=w; scrnHeight=h;
  414. X
  415. X           win = XCreateWindow (dpy, DefaultRootWindow (dpy),
  416. X                    x, y, scrnWidth, scrnHeight, 1, 0,
  417. X                    CopyFromParent, CopyFromParent,
  418. X                    xswamask, &xswa
  419. X                    );
  420. X
  421. X            XSetStandardProperties(dpy,win,"Time 3D","Time 3D",
  422. X                (!XReadBitmapFile(dpy, win, T3DICON,
  423. X                                      &wr, &hr, &icon, &hx, &hy) ? icon : None),
  424. X                0,0,&hints);
  425. X
  426. X             XMapWindow (dpy, win);
  427. X             XSelectInput (dpy, win, ExposureMask | StructureNotifyMask
  428. X                                            | KeyPressMask | ButtonPressMask
  429. X                                            | VisibilityChangeMask | PropertyChangeMask);
  430. X            for (;;)
  431. X            {
  432. X                XEvent event;
  433. X                XNextEvent(dpy, &event);
  434. X                 if (event.type == Expose) break;
  435. X          }
  436. X        }
  437. X
  438. X    xswa.override_redirect = 0;
  439. X
  440. X    planes=DefaultDepth(dpy,screen);
  441. X
  442. X   gc = XCreateGC (dpy, win, 0,  xgc);
  443. X    xorgc->function =GXor;
  444. X   orgc = XCreateGC (dpy, win, GCFunction,  xorgc);
  445. X    xandgc->function =GXandInverted;
  446. X   andgc = XCreateGC (dpy, win, GCFunction,  xandgc);
  447. X
  448. X     buffer = XCreatePixmap (dpy, DefaultRootWindow(dpy), scrnWidth, scrnHeight,
  449. X                                    DefaultDepth (dpy, screen)); 
  450. X
  451. X    printf("Time 3D drawing ");
  452. #ifdef FASTDRAW
  453. #    ifdef FASTCOPY
  454. X    puts("fast by Pixmap copy");
  455. #    else
  456. X    puts("fast by XImage copy");
  457. #    endif
  458. #else
  459. X    puts("slow");
  460. #endif
  461. X
  462. #ifdef FASTCOPY
  463. X    fastcircles = XCreatePixmap (dpy, DefaultRootWindow(dpy), fastcw, fastch+1,
  464. X                                            DefaultDepth (dpy,screen));
  465. X    fastmask    = XCreatePixmap (dpy, DefaultRootWindow(dpy), fastcw, fastch+1,
  466. X                                            DefaultDepth (dpy,screen));
  467. #endif
  468. X
  469. X    setink(BlackPixel (dpy, screen));
  470. X    XFillRectangle (dpy, buffer     , gc, 0, 0, scrnWidth, scrnHeight);    
  471. X
  472. #ifdef FASTCOPY
  473. X
  474. X    setink(BlackPixel (dpy, screen));
  475. X    XFillRectangle (dpy, fastcircles, gc, 0, 0, fastcw, fastch+1);
  476. X    XFillRectangle (dpy, fastmask   , gc, 0, 0, fastcw, fastch+1);
  477. X
  478. #endif
  479. }
  480. X
  481. X
  482. /*------------------------------------------------------------------*/
  483. void init_kugel()
  484. {
  485. X    int i;
  486. X
  487. #ifdef FASTDRAW
  488. X    for(i=0; i<fastch; i++)
  489. X    {
  490. #    ifdef FASTCOPY
  491. X        kugeln[i].r1=-((double) i)/2 -1;
  492. X        kugeln[i].x1=sum1ton(i);
  493. X        kugeln[i].y1=((double) i)/2 +1;
  494. X
  495. X        fill_kugel(i,fastcircles,1);
  496. X        setink((1<<DefaultDepth (dpy, screen))-1);
  497. X        fill_kugel(i,fastmask,0);
  498. #    else
  499. X        kugeln[i].r1=-((double) i)/2 -1;
  500. X        kugeln[i].x1=kugeln[i].y1=((double) i)/2 +1;
  501. X
  502. X        fill_kugel(i,buffer,1);
  503. X        fastcircles[i]=XGetImage(dpy,buffer,0,0,i+2,i+2,(1<<planes)-1,ZPixmap);
  504. X
  505. X        setink((1<<DefaultDepth (dpy, screen))-1);
  506. X        fill_kugel(i,buffer,0);
  507. X        fastmask[i]=XGetImage(dpy,buffer,0,0,i+2,i+2,(1<<planes)-1,ZPixmap);
  508. X
  509. X        setink(0);
  510. X        XFillRectangle (dpy, buffer     , gc, 0, 0, scrnWidth, scrnHeight);    
  511. #    endif
  512. X    }
  513. X    fastdraw=1;
  514. #endif
  515. }
  516. X
  517. /* Zeiger zeichnen */
  518. X
  519. void zeiger(dist,rad,z,sec,q)
  520. double dist,rad,z,sec;
  521. int *q;
  522. {
  523. X    int i,n;
  524. X    double gratio=sqrt(2.0/(1.0+sqrt(5.0)));
  525. X
  526. X    n = *q;
  527. X
  528. X    for(i=0;i<3;i++)
  529. X    {
  530. X        kugeln[n].x=dist*cos(sec);
  531. X        kugeln[n].y=-dist*sin(sec);
  532. X        kugeln[n].z=z;
  533. X        kugeln[n].r=rad;
  534. X        n++;
  535. X
  536. X        dist += rad;
  537. X        rad = rad*gratio;
  538. X    }
  539. X    *q = n;
  540. }
  541. X
  542. /*-----------------------------------------------------------------*
  543. X *                           Uhr zeichnen                          *
  544. X *-----------------------------------------------------------------*/
  545. X
  546. void manipulate(k)
  547. double k;
  548. {
  549. X    double i,l,xs,ys,zs,mod;
  550. X    double persec,sec,min,hour;
  551. X    int n;
  552. X
  553. X    sec=TWOPI*modf(k/60,&mod);
  554. X    min=TWOPI*modf(k/3600,&mod);
  555. X    hour=TWOPI*modf(k/43200,&mod);
  556. X
  557. X    l=TWOPI*modf(k/300,&mod);
  558. X    i=0.0;
  559. X    for (n=0;n<kmax;n++)
  560. X    {
  561. X
  562. X        kugeln[n].x=4.0*sin(i);
  563. X        kugeln[n].y=4.0*cos(i);
  564. X        kugeln[n].z=wobber* /* (sin(floor(2+2*l/(PI))*i)*sin(2*l)); */
  565. X                         cos((i-sec)*floor(2+5*l/(PI)))*sin(5*l);
  566. X        if(minutes)
  567. X        {    kugeln[n].r=/* (1.0+0.3*cos(floor(2+2*l/(PI))*i)*sin(2*l))* */
  568. X                         ((n % 5!=0) ? 0.3 : 0.6)*
  569. X                             ((n % 15 ==0) ? 1.25 : .75);
  570. X        }
  571. X        else
  572. X        {    kugeln[n].r=/* (1.0+0.3*cos(floor(2+2*l/(PI))*i)*sin(2*l))* */
  573. X                         ((n & 1) ? 0.5 : 1.0)*
  574. X                             ((n % 6==0) ? 1.25 : .75);
  575. X        }
  576. X        i+=TWOPI/kmax;
  577. X    }
  578. X
  579. X    kugeln[n].x=0.0;
  580. X    kugeln[n].y=0.0;
  581. X    kugeln[n].z=0.0;
  582. X    kugeln[n].r=2.0+cos(TWOPI*modf(k,&mod))/2;
  583. X    n++;
  584. X
  585. X    zeiger(2.0,0.75,-2.0,sec,&n);
  586. X    zeiger(1.0,1.0,-1.5,min,&n);
  587. X    zeiger(0.0,1.5,-1.0,hour,&n);
  588. X
  589. X    for(n=0;n<maxk;n++)
  590. X    {
  591. X        ys=kugeln[n].y*cos(movef*sin(cycle*sec))+kugeln[n].z*sin(movef*sin(cycle*sec));
  592. X        zs=-kugeln[n].y*sin(movef*sin(cycle*sec))+kugeln[n].z*cos(movef*sin(cycle*sec));
  593. X        kugeln[n].y=ys;
  594. X        kugeln[n].z=zs;
  595. X    }
  596. }
  597. /*------------------------------------------------------------------*/
  598. void sort(l,r)
  599. int l,r;
  600. {
  601. X    int i,j;
  602. X    kugeldat ex;
  603. X    double x;
  604. X
  605. X    i=l;j=r;
  606. X    x=kugeln[(l+r)/2].d;
  607. X    while(1)
  608. X    {
  609. X        while(kugeln[i].d>x) i++;
  610. X        while(x>kugeln[j].d) j--;
  611. X        if (i<=j)
  612. X        {
  613. X            ex=kugeln[i];kugeln[i]=kugeln[j];kugeln[j]=ex;
  614. X            i++;j--;
  615. X        }
  616. X        if (i>j) break;
  617. X    }
  618. X    if (l<j) sort(l,j);
  619. X    if (i<r) sort (i,r);
  620. }
  621. /*------------------------------------------------------------------*/
  622. void draw_kugel()
  623. {
  624. X    int i;
  625. X
  626. X    XSetForeground(dpy,gc,WhitePixel (dpy, screen));
  627. X    XFillRectangle(dpy,buffer,gc,0,0,10,10);
  628. X    for (i=0;i<maxk;i++)
  629. X    {
  630. X        if (kugeln[i].d>0.0)
  631. X        {
  632. X            XFillRectangle(dpy,buffer,gc,kugeln[i].x1,kugeln[i].y1,kugeln[i].r1,kugeln[i].r1);
  633. X        }
  634. X    }
  635. }
  636. /*------------------------------------------------------------------*/
  637. int fill_kugel(i,buf,setcol)
  638. int i, setcol;
  639. Pixmap buf;
  640. {
  641. X    double ra,ra1;
  642. X    int nr=0,m,col,n,inc=1,inr=3,d;
  643. X    d=(int)((abs(kugeln[i].r1)*2));
  644. X    if (d==0) d=1;
  645. X
  646. #ifdef FASTDRAW
  647. X    if(fastdraw && d<fastch)
  648. X    {
  649. #    ifdef FASTCOPY
  650. X        XCopyArea(dpy, fastmask, buf, andgc, sum1ton(d)-(d+1)/2, 1,d,d,
  651. X                     (int)(kugeln[i].x1)-d/2, (int)(kugeln[i].y1)-d/2);
  652. X        XCopyArea(dpy, fastcircles, buf, orgc, sum1ton(d)-(d+1)/2, 1,d,d,
  653. X                     (int)(kugeln[i].x1)-d/2, (int)(kugeln[i].y1)-d/2);
  654. #    else
  655. X        XPutImage(dpy, buf, andgc, fastmask[d-1], 0, 0,
  656. X                     (int)(kugeln[i].x1)-d/2, (int)(kugeln[i].y1)-d/2, d, d);
  657. X        XPutImage(dpy, buf, orgc, fastcircles[d-1], 0, 0,
  658. X                     (int)(kugeln[i].x1)-d/2, (int)(kugeln[i].y1)-d/2, d, d);
  659. #    endif
  660. X    }
  661. X    else
  662. #endif
  663. X    {
  664. X        if(abs(kugeln[i].r1)<6.0) inr=9;
  665. X
  666. X        for (m=0;m<=28;m+=inr)
  667. X        {
  668. X            ra=kugeln[i].r1*sqrt(1-m*m/(28.0*28.0));
  669. #ifdef PRTDBX
  670. X            printf("Radius: %f\n",ra);
  671. #endif
  672. X                 if(-ra< 3.0) inc=14;
  673. X            else if(-ra< 6.0) inc=8;
  674. X            else if(-ra<20.0) inc=4;
  675. X            else if(-ra<40.0) inc=2;
  676. X            if(setcol)
  677. X            {
  678. X                if (m==27) col=33;
  679. X                else
  680. X                    col=(int)(m);
  681. X                if (col>33) col=33;    col/=3;
  682. X                setink(colors[col].pixel);
  683. X            }
  684. X
  685. X            for (n=0,nr=0;n<=sines-1;n+=inc,nr++)
  686. X            {
  687. X                track[nr].x=kugeln[i].x1+(int)(ra*sinus[n])+(kugeln[i].r1-ra)/2;
  688. X                track[nr].y=kugeln[i].y1+(int)(ra*cosinus[n])+(kugeln[i].r1-ra)/2;
  689. X            }
  690. X            XFillPolygon(dpy,buf,gc,track,nr,Convex,CoordModeOrigin);
  691. X        }
  692. X    }
  693. }
  694. X
  695. /*------------------------------------------------------------------*/
  696. X
  697. void init_3d()
  698. {
  699. X    double i;
  700. X    int n=0;
  701. X
  702. X    a[0]=0.0;
  703. X    a[1]=0.0;
  704. X    a[2]=-10.0;
  705. X
  706. X    x[0]=10.0;
  707. X    x[1]=0.0;
  708. X    x[2]=0.0;
  709. X
  710. X    y[0]=0.0;
  711. X    y[1]=10.0;
  712. X    y[2]=0.0;
  713. X
  714. X
  715. X    zoom=-10.0;
  716. X    speed=.0;
  717. X
  718. X    for (i=0.0;n<sines;i+=TWOPI/sines,n++)
  719. X    {
  720. X        sinus[n]=sin(i);
  721. X        cosinus[n]=cos(i);
  722. X    }
  723. }
  724. /*------------------------------------------------------------------*/
  725. X
  726. X
  727. void vektorprodukt(feld1,feld2,feld3)
  728. double feld1[],feld2[],feld3[];
  729. {
  730. X    feld3[0]=feld1[1]*feld2[2]-feld1[2]*feld2[1];
  731. X    feld3[1]=feld1[2]*feld2[0]-feld1[0]*feld2[2];
  732. X    feld3[2]=feld1[0]*feld2[1]-feld1[1]*feld2[0];
  733. }
  734. /*------------------------------------------------------------------*/
  735. void turn(feld1,feld2,winkel)
  736. double feld1[],feld2[];
  737. double winkel;
  738. {
  739. X    double temp[3];
  740. X    double s,ca,sa,sx1,sx2,sx3;
  741. X
  742. X    vektorprodukt(feld1,feld2,temp);
  743. X
  744. X    s=feld1[0]*feld2[0]+feld1[1]*feld2[1]+feld1[2]*feld2[2];
  745. X
  746. X    sx1=s*feld2[0];
  747. X    sx2=s*feld2[1];
  748. X    sx3=s*feld2[2];
  749. X    sa=sin(winkel);ca=cos(winkel);
  750. X    feld1[0]=ca*(feld1[0]-sx1)+sa*temp[0]+sx1;
  751. X    feld1[1]=ca*(feld1[1]-sx2)+sa*temp[1]+sx2;
  752. X    feld1[2]=ca*(feld1[2]-sx3)+sa*temp[2]+sx3;
  753. }
  754. /*------------------------------------------------------------------*/
  755. X
  756. void viewpoint()
  757. X
  758. /* 1: Blickrichtung v;3:Ebenenmittelpunkt m 
  759. double feld1[],feld3[]; */
  760. {
  761. X     am[0]=-zoom*v[0];
  762. X    am[1]=-zoom*v[1];
  763. X    am[2]=-zoom*v[2];
  764. X
  765. X    zaehler=norm*norm*zoom;
  766. }
  767. /*------------------------------------------------------------------*/
  768. void projektion()
  769. {
  770. X    double c1[3],c2[3],k[3],x1,y1;
  771. X    double cno,cnorm,magnit;
  772. X    int i;
  773. X
  774. X    for (i=0;i<maxk;i++)
  775. X    {
  776. X        c1[0]=kugeln[i].x-a[0];
  777. X        c1[1]=kugeln[i].y-a[1];
  778. X        c1[2]=kugeln[i].z-a[2];
  779. X        cnorm=sqrt(c1[0]*c1[0]+c1[1]*c1[1]+c1[2]*c1[2]);
  780. X
  781. X        c2[0]=c1[0];
  782. X        c2[1]=c1[1];
  783. X        c2[2]=c1[2];
  784. X
  785. X        cno=c2[0]*v[0]+c2[1]*v[1]+c2[2]*v[2];
  786. X        kugeln[i].d=cnorm;
  787. X        if (cno<0) kugeln[i].d=-20.0;
  788. X
  789. X
  790. X        kugeln[i].r1=(mag*zoom*kugeln[i].r/cnorm);
  791. X
  792. X        c2[0]=v[0]/cno;
  793. X        c2[1]=v[1]/cno;
  794. X        c2[2]=v[2]/cno;
  795. X
  796. X        vektorprodukt(c2,c1,k);
  797. X
  798. X
  799. X        x1=(startx+(x[0]*k[0]+x[1]*k[1]+x[2]*k[2])*mag);
  800. X        y1=(starty-(y[0]*k[0]+y[1]*k[1]+y[2]*k[2])*mag);
  801. X        if((x1>-2000.0)
  802. X            && (x1<scrnWidth+2000.0)
  803. X            && (y1>-2000.0)
  804. X            && (y1<scrnHeight+2000.0))
  805. X        {
  806. X            kugeln[i].x1=(int)x1;
  807. X            kugeln[i].y1=(int)y1;
  808. X        }
  809. X        else
  810. X        {
  811. X            kugeln[i].x1=0;
  812. X            kugeln[i].y1=0;
  813. X            kugeln[i].d=-20.0;
  814. X        }
  815. X    }
  816. }
  817. X
  818. /*---------- event-handler ----------------*/
  819. void event_handler()
  820. {
  821. X    int kpr;
  822. X    while (XEventsQueued (dpy, QueuedAfterReading))
  823. X    {
  824. X        XEvent event;
  825. X
  826. X        XNextEvent (dpy, &event);
  827. X        switch (event.type)
  828. X        {
  829. X            case ConfigureNotify:
  830. X                if (event.xconfigure.width != scrnWidth ||
  831. X                     event.xconfigure.height != scrnHeight)
  832. X                {
  833. X                    XFreePixmap (dpy, buffer); 
  834. X                    scrnWidth = event.xconfigure.width;
  835. X                    scrnHeight = event.xconfigure.height;
  836. X                    buffer = XCreatePixmap (dpy, DefaultRootWindow (dpy),
  837. X                                                    scrnWidth, scrnHeight,
  838. X                    DefaultDepth (dpy, screen));
  839. X     
  840. X                    startx=scrnWidth/2;
  841. X                    starty=scrnHeight/2;
  842. X                    scrnH2=startx;
  843. X                    scrnW2=starty;
  844. X               }
  845. X            case KeyPress:
  846. X            {
  847. X                kpr=event.xkey.keycode;
  848. X                if (kpr==52) /* s */
  849. X                    vspeed=0.5;
  850. X                if (kpr==53)
  851. X                    vspeed=-0.3;
  852. X                if (kpr==62)
  853. X                {
  854. X                    speed=0;vspeed=0;
  855. X                }
  856. X                /*    printf("%i\n",event.xkey.keycode);*/
  857. X                if (kpr==36) mag*=1.02;
  858. X                if (kpr==35) mag/=1.02;
  859. X            }
  860. X            default:
  861. X                kpr=0;
  862. X          break;
  863. X        }
  864. X    }
  865. X    /*nap(40);-Ersatz*/ 
  866. X    {
  867. X        struct timeval timeout;
  868. X        timeout.tv_sec=timewait/1000000;
  869. X        timeout.tv_usec=timewait%1000000;
  870. X        (void)select(0,0,0,0,&timeout);
  871. X    }
  872. }
  873. /*-------------------------------------------------*/
  874. main(argc,argv)
  875. int argc;
  876. char *argv[];
  877. {    Window junk_win,in_win;
  878. X
  879. X    int px,py,junk,kb,wai;
  880. X    int act,act1,tc;
  881. X    double vnorm;
  882. X    /* double var=0.0; */
  883. X    int color=0, dir=1;
  884. X    
  885. X    initialize(argc,argv);
  886. X    
  887. X    initColor(r,g,b);
  888. X    init_3d();
  889. X    zeit=malloc(sizeof(struct tm));
  890. X    init_kugel();
  891. X
  892. X    startx=scrnWidth/2;
  893. X    starty=scrnHeight/2;
  894. X    scrnH2=startx;
  895. X    scrnW2=starty;
  896. X    vspeed=0;
  897. X
  898. X
  899. X    vektorprodukt(x,y,v);
  900. X    viewpoint(m,v);
  901. X   
  902. X    setink (BlackPixel (dpy, screen));
  903. X    XFillRectangle (dpy, win, gc, 0, 0, scrnWidth, scrnHeight);
  904. X    XQueryPointer (dpy, win, &junk_win, &junk_win, &junk, &junk,
  905. X                        &px, &py, &kb);
  906. X
  907. X    for (;;)
  908. X    {    double dtime;
  909. X
  910. X        /*--------------- Zeichenteil --------------*/
  911. X
  912. X        event_handler();
  913. X
  914. X        vektorprodukt(x,y,v);
  915. X
  916. X        vnorm=sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);
  917. X        v[0]=v[0]*norm/vnorm;
  918. X        v[1]=v[1]*norm/vnorm;
  919. X        v[2]=v[2]*norm/vnorm;
  920. X        vnorm=sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2]);
  921. X        x[0]=x[0]*norm/vnorm;
  922. X        x[1]=x[1]*norm/vnorm;
  923. X        x[2]=x[2]*norm/vnorm;
  924. X        vnorm=sqrt(y[0]*y[0]+y[1]*y[1]+y[2]*y[2]);
  925. X        y[0]=y[0]*norm/vnorm;
  926. X        y[1]=y[1]*norm/vnorm;
  927. X        y[2]=y[2]*norm/vnorm;
  928. X
  929. X        projektion();
  930. X        sort(0,maxk-1);
  931. X
  932. X        dtime=gettime();
  933. X
  934. X        if(cycl)
  935. X        {
  936. X            color=(int)(64.0*(dtime/60-floor(dtime/60)))-32;
  937. X
  938. X            if(color<0)
  939. X                color=-color;
  940. X
  941. X            setink(colors[color/3].pixel);
  942. X        }
  943. X        else
  944. X            setink(BlackPixel (dpy, screen));
  945. X
  946. X        XFillRectangle(dpy,buffer,gc,0,0,scrnWidth,scrnHeight);
  947. X
  948. X        {
  949. X            int i;
  950. X
  951. X            manipulate(dtime);
  952. X
  953. X            for (i=0;i<maxk;i++)
  954. X            {
  955. X                if (kugeln[i].d>0.0)
  956. X                fill_kugel(i,buffer,1);
  957. X            }
  958. X        }
  959. X
  960. X        XSync(dpy,0);
  961. X
  962. X        /* manipulate(gettime());
  963. X        var+=PI/500;
  964. X        if (var>=TWOPI) var=PI/500; */
  965. X
  966. X        /*event_handler();*/
  967. X
  968. X        if(hsvcycl!=0.0)
  969. X        {
  970. X            dtime=hsvcycl*dtime/10.0+hue/360.0;
  971. X            dtime=360*(dtime-floor(dtime));
  972. X
  973. X            hsv2rgb(dtime,sat,val,&r,&g,&b);
  974. X            changeColor(r,g,b);
  975. X        }
  976. X
  977. X        XCopyArea (dpy, buffer, win, gc, 0, 0, scrnWidth, scrnHeight, 0, 0);
  978. X
  979. X
  980. X        /*-------------------------------------------------*/
  981. X        XSync(dpy,0);
  982. X
  983. X        event_handler();
  984. X
  985. X        (void)(XQueryPointer (dpy, win, &junk_win, &in_win, &junk, &junk,
  986. X                                    &px, &py, &kb));
  987. X    
  988. X        if ((px>0)&&(px<scrnWidth)&&(py>0)&&(py<scrnHeight) )        
  989. X        {
  990. X            if ((px !=startx)&&(kb&Button2Mask))
  991. X            {
  992. /*                printf("y=(%f,%f,%f)",y[0],y[1],y[2]);*/
  993. X                turn(y,x,((double)(px-startx))/(8000*mag));
  994. /*                printf("->(%f,%f,%f)\n",y[0],y[1],y[2]);*/
  995. X            }
  996. X            if ((py !=starty)&&(kb&Button2Mask)) 
  997. X            {
  998. /*                printf("x=(%f,%f,%f)",x[0],x[1],x[2]);*/
  999. X                turn(x,y,((double)(py-starty))/(-8000*mag));
  1000. /*                printf("->(%f,%f,%f)\n",x[0],x[1],x[2]);*/
  1001. X            }
  1002. X            if ((kb&Button1Mask)) 
  1003. X            {
  1004. X                if (vturn==0.0) vturn=.005; else if (vturn<2)  vturn+=.01;
  1005. X                turn(x,v,.002*vturn);
  1006. X                turn(y,v,.002*vturn); 
  1007. X            }
  1008. X            if ((kb&Button3Mask)) 
  1009. X            {
  1010. X                if (vturn==0.0) vturn=.005; else if (vturn<2) vturn+=.01;
  1011. X                turn(x,v,-.002*vturn);
  1012. X                turn(y,v,-.002*vturn);
  1013. X            }
  1014. X        }
  1015. X        if (!(kb&Button1Mask)&&!(kb&Button3Mask)) 
  1016. X        vturn=0;
  1017. X
  1018. X        speed=speed+speed*vspeed;
  1019. X        if ((speed<0.0000001) &&(vspeed>0.000001)) speed=0.000001;
  1020. X        vspeed=.1*vspeed;
  1021. X        if (speed>0.01) speed=.01;
  1022. X        a[0]=a[0]+speed*v[0];
  1023. X        a[1]=a[1]+speed*v[1];
  1024. X        a[2]=a[2]+speed*v[2];
  1025. X    }
  1026. }
  1027. SHAR_EOF
  1028. chmod 0644 t3d.c ||
  1029. echo 'restore of t3d.c failed'
  1030. Wc_c="`wc -c < 't3d.c'`"
  1031. test 21021 -eq "$Wc_c" ||
  1032.     echo 't3d.c: original size 21021, current size' "$Wc_c"
  1033. fi
  1034. # ============= t3d.icon ==============
  1035. if test -f 't3d.icon' -a X"$1" != X"-c"; then
  1036.     echo 'x - skipping t3d.icon (File already exists)'
  1037. else
  1038. echo 'x - extracting t3d.icon (Text)'
  1039. sed 's/^X//' << 'SHAR_EOF' > 't3d.icon' &&
  1040. #define t3d_width 31
  1041. #define t3d_height 31
  1042. static char t3d_bits[] = {
  1043. X   0x00, 0xc0, 0x01, 0x00, 0x00, 0x48, 0x09, 0x00, 0x00, 0xc1, 0x41, 0x00,
  1044. X   0x80, 0x02, 0xa0, 0x00, 0x00, 0x01, 0x40, 0x00, 0x20, 0x00, 0x00, 0x02,
  1045. X   0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x14, 0x00, 0x00, 0x14,
  1046. X   0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x18, 0x20,
  1047. X   0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x07, 0x80, 0x0f, 0x70,
  1048. X   0x05, 0x40, 0x02, 0x50, 0x07, 0x40, 0x02, 0x70, 0x00, 0x80, 0x01, 0x00,
  1049. X   0x00, 0x00, 0x1c, 0x00, 0x02, 0x00, 0x14, 0x20, 0x00, 0x00, 0x3c, 0x00,
  1050. X   0x08, 0x06, 0x30, 0x08, 0x14, 0x06, 0x40, 0x14, 0x08, 0x01, 0x00, 0x08,
  1051. X   0x80, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x02, 0x00, 0x01, 0x40, 0x00,
  1052. X   0x80, 0x02, 0xa0, 0x00, 0x00, 0xc1, 0x41, 0x00, 0x00, 0x48, 0x09, 0x00,
  1053. X   0x00, 0xc0, 0x01, 0x00};
  1054. SHAR_EOF
  1055. chmod 0664 t3d.icon ||
  1056. echo 'restore of t3d.icon failed'
  1057. Wc_c="`wc -c < 't3d.icon'`"
  1058. test 848 -eq "$Wc_c" ||
  1059.     echo 't3d.icon: original size 848, current size' "$Wc_c"
  1060. fi
  1061. # ============= patchlevel.h ==============
  1062. if test -f 'patchlevel.h' -a X"$1" != X"-c"; then
  1063.     echo 'x - skipping patchlevel.h (File already exists)'
  1064. else
  1065. echo 'x - extracting patchlevel.h (Text)'
  1066. sed 's/^X//' << 'SHAR_EOF' > 'patchlevel.h' &&
  1067. /* This file contains the current patch level. Not all patch levels are
  1068. X * released, I also use this number to keep track of my changes to t3d,
  1069. X * so don't be suprised by jumps in this number.
  1070. X * Any new patches will say which patchlevel the patch is intended for, 
  1071. X * and should be applied only to programs of that patchlevel.
  1072. X */
  1073. #define PATCHLEVEL 0
  1074. SHAR_EOF
  1075. chmod 0644 patchlevel.h ||
  1076. echo 'restore of patchlevel.h failed'
  1077. Wc_c="`wc -c < 'patchlevel.h'`"
  1078. test 353 -eq "$Wc_c" ||
  1079.     echo 'patchlevel.h: original size 353, current size' "$Wc_c"
  1080. fi
  1081. # ============= Imakefile ==============
  1082. if test -f 'Imakefile' -a X"$1" != X"-c"; then
  1083.     echo 'x - skipping Imakefile (File already exists)'
  1084. else
  1085. echo 'x - extracting Imakefile (Text)'
  1086. sed 's/^X//' << 'SHAR_EOF' > 'Imakefile' &&
  1087. # t3d
  1088. # by Georg Acher, acher@informatik.tu-muenchen.de
  1089. # Imakefile for t3d
  1090. # make Makefile with xmkmf
  1091. X          SRCS1 = t3d.c 
  1092. X          OBJS1 = t3d.o 
  1093. X       INCLUDES = -I$(TOP) -Im $(T3DFLAGS)
  1094. X       PROGRAMS =  t3d
  1095. X       T3DFLAGS = -DFASTDRAW -DFASTCOPY -DT3DICON='"'$(PWD)/t3d.icon'"'
  1096. X    
  1097. X
  1098. ComplexProgramTarget_1(t3d,$(XLIB),-lm)
  1099. X
  1100. SHAR_EOF
  1101. chmod 0664 Imakefile ||
  1102. echo 'restore of Imakefile failed'
  1103. Wc_c="`wc -c < 'Imakefile'`"
  1104. test 338 -eq "$Wc_c" ||
  1105.     echo 'Imakefile: original size 338, current size' "$Wc_c"
  1106. fi
  1107. # ============= README ==============
  1108. if test -f 'README' -a X"$1" != X"-c"; then
  1109.     echo 'x - skipping README (File already exists)'
  1110. else
  1111. echo 'x - extracting README (Text)'
  1112. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  1113. X
  1114. X
  1115. X
  1116. X t3d(1)                            Time 3D                            t3d(1)
  1117. X                                 Version 1.0
  1118. X
  1119. X
  1120. X
  1121. X NAME
  1122. X      t3d - clock using flying balls to display the time
  1123. X
  1124. X SYNOPSIS
  1125. X      t3d [  options ]...
  1126. X
  1127. X DESCRIPTION
  1128. X      Time 3D is a clock. It uses flying balls to display the time. This
  1129. X      balls moves and wobbers around to give you the impression your graphic
  1130. X      workstation with its many XStones is doing something.
  1131. X
  1132. X      t3d uses mouse and keyboard to let you fly through the balls. Hit S to
  1133. X      speed up, A to slow down, Z to zoom in and X to zoom out.  Use the
  1134. X      left mouse button to rotate to the left and the right mouse button to
  1135. X      rotate the view to the right. Use the middle mouse button to change
  1136. X      the optical axis and the moving direction.  Q will stop you.
  1137. X
  1138. X OPTIONS
  1139. X      -display host:dpy
  1140. X           Specifys the display in the usual way.
  1141. X
  1142. X      -geometry WxH+X+Y
  1143. X           Sets the size and location of the t3d window.
  1144. X
  1145. X      -move factor
  1146. X           Modifies the direction move of t3d. The clock looks 30 degrees*
  1147. X           factor to the left and to the right periodically.
  1148. X
  1149. X      -wobber factor
  1150. X           Modifies the "wobbering" (sounds nice :-) of t3d by multiplying
  1151. X           the default deformation of the clock by factor.
  1152. X
  1153. X      -nice factor
  1154. X           Renices t3d by factor because t3d uses your process time. The
  1155. X           default renice factor is 20, so you can't do anything wrong by
  1156. X           not renicing t3d. If you want more speed, you should set nice to
  1157. X           a smaller value.
  1158. X
  1159. X      -minutes
  1160. X           Shows one small ball for every minute, instead of one for every
  1161. X           2.5 minutes.
  1162. X
  1163. X      -mag factor
  1164. X           Changes the magnification of t3d. By default, t3d uses a 200x200
  1165. X           window. A factor of 2 means, it will use a 400x400 window.
  1166. X
  1167. X      -cycle period
  1168. X           Sets the moving cycle to period seconds. By default, this value
  1169. X           is 10 seconds.
  1170. X
  1171. X
  1172. X
  1173. X
  1174. X
  1175. X                                    - 1 -      Formatted:  November 23, 1993
  1176. X
  1177. X
  1178. X
  1179. X
  1180. X
  1181. X
  1182. X t3d(1)                            Time 3D                            t3d(1)
  1183. X                                 Version 1.0
  1184. X
  1185. X
  1186. X
  1187. X      -wait microsec
  1188. X           Inserts a wait after drawing one view of the clock. By default,
  1189. X           t3d waits 40 ms after each drawing. This helps you to keep the
  1190. X           performance loss small.
  1191. X
  1192. X      -fast precalc radius
  1193. X           t3d uses bitmap copy to draw precalculated balls. You can specify
  1194. X           the radius in pixels up to which t3d should precalculate balls.
  1195. X           t3d will set a useful range by itself using the magnification
  1196. X           when it is started.
  1197. X
  1198. X      -colcycle
  1199. X           Draws cyclic the color scale used for the balls in the background
  1200. X           instead of the normal black.
  1201. X
  1202. X      -rgb red green blue
  1203. X           Selects the color in RGB color space of the lighning spot on the
  1204. X           balls.  All the other colors used for balls or -colcycle are less
  1205. X           intensive colors of the same hue and saturation. All values in
  1206. X           range of 0 to 1.
  1207. X
  1208. X      -hsv hue value saturation
  1209. X           Selects the color in HSV color space.  hue is in degrees from 0
  1210. X           to 360, all other values in range of 0 to 1.
  1211. X
  1212. X      -hsvcycle speed
  1213. X           Rotates the hue axis every 10 seconds* speed.
  1214. X
  1215. X      -help
  1216. X           Prints a short usage message.
  1217. X
  1218. X      Bernd Paysan
  1219. X
  1220. X      Email: paysan@informatik.tu-muenchen.de
  1221. X
  1222. X ACKNOLEDGEMENT
  1223. X      Acknoledgement to Georg Acher, who wrote the initial program
  1224. X      displaying balls.
  1225. X
  1226. X
  1227. X
  1228. X
  1229. X
  1230. X
  1231. X
  1232. X
  1233. X
  1234. X
  1235. X
  1236. X
  1237. X
  1238. X
  1239. X
  1240. X
  1241. X                                    - 2 -      Formatted:  November 23, 1993
  1242. X
  1243. X
  1244. X
  1245. SHAR_EOF
  1246. chmod 0644 README ||
  1247. echo 'restore of README failed'
  1248. Wc_c="`wc -c < 'README'`"
  1249. test 3658 -eq "$Wc_c" ||
  1250.     echo 'README: original size 3658, current size' "$Wc_c"
  1251. fi
  1252. # ============= t3d.man ==============
  1253. if test -f 't3d.man' -a X"$1" != X"-c"; then
  1254.     echo 'x - skipping t3d.man (File already exists)'
  1255. else
  1256. echo 'x - extracting t3d.man (Text)'
  1257. sed 's/^X//' << 'SHAR_EOF' > 't3d.man' &&
  1258. .TH t3d 1 "Version 1.0" "Time 3D"
  1259. .SH NAME
  1260. t3d \- clock using flying balls to display the time
  1261. .SH SYNOPSIS
  1262. t3d [ \f2 options\f1 ]...
  1263. .SH DESCRIPTION
  1264. .PP
  1265. Time 3D is a clock. It uses flying balls to display the time. This
  1266. balls moves and wobbers around to give you the impression your
  1267. graphic workstation with its many XStones is doing something.
  1268. .PP
  1269. t3d uses mouse and keyboard to let you fly through the balls. Hit
  1270. .B S
  1271. to speed up, 
  1272. .B A
  1273. to slow down,
  1274. .B Z
  1275. to zoom in and
  1276. .B X
  1277. to zoom out.
  1278. Use the
  1279. .B left mouse button
  1280. to rotate to the left and the
  1281. .B right mouse button
  1282. to rotate the view to the right. Use the
  1283. .B middle mouse button
  1284. to change the optical axis and the moving direction.
  1285. .B Q
  1286. will stop you.
  1287. .PP
  1288. .SH OPTIONS
  1289. .TP
  1290. .BI "-display " "host:dpy"
  1291. Specifys the display in the usual way.
  1292. .TP
  1293. .BI "-geometry " "WxH+X+Y"
  1294. Sets the size and location of the t3d window.
  1295. .TP
  1296. .BI "-move " "factor"
  1297. Modifies the direction move of t3d. The clock looks 30 degrees*
  1298. .I factor
  1299. to the left and to the right periodically.
  1300. .TP
  1301. .BI "-wobber " "factor"
  1302. Modifies the "wobbering" (sounds nice :-) of t3d by multiplying the
  1303. default deformation of the clock by
  1304. .I factor.
  1305. .TP
  1306. .BI "-nice " "factor"
  1307. Renices t3d by
  1308. .I factor
  1309. because t3d uses your process time. The default renice factor is 20, so
  1310. you can't do anything wrong by not renicing t3d. If you want more speed,
  1311. you should set nice to a smaller value.
  1312. .TP
  1313. .B -minutes
  1314. Shows one small ball for every minute, instead of one for every 2.5 minutes.
  1315. .TP
  1316. .BI "-mag " "factor"
  1317. Changes the magnification of t3d. By default, t3d uses a 200x200 window. A
  1318. .I factor
  1319. of 2 means, it will use a 400x400 window.
  1320. .TP
  1321. .BI "-cycle " "period"
  1322. Sets the moving cycle to
  1323. .I period
  1324. seconds. By default, this value is 10 seconds.
  1325. .TP
  1326. .BI "-wait " "microsec"
  1327. Inserts a wait after drawing one view of the clock. By default, t3d waits
  1328. 40 ms after each drawing. This helps you to keep the performance loss
  1329. small.
  1330. .TP
  1331. .BI "-fast " "precalc radius"
  1332. t3d uses bitmap copy to draw precalculated balls. You can specify the radius
  1333. in pixels up to which t3d should precalculate balls. t3d will set a useful
  1334. range by itself using the magnification when it is started.
  1335. .TP
  1336. .B -colcycle
  1337. Draws cyclic the color scale used for the balls in the background instead
  1338. of the normal black.
  1339. .TP
  1340. .BI "-rgb " "red green blue"
  1341. Selects the color in RGB color space of the lighning spot on the balls.
  1342. All the other colors used for balls or
  1343. .B -colcycle
  1344. are less intensive colors of the same hue and saturation. All values
  1345. in range of 0 to 1.
  1346. .TP
  1347. .BI "-hsv " "hue value saturation"
  1348. Selects the color in HSV color space.
  1349. .I hue
  1350. is in degrees from 0 to 360, all other values in range of 0 to 1.
  1351. .TP
  1352. .BI "-hsvcycle " "speed"
  1353. Rotates the hue axis every 10 seconds*
  1354. .I speed.
  1355. .TP
  1356. .B -help
  1357. Prints a short usage message.
  1358. .TP
  1359. .SH AUTHOR
  1360. .nf
  1361. Bernd Paysan
  1362. X
  1363. Email: paysan@informatik.tu-muenchen.de
  1364. .fi
  1365. .PP
  1366. X
  1367. .SH ACKNOLEDGEMENT
  1368. .PP
  1369. Acknoledgement to Georg Acher, who wrote the initial program displaying
  1370. balls.
  1371. SHAR_EOF
  1372. chmod 0644 t3d.man ||
  1373. echo 'restore of t3d.man failed'
  1374. Wc_c="`wc -c < 't3d.man'`"
  1375. test 2987 -eq "$Wc_c" ||
  1376.     echo 't3d.man: original size 2987, current size' "$Wc_c"
  1377. fi
  1378. exit 0
  1379.  
  1380. exit 0 # Just in case...
  1381. -- 
  1382.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  1383. \X/  Amiga: The only way to fly!  |    sources-x@sterling.com
  1384.        "It's intuitively obvious to the most casual observer..."
  1385.  GCS d++(--) -p+ c++ !l u++ e+ m+(-) s++/++ n h--- f+ g+++ w+ t++ r+ y+
  1386.