void cb(double *t, int *kc) { static XYZ orbit; /* Position of point to draw */ static float tt = 0; /* Current position in orbit */ orbit.x = cos(tt); /* Update point position */ orbit.y = sin(tt); tt += 0.05; COLOUR ocol = { 1, 1, 0 }; /* Point colour = yellow*/ ns2vthpoint(orbit, ocol, 3); /* Draw the point */ }
void cb(double *t, int *kc) { COLOUR hilite = { 1.0, 1.0, 1.0 }; /* Highlight colour */ float hsize = 0.02; /* Size of handle */ int i; /* Loop variable */ if ((*kc%2) == 0) { for (i=0;i<N;i++) { ns2vthpoint(xyz[i], col[i], 3); /* Draw thick point */ ds2ah(xyz[i], hsize, col[i], hilite, i, sel[i]); /* Draw handles */ } } else { for (i=0;i<N;i++) { /* Only show selected */ if (sel[i]) { ns2vthpoint(xyz[i], col[i], 3); /* Draw thick point */ ds2ah(xyz[i], hsize, col[i], hilite, i, sel[i]); /* Draw handles */ } } } }
void cb(double *t, int *kc) { XYZ xyz = {0.0, 0.3, 0.4}; /* Location */ float isize = 0.05; /* Texture scale */ XYZ offset = { 0.2, 0.1, 0.0}; /* Texture offset to reference point */ float aspect = 2.2; /* Aspect ratio */ COLOUR col = { 1.0, 1.0, 0.0 }; /* Yellow */ float alpha = 0.9; /* Alpha channel */ char trans = 's'; /* Transparency */ float pangle = 45.0; ds2vbbpr(xyz, offset, aspect, isize, pangle, col, tid, alpha, trans); /* Billboard with aspect ratio and offset */ ns2vthpoint(xyz, col, 3); /* Plot texture reference point */ }
void cb(double *t, int *kc) { int N = 100; /* Number of points */ static int flag = -1; /* Flag for initialisation */ static XYZ xyz[100]; /* Array of point positions */ static COLOUR col[100]; /* Array of colours */ int i; /* Loop variable */ if (flag < 0) { /* First time through? */ for (i=0;i<N;i++) { xyz[i].x = drand48()*2.0 - 1.0; /* Random data positions */ xyz[i].y = drand48()*2.0 - 1.0; xyz[i].z = drand48()*2.0 - 1.0; col[i].r = drand48(); /* Random data colours */ col[i].g = drand48(); col[i].b = drand48(); } flag = 1; /* Set the flag */ } s2swin(-0.8,0.8,-0.8,0.8,-0.8,0.8); /* Set new plotting window */ for (i=0;i<N;i++) { ns2vthpoint(xyz[i], col[i], 3); /* Draw the point */ } if (*kc % 2 == 1) /* Check for keyboard press */ s2twc(1); /* Turn on clipping */ else s2twc(0); /* Turn off clipping */ int wc = s2qwc(); /* Query clipping state */ char text[32]; sprintf(text, "Clipping state: %d\n",wc); /* Prepare a text string */ s2textxy(0.0,0.0,0.0, text); /* Display text string */ s2lab("","","","Press <space> to toggle clipping state"); }
void cb(double *t, int *kc) { int N = 100; /* Number of points */ static int flag = -1; /* Flag for initialisation */ static XYZ xyz[100]; /* Array of point positions */ static COLOUR col[100]; /* Array of colours */ int i; /* Loop variable */ if (flag < 0) { /* First time through? */ for (i=0;i<N;i++) { xyz[i].x = drand48()*2.0 - 1.0; /* Random data positions */ xyz[i].y = drand48()*2.0 - 1.0; xyz[i].z = drand48()*2.0 - 1.0; col[i].r = drand48(); /* Random data colours */ col[i].g = drand48(); col[i].b = drand48(); } flag = 1; /* Set the flag */ } for (i=0;i<N;i++) { ns2vthpoint(xyz[i], col[i], 3); /* Draw the point */ } static int lkc = 1; /* Last time <space> key pressed */ if (lkc != *kc) /* Check for keyboard press */ ss2sca(drand48()*70 + 20); /* Set the camera aperture */ lkc = *kc; /* Update key press */ int wc = ss2qca(); /* Query camera aperture */ char text[64]; sprintf(text, "Aperture %d degrees\n",wc); /* Prepare a text string */ s2textxy(0.0,0.0,0.0, text); /* Display text string */ s2lab("","","","Press <space> to change camera aperture"); }