/***********************************************************
/* A program to generate symbolic walkers as dynamic, three dimensional /* color
graphic displays. We, the viewers, move into the seen in a
/* straight line, while our "gaze" is on this walker
/*
/*
/* The basis for this code was a program written by James E. Cutting,
/* published in Behavior Research Methods & Instrumentation (1978, Vol. /* 10
(1), 91-94), under the * title of "A program to generate synthetic /* walkers as *
dynamic point-light displays." The orginal program was * /* written in FORTAN 77
on a 32K Hewlett-Packard HP-100 * L-Series P /* for a Tektronix 604 monitor
display driven by a Data General Nova.
/*
/* Modifications by J.E.C. beginning 23 Sept 91
/* latest 18 Mar 92, Laurence Kaplan adaptation
/*
/***********************************************************/
/* attach the code to the 'C' libraries it requires */ #include
/* standard input & output */
#include
#include /* graphics library */
#include /* math functions */
#include /* interactive device */
#include
#include /* } */
#include
#include /* } time/timing functions */
#include /* } */
#include
/* define the global constants */
/* math */
#define PI 3.1415926
#define RAD 0.017453292 /* degree to radian conversion constant */
#define DEG 57.29577951 /* radian to degree conversion constant */
/* body */
#define TORSO 85.0 /* height or length of torso */
#define SW 25.0 /* shoulder width */
#define HW 15.0 /* hip width */
/* walker object */
#define NUM_STEPS 6 /* number of steps to be taken by walker */
#define Z1 0.0 /* where in z-plane walker is to walk */
/* colors */
#define GROUND 1 /* color of ground plane in bkgnd scenery */
#define FIXTREE 9
#define TREECOLOR 10
/* viewing */
#define VISANG 300 /* cone of vision */
#define EYE_HT 255.0
/* forest */
#define NUMTR 60
#define NTRI 9 /* 8 plus 1 */
/* declare global variables */
/* the coords for cube object from which walker is created */
long side[6][4][3] ={{-1,-1,1}, {1,-1,1}, {1,1,1}, {-1,1,1},
{1,-1,1}, {1,-1,-1}, {1,1,-1}, {1,1,1},
{1,-1,-1}, {-1,-1,-1}, {-1,1,-1}, {1,1,-1},
{-1,-1,-1}, {-1,-1,1}, {-1,1,1}, {-1,1,-1},
{-1,1,1}, {1,1,1}, {1,1,-1}, {-1,1,-1},
{-1,-1,-1}, {1,-1,-1}, {1,-1,1}, {-1,-1,1}};
/* variables used by time functions */
struct tms t1;
long time1,time2;
double tim, starttim;
struct timeval tp;
struct timezone tzp;
float x,y,z,xx,zz,xx1,zz1;
int REDO,TRI,RESP,SDIR,SX,SZ,GRID,TREES,INCR,t,tt,tmod,j,OUT; char
fname[20];
FILE *fp,*fopen();
Coord rno[NUMTR][3];
int afile[NTRI][6];
int tord[NTRI];
int tinfo[NTRI][3] ={0,0,0,
/* x z angle */
-4943, 0, 0,
/* in front and behind */
4943, 0, 180,
0, -4943, 90,
/*on either side*/
0, 4943, 270,
3445, -3445, 135,
/*in front and to the side*/
3445, 3445, 225,
-3445, -3445, 45,
/*behind and to the side*/
-3445, 3445, 315};
/* the graphical objects that make up the walker and scenery */ Object
cube,Groundplane,Floorgrid,Tree1,Cylinder;
/***************************************************************************
* MAIN function/procedure of the program *
***************************************************************************/ main () {
/* declare functions */
void initialize_variables (),
setup_windows_graphics_devices (),
setup_underdraw(),
make_objects (),
ankle_table (),
get_hips (),
get_ankles (),
get_shoulders (),
get_wrists (),
get_knees (),
get_elbows (),
get_midpoint (),
clear_screen (),
draw_corpse (),
draw_head (),
draw_part (),
draw_torso (),
get_angle (),
locomotion (),
stop_and_wait (),
clean_up ();
/* declare variables */
float humor,ulna,tibia,femur,leg, /* lengths of body parts */
step, hstep, /* length of step, half-step */ hex, hey, /* hip ellipses, x&y axes */
sex, sey, /* shoulder ellipses,x&y-axes*/
sher, /* shoulder excursion as multiple of hip */
time, /* cmsec per frame */
bounce, /* up & down mvt of body */
swf, /* femur swing */
swh, /* humor swing, f(sholder swing&step */
swu, /* ulna swing */
swt, /* tibia swing, 25=atan(foot/tibia) */
femfo, /* forward tilt of femur pendulum */
delay, /* degrees pre- and post-femur swing that tibia
swings due to foot & to compound pendulum */
cosff, /* y correction for hip */
xlean, ylean, /* upper body lean, f(speed), 2 deg modal */ xinit, yinit, /* initial x & y
values in screen units */ falfo, /* mvt falling forwards w/in overlay period
due to tibia swing and foot */
sia[541]; /* ankle table, broad w-shaped, 0-540 deg. */
int ip, ist; /* used for SWAPINTERVAL */
char ss[10];
int c,k;
fmfonthandle f;
fmfonthandle fsized;
/* printf("filename = ");
scanf("%s",fname);
*/
/* main routines */
/* initialize the variables */
initialize_variables (&humor,&ulna,&femur,&tibia,&leg,&step,
&sher,&time,&hex,&hey,&sex,&sey,&swf,&swh,
&swu,&swt,&hstep,&bounce,&delay,&xlean,&ylean,
&xinit,&yinit,&falfo,&femfo,&cosff,&ip,&ist);
/* set up the windows, the graphics configuration, objects, etc. */
setup_windows_graphics_devices ();
/* generate the ankle table */
ankle_table (delay,sia);
rnorder();
/*for (t=1; t 180) cosi=sin((i-90)*RAD);
if ((i >= (180-delay)) && (i = (360-delay)) || (i 359) tmod=(k+tt)%360;
if ((k>=140) && (ky2)) || ((x1>x2) && (y1tord[k]){
for (j=in; j>k; j=j-1)
tord[j]=tord[j-1];
}
tord[k]=itemp;
}
}
/*********************************************************************
* clear the screen *
*********************************************************************/ clearscreen () {
color (BLACK);
clear ();
zclear();
}
/*********************************************************************
* take care of any window changes or input from mouse and keyboard *
*********************************************************************/ processinput () {
short val;
int dev;
dev=qread (&val);
switch (dev) {
case MIDDLEMOUSE: /* user wants to repeat */
TRI=TRI-1;
REDO=1;
qreset();
return;
case RIGHTMOUSE:
RESP=1;
REDO=0;
return;
case LEFTMOUSE:
RESP=2;
REDO=0;
return;
case ESCKEY: /* end program */
OUT=1;
return;
default:
return;
}
}
/*********************************************************************
* draw the trees *
*********************************************************************/
drawtrees (xx,zz)
float xx,zz;
{
int c,r,w;
float x1,z1;
color(TREECOLOR);
for (c=1;c
translate(rno[c][0]-rno[c-1][0],0.0,
rno[c][1]-rno[c-1][1]);
x1=rno[c][0]-xx;
z1=rno[c][1]-zz;
x1=sqrt(x1*x1+z1*z1);
w=3.0*tan(1.0/x1)/tan(1.0/5000.0);
linewidth((short)w);
r=rno[c][2];
if(c==(NUMTR-1)) color(FIXTREE);
pushmatrix();
rotate(r,'y');
scale(10.0,10.0,10.0);
callobj(Tree1);
popmatrix();
}
}
/*********************************************************************
* generate the random coordinates of each of the 6 randomly placed trees
*********************************************************************/ generatecoords () {
int c;
float angd,angr,angl;
rno[0][0]=0.0;
rno[0][1]=0.0;
for (c=1;c
rno[c][0]=20000.0*((float)rand())/32767.0 - 10000.0; rno[c][1]=10000.0 -
200.0*c*(100.0/NUMTR); rno[c][2]=((float)rand()/32767.0)*3600.0;
}
rno[NUMTR-1][0]=0.0;
rno[NUMTR-1][1]=0.0;
}
/*********************************************************************
* stop and wait for the ESC to be queued by the user/viewer *
*********************************************************************/ void stop_and_wait
(){
int i;
while (getbutton (ESCKEY) == FALSE);
}