home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <gl.h>
- #include <device.h>
- #include <math.h>
- #include <sys/time.h>
- #include <stdio.h>
- #include "objects.h"
-
- #define X 0
- #define Y 1
- #define Z 2
-
- #define DEG *3.14159265359/180.0
- #define RAD *180.0/3.14159265359
-
- float move_speed; /* Spline distance per second */
- static long menu; /* The pop up menu */
-
- #define O_RESTART 1
- #define O_QUIT 2
- #define O_SLOW 3
- #define O_MEDIUM 4
- #define O_FAST 5
- #define O_SUPER_FAST 6
-
- #define O_NOMS 7
- #define O_4MS 8
- #define O_8MS 9
- #define O_16MS 10
-
- float idmat[4][4] = {
- {1.0, 0.0, 0.0, 0.0},
- {0.0, 1.0, 0.0, 0.0},
- {0.0, 0.0, 1.0, 0.0},
- {0.0, 0.0, 0.0, 1.0},
- };
- float light1[] = {
- AMBIENT, 0.0, 0.0, 0.0,
- LCOLOR, 1.0, 1.0, 1.0,
- POSITION, 0.0, 1.0, 0.0, 0.0,
- LMNULL
- };
- float light2[] = {
- AMBIENT, 0.0, 0.0, 0.0,
- LCOLOR, 0.3, 0.3, 0.5,
- POSITION, -1.0, 0.0, 0.0, 0.0,
- LMNULL
- };
- float light3[] = {
- AMBIENT, 0.2, 0.2, 0.2,
- LCOLOR, 0.2, 0.2, 0.2,
- POSITION, 0.0, -1.0, 0.0, 0.0,
- LMNULL
- };
- float lmodel[] = {
- AMBIENT, 0.3, 0.3, 0.3,
- LOCALVIEWER, 0.0,
- LMNULL
- };
- float mat_logo[] = {
- AMBIENT, 0.1, 0.1, 0.1,
- DIFFUSE, 0.5, 0.4, 0.7,
- SPECULAR, 1.0, 1.0, 1.0,
- SHININESS, 30.0,
- LMNULL,
- };
- float mat_holder_base[] = {
- AMBIENT, 0.0, 0.0, 0.0,
- DIFFUSE, 0.6, 0.6, 0.6,
- SPECULAR, 0.8, 0.8, 0.8,
- SHININESS, 30.0,
- LMNULL,
- };
- float mat_holder_rings[] = {
- AMBIENT, 0.0, 0.0, 0.0,
- DIFFUSE, 0.9, 0.8, 0.0,
- SPECULAR, 1.0, 1.0, 1.0,
- SHININESS, 30.0,
- LMNULL,
- };
- float mat_hemisphere[] = {
- AMBIENT, 0.0, 0.0, 0.0,
- DIFFUSE, 1.0, 0.2, 0.2,
- SPECULAR, 0.5, 0.5, 0.5,
- SHININESS, 20.0,
- LMNULL,
- };
- init_materials() {
-
- lmdef(DEFMATERIAL, MAT_LOGO, 0, mat_logo);
- lmdef(DEFMATERIAL, MAT_HOLDER_BASE, 0, mat_holder_base);
- lmdef(DEFMATERIAL, MAT_HOLDER_RINGS, 0, mat_holder_rings);
- lmdef(DEFMATERIAL, MAT_HEMISPHERE, 0, mat_hemisphere);
- }
- #define HALFTONE 1
-
- unsigned short halftone[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa,
- 0x5555, 0xaaaa, 0x5555, 0xaaaa,
- 0x5555, 0xaaaa, 0x5555, 0xaaaa,
- 0x5555, 0xaaaa, 0x5555, 0xaaaa };
- /*
- unsigned short halftone[] = { 0xeeee, 0xffff, 0xbbbb, 0xffff,
- 0xeeee, 0xffff, 0xbbbb, 0xffff,
- 0xeeee, 0xffff, 0xbbbb, 0xffff,
- 0xeeee, 0xffff, 0xbbbb, 0xffff };
- */
-
- short dev, val;
-
- float Time=0.0;
-
- float tmplight[] = {
- POSITION, 0.0, 0.0, 0.0, 0.0, LMNULL
- };
-
- float tv[4][4] = {
- {1.0, 0.0, 0.0, 0.0},
- {0.0, 1.0, 0.0, -1.0},
- {0.0, 0.0, 1.0, 0.0},
- {0.0, 0.0, 0.0, 0.0},
- };
-
- #define TABLERES 12
-
- float pcr, pcg, pcb, pca;
-
- typedef float vector[3];
- typedef vector parameter[4];
-
- vector table_points[TABLERES+1][TABLERES+1];
- int tablecolors[TABLERES+1][TABLERES+1];
-
- vector paper_points[4] = {
- {-0.8, 0.0, 0.4},
- {-0.2, 0.0, -1.4},
- {1.0, 0.0, -1.0},
- {0.4, 0.0, 0.8},
- };
-
- float dot(vector, vector);
-
- #define TIME 15
- #define START_TIME 0.6
-
- vector light_pos_ctl[] = {
-
- {0.0, 1.8, 0.0},
- {0.0, 1.8, 0.0},
- {0.0, 1.6, 0.0},
-
- {0.0, 1.6, 0.0},
- {0.0, 1.6, 0.0},
- {0.0, 1.6, 0.0},
- {0.0, 1.4, 0.0},
-
- {0.0, 1.3, 0.0},
- {-0.2, 1.5, 2.0},
- {0.8, 1.5, -0.4},
- {-0.8, 1.5, -0.4},
-
- {0.8, 2.0, 1.0},
- {1.8, 5.0, -1.8},
- {8.0, 10.0, -4.0},
- {8.0, 10.0, -4.0},
- {8.0, 10.0, -4.0},
- };
-
- vector logo_pos_ctl[] = {
-
- {0.0, -0.5, 0.0},
-
- {0.0, -0.5, 0.0},
- {0.0, -0.5, 0.0},
-
- {0.0, -0.5, 0.0},
- {0.0, -0.5, 0.0},
- {0.0, -0.5, 0.0},
- {0.0, 0.0, 0.0},
-
- {0.0, 0.6, 0.0},
- {0.0, 0.75, 0.0},
- {0.0, 0.8, 0.0},
- {0.0, 0.8, 0.0},
-
- {0.0, 0.5, 0.0},
- {0.0, 0.5, 0.0},
- {0.0, 0.5, 0.0},
- {0.0, 0.5, 0.0},
- {0.0, 0.5, 0.0},
- };
-
-
- vector logo_rot_ctl[] = {
-
- {0.0, 0.0, -18.4},
-
- {0.0, 0.0, -18.4},
- {0.0, 0.0, -18.4},
-
- {0.0, 0.0, -18.4},
- {0.0, 0.0, -18.4},
- {0.0, 0.0, -18.4},
- {0.0, 0.0, -18.4},
- {0.0, 0.0, -18.4},
-
- /* {90.0, 0.0, -90.0},
- {180.0, 180.0, 90.0}, */
- {240.0, 360.0, 180.0},
- {90.0, 180.0, 90.0},
-
- {11.9, 0.0, -18.4},
- {11.9, 0.0, -18.4},
- {11.9, 0.0, -18.4},
- {11.9, 0.0, -18.4},
- {11.9, 0.0, -18.4},
- };
-
-
- vector view_from_ctl[] = {
-
- {-1.0, 1.0, -4.0},
-
- {-1.0, -3.0, -4.0}, /* 0 */
- {-3.0, 1.0, -3.0}, /* 1 */
-
- {-1.8, 2.0, 5.4}, /* 2 */
- {-0.4, 2.0, 1.2}, /* 3 */
- {-0.2, 1.5, 0.6}, /* 4 */
- {-0.2, 1.2, 0.6}, /* 5 */
-
- {-0.8, 1.0, 2.4}, /* 6 */
- {-1.0, 2.0, 3.0}, /* 7 */
- {0.0, 4.0, 3.6}, /* 8 */
- {-0.8, 4.0, 1.2}, /* 9 */
-
- {-0.2, 3.0, 0.6}, /* 10 */
- {-0.1, 2.0, 0.3}, /* 11 */
- {-0.1, 2.0, 0.3}, /* 12 */
- {-0.1, 2.0, 0.3}, /* 13 */
- {-0.1, 2.0, 0.3}, /* 13 */
-
-
- };
-
- vector view_to_ctl[] = {
-
- {-1.0, 1.0, 0.0},
-
- {-1.0, -3.0, 0.0},
- {-1.0, 1.0, 0.0},
-
- {0.1, 0.0, -0.3},
- {0.1, 0.0, -0.3},
- {0.1, 0.0, -0.3},
- {0.0, 0.2, 0.0},
-
- {0.0, 0.6, 0.0},
- {0.0, 0.8, 0.0},
- {0.0, 0.8, 0.0},
- {0.0, 0.8, 0.0},
-
- {0.0, 0.8, 0.0},
- {0.0, 0.8, 0.0},
- {0.0, 0.8, 0.0},
- {0.0, 0.8, 0.0},
- {0.0, 0.8, 0.0},
-
- };
-
-
- vector view_from, view_to, light_pos, logo_pos, logo_rot;
-
- parameter *view_from_spline, *view_to_spline,
- *light_pos_spline, *logo_pos_spline,
- *logo_rot_spline;
-
- parameter *calc_spline_params(vector *, int);
-
- double a3, a4;
-
- void ideas_usage(void)
- {
- fprintf(stderr, "Usage: ideas [-a]\n");
- }
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- float x, y, z, c;
- int pick;
- int loops;
- int i;
- int auto_run; /* If set, then automatically run forever */
- struct timeval start;
- struct timeval current;
- float timediff;
- float timeoffset; /* Used to compute timing */
- float new_speed; /* Set new animation speed? */
- int resetclock; /* Reset the clock? */
- int timejerk; /* Set to indicate time jerked! (menu pulled down) */
-
- /* .4 spline distance per second by default */
- move_speed=.4;
- new_speed=.4;
- timeoffset=START_TIME;
-
-
- auto_run = 0; /* Don't automatically run forever */
- for (i = 1; i < argc; i++) {
- if (argv[i][0] != '-') {
- break;
- }
-
- switch(argv[i][1]) {
- case 'a': /* Keep running forever */
- auto_run = 1;
- break;
- default:
- ideas_usage();
- break;
- }
- }
-
- initialize(argv[0]);
-
- loops = 0;
- Time = timeoffset;
- resetclock = 1;
- timejerk = 0;
- while (TRUE) {
- if ((Time) > (TIME*1.0)-3.0) Time = TIME*1.0-3.001;
-
- while(qtest()) {
-
- switch(dev=qread(&val)) {
- case REDRAW:
- timejerk = 1;
- reshapeviewport();
- break;
-
- case ESCKEY:
- if (val) break; /* Ignore down, exit up */
- case WINQUIT:
- gexit();
- exit(0);
-
- case LEFTMOUSE:
- if (!val) {
- resetclock = 1;
- }
- break;
- case RIGHTMOUSE:
- timejerk = 1;
- switch(dopup(menu)) {
- case O_NOMS: /* No multi sampling */
- zbsize(32);
- mssize(0,0,0);
- gconfig();
- break;
- case O_4MS: /* 4 multi samples */
- zbsize(0);
- mssize(4,32,0);
- gconfig();
- break;
- case O_8MS: /* 8 multi samples */
- zbsize(0);
- mssize(8,32,0);
- gconfig();
- break;
- case O_16MS: /* 16 multi samples */
- zbsize(0);
- mssize(16,32,0);
- gconfig();
- break;
- case O_SLOW: /* Slow */
- new_speed = 0.2;
- break;
- case O_MEDIUM: /* Medium */
- new_speed = 0.4;
- break;
- case O_FAST: /* Fast */
- new_speed = 0.7;
- break;
- case O_SUPER_FAST: /* Really fast! */
- new_speed = 1.0;
- break;
- case O_RESTART: /* Restart */
- resetclock = 1;
- break;
- case O_QUIT: /* Quit */
- gexit();
- exit(0);
- break;
- default:
- break;
- }
- break;
- }
- }
-
- calc_spline(view_from, view_from_spline, Time);
- calc_spline(view_to, view_to_spline, Time);
- calc_spline(light_pos, light_pos_spline, Time);
- calc_spline(logo_pos, logo_pos_spline, Time);
- calc_spline(logo_rot, logo_rot_spline, Time);
-
- if (auto_run) {
- loops++;
- if (loops == 650) {
- resetclock = 1;
- loops = 0;
- }
- }
-
- tmplight[1] = light_pos[X]-logo_pos[X];
- tmplight[2] = light_pos[Y]-logo_pos[Y];
- tmplight[3] = light_pos[Z]-logo_pos[Z];
-
- lmdef(DEFLIGHT, 1, 0, tmplight);
-
- tv[0][0] = tv[1][1] = tv[2][2] = light_pos[Y];
-
- RGBcolor(0, 0, 0);
- clear(); zclear();
-
- mmode(MSINGLE);
-
- perspective(450, 5.0/4.0, 0.5, 20.0);
- lookat(view_from[X], view_from[Y], view_from[Z],
- view_to[X], view_to[Y], view_to[Z], 0);
-
- if (view_from[Y] > 0.0) draw_table();
-
- zbuffer(FALSE);
-
- if (logo_pos[Y]<0.0) {
-
- if (logo_pos[Y]>-0.33) {
- c = 1.0 - (logo_pos[Y])/-0.33;
- pca /= 4.0;
- RGBcolor((int)(128.0*(1.0-c)*0.5 + 255.0*pca*c),
- (int)(102.0*(1.0-c)*0.5 + 255.0*pca*c),
- (int)(179.0*(1.0-c)*0.5 + 200.0*pca*c));
- } else {
- RGBcolor(128/2, 102/2, 179/2);
- }
-
- pushmatrix();
- scale(0.04, 0.0, 0.04);
- rotate(-900, 'x');
- rotate((int)(10.0*logo_rot[Z]), 'z');
- rotate((int)(10.0*logo_rot[Y]), 'y');
- rotate((int)(10.0*logo_rot[X]), 'x');
- rotate(353, 'x');
- rotate(450, 'y');
- draw_logo_shadow();
- /* draw_logo_line();*/
- popmatrix();
- }
-
- if (logo_pos[Y]>0.0) {
-
- pushmatrix();
-
- if (logo_pos[Y]<0.33) {
- pca /= 4.0;
- c = 1.0 - (logo_pos[Y])/0.33;
- RGBcolor((int)(255.0*pca*c),
- (int)(255.0*pca*c),
- (int)(200.0*pca*c));
- } else {
- RGBcolor(0, 0, 0);
- }
-
- translate(light_pos[X], light_pos[Y], light_pos[Z]);
- multmatrix(tv);
- translate(-light_pos[X]+logo_pos[X],
- -light_pos[Y]+logo_pos[Y],
- -light_pos[Z]+logo_pos[Z]);
- scale(0.04, 0.04, 0.04);
- rotate(-900, 'x');
- rotate((int)(10.0*logo_rot[Z]), 'z');
- rotate((int)(10.0*logo_rot[Y]), 'y');
- rotate((int)(10.0*logo_rot[X]), 'x');
- rotate(353, 'x');
- rotate(450, 'y');
- setpattern(HALFTONE);
- draw_logo_shadow();
- setpattern(0);
- popmatrix();
-
- }
- zbuffer(TRUE);
-
- mmode(MVIEWING);
- perspective(450, 5.0/4.0, 0.5, 20.0);
- loadmatrix(idmat);
- lookat(view_from[X], view_from[Y], view_from[Z],
- view_to[X], view_to[Y], view_to[Z], 0);
-
- lmbind(LIGHT0, 3);
- lmbind(LIGHT1, 2);
-
- lmbind(MATERIAL, MAT_HOLDER_RINGS);
-
- pushmatrix();
- translate(light_pos[X], light_pos[Y], light_pos[Z]);
- scale(0.1, 0.1, 0.1);
-
- x = light_pos[X] - logo_pos[X];
- y = light_pos[Y] - logo_pos[Y];
- z = light_pos[Z] - logo_pos[Z];
-
- if (x!=0.0) {
- a3 = -atan2(z, x)*10.0 RAD;
- } else a3 = 0.0;
-
- a4 = -atan2(sqrt(x*x + z*z), y)*10.0 RAD;
-
- rotate((int)a3, 'y');
- rotate((int)a4, 'z');
-
- rotate(-900, 'x');
- draw_hemisphere();
- popmatrix();
-
- lmbind(LIGHT0, 1);
- lmbind(LIGHT1, 0);
-
- if (logo_pos[Y] > -0.33) {
- pushmatrix();
- translate(logo_pos[X], logo_pos[Y], logo_pos[Z]);
- scale(0.04, 0.04, 0.04);
- rotate(-900, 'x');
- rotate((int)(10.0*logo_rot[Z]), 'z');
- rotate((int)(10.0*logo_rot[Y]), 'y');
- rotate((int)(10.0*logo_rot[X]), 'x');
- rotate(353, 'x');
- rotate(450, 'y');
- lmbind(LMODEL, 1);
- draw_logo();
- lmbind(LMODEL, 0);
- popmatrix();
- }
-
- if (view_from[Y] < 0.0) draw_under_table();
-
- swapbuffers();
-
- /* Time jerked -- adjust clock appropriately */
- if (timejerk) {
- timejerk = 0;
- timeoffset = Time;
- gettimeofday(&start, NULL);
- }
-
- /* Reset our timer */
- if (resetclock) {
- resetclock = 0;
- timeoffset = START_TIME;
- gettimeofday(&start, NULL);
- }
-
- /* Compute new time */
- gettimeofday(¤t, NULL);
- timediff = (current.tv_sec - start.tv_sec) +
- (current.tv_usec - start.tv_usec) / 1000000.0;
- Time = timediff * move_speed + timeoffset;
-
- /* Adjust to new speed */
- if (new_speed != move_speed) {
- move_speed = new_speed;
- timeoffset = Time;
- gettimeofday(&start, NULL);
- }
- }
- }
-
- add_pick (menu, pickstr, rval)
- int menu;
- char *pickstr;
- int rval;
- {
- char pstr[60];
-
- sprintf (pstr, "%s%%x%0d", pickstr, rval);
- addtopup (menu, pstr);
- }
-
- add_submenu (menu, pickstr, menuid)
- int menu;
- char *pickstr;
- int menuid;
- {
- char pstr[32];
-
- sprintf (pstr, "%s%%m", pickstr);
- addtopup (menu, pstr, menuid);
- }
-
-
- initialize(title)
- char *title;
- {
- char *t, *strrchr();
- int multiAvail;
- static long speedmenu;
- static long msmenu;
-
- keepaspect(5, 4);
- winopen((t=strrchr(title, '/')) != NULL ? t+1 : title);
-
- if (getgdesc(GD_BITS_NORM_DBL_RED) == 0) {
- system("inform 'Your system must support RGB mode to run ideas'");
- exit(1);
- }
- if (getgdesc(GD_BITS_NORM_ZBUFFER) == 0) {
- system("inform 'Your system must have a z-buffer to run ideas'");
- exit(1);
- }
-
- doublebuffer();
- RGBmode();
- subpixel(TRUE);
- gconfig();
-
- multiAvail = 0;
- if (getgdesc(GD_MULTISAMPLE) == 1) {
-
- zbsize(0);
- mssize(16,32,0);
- gconfig();
-
- if (getgconfig(GC_MS_SAMPLES) == 16) multiAvail = 16;
- else if (getgconfig(GC_MS_SAMPLES) == 8) multiAvail = 8;
- else if (getgconfig(GC_MS_SAMPLES) == 4) multiAvail = 4;
- else if (getgconfig(GC_MS_SAMPLES) <= 4) {
- multiAvail = 0;
- zbsize(32);
- mssize(0,0,0);
- gconfig();
- }
- }
-
- qdevice(LEFTMOUSE);
- qdevice(RIGHTMOUSE);
- qdevice(ESCKEY);
- qdevice(WINQUIT);
- qdevice(WINSHUT);
-
- menu = defpup("Ideas %t");
-
- add_pick(menu, "Restart", O_RESTART);
-
-
- speedmenu = defpup("Speed %t");
- add_pick(speedmenu, "Slow", O_SLOW);
- add_pick(speedmenu, "Medium", O_MEDIUM);
- add_pick(speedmenu, "Fast", O_FAST);
- add_pick(speedmenu, "Super Fast", O_SUPER_FAST);
- add_submenu(menu, "Speed", speedmenu);
-
- if (multiAvail > 0) {
- msmenu = defpup("Multi Sampling %t");
- add_pick(msmenu, "None", O_NOMS);
- if (multiAvail >= 4 ) add_pick(msmenu, "4 Samples", O_4MS);
- if (multiAvail >= 8 ) add_pick(msmenu, "8 Samples", O_8MS);
- if (multiAvail >= 16 ) add_pick(msmenu, "16 Samples", O_16MS);
- add_submenu(menu, "Multi Sampling", msmenu);
- }
-
- add_pick(menu, "Quit", O_QUIT);
-
- defpattern(HALFTONE, 16, halftone);
-
- /* lsetdepth(0x0, 0x7fffff); */
- lsetdepth((getgdesc(GD_ZMIN)), (getgdesc(GD_ZMAX)));
- lmdef(DEFLIGHT, 1, 0, light1);
- lmdef(DEFLIGHT, 2, 0, light2);
- lmdef(DEFLIGHT, 3, 0, light3);
- lmdef(DEFLMODEL, 1, 0, lmodel);
-
- init_materials();
-
- build_table();
-
- view_from_spline = calc_spline_params(view_from_ctl, TIME);
- view_to_spline = calc_spline_params(view_to_ctl, TIME);
- light_pos_spline = calc_spline_params(light_pos_ctl, TIME);
- logo_pos_spline = calc_spline_params(logo_pos_ctl, TIME);
- logo_rot_spline = calc_spline_params(logo_rot_ctl, TIME);
-
- perspective(450, 5.0/4.0, 0.5, 20.0);
-
- mmode(MVIEWING);
- }
-
-
- build_table() {
-
- float i, j;
-
- for (j=0.0; j<=TABLERES*1.0; j+=1.0) {
- for (i=0.0; i<=TABLERES*1.0; i+=1.0) {
- table_points[(int)j][(int)i][Z] = (i-TABLERES*1.0/2.0)/2.0;
- table_points[(int)j][(int)i][X] = (j-TABLERES*1.0/2.0)/2.0;
- table_points[(int)j][(int)i][Y] = 0.0;
- }
- }
- }
-
-
- draw_table() {
-
- float x, z, c;
- int i, j;
- int k, l;
- float m, n;
- float ov[3], lv[3];
-
- zbuffer(FALSE);
-
- ov[X] = light_pos[X]-logo_pos[X];
- ov[Y] = light_pos[Y]-logo_pos[Y];
- ov[Z] = light_pos[Z]-logo_pos[Z];
-
- normalize(ov);
-
- for (j=0; j<=TABLERES; j++) {
- for (i=0; i<=TABLERES; i++) {
- lv[X] = light_pos[X] - table_points[j][i][X];
- lv[Y] = light_pos[Y] - table_points[j][i][Y];
- lv[Z] = light_pos[Z] - table_points[j][i][Z];
- normalize(lv);
- if ((c = dot(lv, ov))<0.0) c = 0.0;
- c = c * c * c * lv[Y] * 255.0;
- /* fade */
- if ((Time>TIME-5.0) && (Time<TIME-3.0))
- c *= 1.0 - (Time-(TIME-5.0)) * 0.5;
-
- tablecolors[j][i] = (int)c;
- }
- }
-
-
- for (l=0; l<TABLERES; l++) {
-
- bgntmesh();
- for (k=0; k<=TABLERES; k++) {
-
- RGBcolor(tablecolors[l][k],
- tablecolors[l][k],
- tablecolors[l][k]);
- v3f(table_points[l][k]);
-
- RGBcolor(tablecolors[l+1][k],
- tablecolors[l+1][k],
- tablecolors[l+1][k]);
- v3f(table_points[l+1][k]);
-
- }
- endtmesh();
- }
-
- if (logo_pos[Y]>-0.33 && logo_pos[Y]<0.33) {
- zbuffer(TRUE);
- }
-
- pca = 0.0;
- bgnpolygon();
- for (i=0; i<4; i++) {
- lv[X] = light_pos[X] - paper_points[i][X];
- lv[Y] = light_pos[Y] - paper_points[i][Y];
- lv[Z] = light_pos[Z] - paper_points[i][Z];
- normalize(lv);
- if ((c = dot(lv, ov))<0.0) c = 0.0;
- c = c * c * c * lv[Y];
- /* fade */
- if ((Time>TIME-5.0) && (Time<TIME-3.0))
- c *= 1.0 - (Time-(TIME-5.0)) * 0.5;
-
- pcr = c * 255; pcg = c * 255; pcb = c * 200;
- pca += c;
- RGBcolor((int)pcr, (int)pcg, (int)pcb);
- v3f(paper_points[i]);
- }
- endpolygon();
-
- /* RGBcolor(0, 200, 255);
- for (m = 0.4; m>-1.4; m -= 0.33) {
- move(-0.8+(m-4.0)/3.0, 0.0, m);
- draw(1.2-0.8+(m-4.0)/3.0, 0.0, m+0.4);
- }
- */
-
-
- zbuffer(FALSE);
-
- pushmatrix();
-
- rotate(-184, 'y');
-
- translate(-0.3, 0.0, -0.8);
-
- rotate(-900, 'x');
-
- scale(0.015, 0.015, 0.015);
-
- if (Time>TIME*1.0-5.0) {
- c = (Time-(TIME*1.0-5.0))/2.0;
- RGBcolor((int)(c*255.0), (int)(c*255.0), (int)(c*255.0));
- } else RGBcolor(0, 0, 0);
-
- draw_i();
- translate(3.0, 0.0, 0.0);
-
- draw_d();
- translate(6.0, 0.0, 0.0);
-
- draw_e();
- translate(5.0, 0.0, 0.0);
-
- draw_a();
- translate(6.0, 0.0, 0.0);
-
- draw_s();
- translate(10.0, 0.0, 0.0);
-
- draw_i();
- translate(3.0, 0.0, 0.0);
-
- draw_n();
- translate(-31.0, -13.0, 0.0);
-
- draw_m();
- translate(10.0, 0.0, 0.0);
-
- draw_o();
- translate(5.0, 0.0, 0.0);
-
- draw_t();
- translate(4.0, 0.0, 0.0);
-
- draw_i();
- translate(3.5, 0.0, 0.0);
-
- draw_o();
- translate(5.0, 0.0, 0.0);
-
- draw_n();
-
- popmatrix();
-
- zbuffer(TRUE);
-
-
- }
-
-
-
- draw_under_table() {
-
- int k, l;
-
- zbuffer(FALSE);
-
-
- RGBcolor(0, 0, 0);
-
- for (l=0; l<TABLERES; l++) {
-
- bgntmesh();
- for (k=0; k<=TABLERES; k++) {
-
- v3f(table_points[l][k]);
- v3f(table_points[l+1][k]);
-
- }
- endtmesh();
- }
-
- zbuffer(TRUE);
-
- }
-
-
-
- calc_spline(v, params, Time)
- vector v;
- parameter *params;
- float Time;
- {
-
- float t, tt;
- int i, j;
-
- tt = t = Time - (float)((int)Time);
-
- for (i=0; i<3; i++) {
-
-
- v[i] = params[(int)Time][3][i] +
- params[(int)Time][2][i] * t +
- params[(int)Time][1][i] * t * t +
- params[(int)Time][0][i] * t * t * t;
- }
-
- }
-
-
- parameter *calc_spline_params(ctl_pts, n)
- vector *ctl_pts;
- int n;
- {
-
- int i, j;
- parameter *params;
-
- if (n<4) {
- fprintf(stderr,
- "calc_spline_params: not enough control points\n");
- return (NULL);
- }
-
- params = (parameter *)malloc(sizeof(parameter) * (n-3));
-
- for (i=0; i<n-3; i++) {
-
- for (j=0; j<3; j++) {
-
- params[i][3][j] = ctl_pts[i+1][j];
- params[i][2][j] = ctl_pts[i+2][j] - ctl_pts[i][j];
- params[i][1][j] = 2.0 * ctl_pts[i][j] +
- -2.0 * ctl_pts[i+1][j] +
- 1.0 * ctl_pts[i+2][j] +
- -1.0 * ctl_pts[i+3][j];
- params[i][0][j] = -1.0 * ctl_pts[i][j] +
- 1.0 * ctl_pts[i+1][j] +
- -1.0 * ctl_pts[i+2][j] +
- 1.0 * ctl_pts[i+3][j];
-
- }
- }
-
- return (params);
- }
-
-
- normalize(v)
- vector v;
- {
- float r;
-
- r = sqrt(v[X]*v[X] + v[Y]*v[Y] + v[Z]*v[Z]);
-
- v[X] /= r;
- v[Y] /= r;
- v[Z] /= r;
- }
-
-
- float dot(v1, v2)
- vector v1, v2;
- {
-
- return v1[X]*v2[X]+v1[Y]*v2[Y]+v1[Z]*v2[Z];
- }
-
-