Example #1
0
int main(int argc, char *argv[])
{
   int i, N = 20;				/* Loop variables */
   float x, y, z;				/* Random data */
   XYZ focus;					/* Point to rotate about */
   int wc = 1;					/* Use world coordinates */

   srand48((long)time(NULL));			/* Seed random numbers */

   s2opend("/?",argc, argv);			/* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */

   s2slw(3);					/* Set line width */
   for (i=0;i<N;i++) {
      x = drand48()*2.0 - 1.0;			/* Random (x,y,z) */
      y = drand48()*2.0 - 1.0;
      z = drand48()*2.0 - 1.0;
      s2sci(15*drand48() + 1);			/* Random colour */
      s2pt1(x,y,z,1);				/* Plot the point */
   }

   focus.x = drand48()*2.0 - 1.0;		/* Random rotation point */
   focus.y = drand48()*2.0 - 1.0;
   focus.z = drand48()*2.0 - 1.0;
   ss2scf(focus, wc);				/* Set the rotation point */

   s2sch(0.7);					/* Set text height */
   s2textxy(-1,0,0,"Rotate camera - then press 1 followed by +"); 

   cs2sncb(&numcb);				/* Install number callback */

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Example #2
0
void cb(double *t, int *kc)
/* Dynamic callback function */
{
   XYZ rot; 
   int wc = 1;				/* Use world coordinates */
   XYZ off = { 0.01, 0.01, 0.0 };	/* Small offset for text */

   int set;
   char string[255];
   s2sch(0.05);				/* Set the text height */
   if (*kc%2 == 0) {
      ss2qpr(&rot, wc);			/* Query the rotation point */ 
      sprintf(string,"Rotation about (%.2f, %.2f, %.2f)",rot.x,rot.y,rot.z);
      XYZ xyz = { 0.5, 0.5, 0.5 };
      ss2scf(xyz, wc);			/* Set the camera focus */
   } else {
      ss2qcf(&set, &rot, wc);		/* Query the camera focus */
      sprintf(string,"Focus at (%.2f, %.2f, %.2f)",rot.x,rot.y,rot.z);
   }
   ds2vtb(rot, off,string,1);		/* Write some dynamic billboard text */
   s2lab("","","","<space> to toggle mode");
					/* Display an instructional label */

}