Example #1
0
int main(int argc, char *argv[])
{
   int i, N = 20;
   float x[20], y[20], z[20];			/* Static geometry */

   srand48((long)time(NULL));			/* Seed random numbers */
   for (i=0;i<N;i++) {
      x[i] = drand48()*4.0-2.0;			/* Random positions */
      y[i] = drand48()*4.0-2.0;
      z[i] = drand48()*4.0-2.0;
   }
  
   s2opend("/?",argc, argv);			/* Open the display */
   s2swin(-2.,2., -2.,2., -2.,2.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */

   cs2scb(&cb);                                  /* Install the callback */
   cs2sncb(&ncb);                              /* Install number callback */
 
   s2slw(4);					/* Set line width */
   s2sci(S2_PG_YELLOW);
   s2pt(N,x,y,z,1);				/* Draw static data */
   s2slw(1);

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Example #2
0
int main(int argc, char *argv[])
{
   int i;				/* Loop variable */
   XYZ xyz;				/* Coordinate for plotting points */
   COLOUR col;				/* Colour of plotted points */

   s2opend("/S2MONO",argc,argv);	/* Query the s2plot device to use */
   s2swin(-1.,1.,-1.,1.,-1.,1.);	/* Set the world coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);	/* Draw a coordinate box */

   srand48((long)time(NULL));		/* Seed the random number generator */

   for (i=0;i<1000;i++) {		/* Generate and plot random points */
      xyz.x = drand48()*2.0 - 1.0;	/*  with random colours */
      xyz.y = drand48()*2.0 - 1.0;
      xyz.z = drand48()*2.0 - 1.0;
      col.r = drand48();
      col.g = drand48();
      col.b = drand48();
      ns2vpoint(xyz, col);
   }
   ss2sas(1);				/* Start the geometry auto-spinning */
   cs2scb(cb);				/* Install a dynamic callback */
   s2show(1);				/* Display the geometry */
   return 0;
}
Example #3
0
int main(int argc, char *argv[])
{
   int width = 16, height = 16;		/* Dimensions of texture */
   int i, j;				/* Loop variables */
   int idx;				/* Index into texture array */
   unsigned char *tex;				/* Array of texture values */

   srand48((long)time(NULL));			/* Seed random numbers */
   s2opend("/?",argc,argv);			/* Open the display */
   s2svp(-1.0,1.0, -1.0,1.0, -1.0,1.0);		/* Set the viewport coords */
   s2swin(-1.0,1.0, -1.0,1.0, -1.0,1.0);	/* Set the window coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);	/* Draw a bounding box */

   tid = ss2ct(width, height);		/* Create a new texture */
   tex = ss2gt(tid, &width, &height);	/* Get the texture */

   for (j=0;j<height;j++) {
      for (i=0;i<width;i++) {
         idx = (j*width + i) * 4;		/* Stored as (r,g,b,alpha) */
         tex[idx  ] = 127*drand48()+128;	/* Randomish red */
         tex[idx+1] = 0;			/* Green */
         tex[idx+2] = 0;			/* Blue */
						/* Do nothing to alpha */
      }
   }
   ss2pt(tid);				/* Push texture for usage */

   cs2scb(&cb);				/* Install a callback */

   s2show(1);				/* Open the s2plot window */

   return 1;
}
Example #4
0
int main(int argc, char *argv[])
{
   fprintf(stderr,"Resize window to see change in panel size");

   s2opend("/s2mono", argc, argv);             	/* Open in mono mode */
   s2swin(-1.,1., -1.,1., -1.,1.);              /* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);  /* Draw coordinate box */
   
   cs2scb(cb);					/* Install dynamic callback */
   s2show(1);                                   /* Open the s2plot window */

   return 1;
}
Example #5
0
int main(int argc, char *argv[])
{

   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 */

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

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Example #6
0
int main(int argc, char *argv[])
{

   srand48((long)time(NULL));                   /* Seed random numbers */
   s2opend("/s2mono",argc, argv);		/* Open the display: mono */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);	/* Draw coordinate box */

   s2lab("","","","Press < and > to change camera movement increment, then +/- to test zooming\n"); 

   cs2scb(cb);					/* Install dynamic callback */
   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Example #7
0
int main(int argc, char *argv[])
{

   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 */

   cs2scb(cb);					/* Install a dynamic callback */

   s2show(1);					/* Open the s2plot window */

   
   return 1;
}
Example #8
0
int main(int argc, char *argv[])
{
   int Nx = 32, Ny = 32, Nz = 32;		/* Texture dimensions */
   int w,h,d;					/* Returned dimensions */

   s2opend("/?",argc,argv);			/* Open the s2plot display device */
   s2swin(-1,1,-1,1,-1,1);			/* Set the world coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);
	
   texid = ss2c3dt(Nx, Ny, Nz);			/* Create a new 3d texture */
   unsigned char *bits = (unsigned char *)ss2g3dt(texid, &w, &h, &d);
						/* Get the texture data for modification */
   int i, j, k;
   long idx;
   float x,y,z;  
   for (i=0;i<Nx;i++) {
      x = -1.0 + i*(2.0/(float)(Nx-1));
      for (j=0;j<Ny;j++) {
         y = -1.0 + j*(2.0/(float)(Ny-1));
         for (k=0;k<Nz;k++) {
            z = -1.0 + k*(2.0/(float)(Nz-1));
            idx = ((i*Ny + j)*Nz + k)*4;
	    if ((x*x + y*y + z*z) < 1.0) {	/* 3D solid red sphere */
               bits[idx + 1 ] = 255;
               ns2point(x,y,z,1,1,1);		/* Plot point in sphere */
            } else { 
               bits[idx + 0 ] = 0;
            }

	    bits[idx + 1 ] = 0;			/* Blue channel */
	    bits[idx + 2 ] = 0;			/* Green channel */
	    bits[idx + 3 ] = 255;		/* Alpha channel */
         }     
      }     
   }     

   fprintf(stderr, "3d texture IS %d x %d x %d\n", w, h, d);
   ss2pt(texid);				/* Push back the texture */

   cs2scb(cb);					/* Install a dynamic callback */
   				
   s2show(1);					/* Display the geometry */

   return 0;
}
Example #9
0
int main(int argc, char *argv[])
{
   srand48((long)time(NULL));			/* Seed random numbers */
   s2opend("/?", argc, argv);			/* Prompt for display type */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */

   cs2scb(cb);					/* Install dynamic geometry callback */
   cs2sncb(ncb);				/* Install number key press callback */

   char string[128];				/* Write instruction label */
   sprintf(string,"Press 1 to protect, press 2 to unprotect");
   s2lab("","","",string);

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Example #10
0
int main(int argc, char *argv[])
{
   int i;                                       /* Loop varibale */
   float x, y, z;                               /* Random data */

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

   fprintf(stderr,"Shift-s to toggle handles\nShift-c to toggle crosshair\n");
   fprintf(stderr,"Right mouse select\nSpacebar toggle show all/show sel\n");
   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 */

   for (i=0;i<N;i++) {                          /* Set-up globals */
      xyz[i].x = drand48()*2.0 - 1.0;           /* Random position */
      xyz[i].y = drand48()*2.0 - 1.0;
      xyz[i].z = drand48()*2.0 - 1.0;
      col[i].r = drand48();                     /* Random colour */
      col[i].g = drand48();
      col[i].b = drand48();
      sel[i]   = 0;                             /* Not currently selected */
   }

   cs2scb(&cb);                                  /* Install dynamic callback */
   cs2shcb(&pick);                               /* Install handle callback */

   s2slw(2);                                    /* Set line width */
   for (i=0;i<N;i++) {          /* Non-selectable random data points */
      x = drand48()*2.0 - 1.0;
      y = drand48()*2.0 - 1.0;
      z = drand48()*2.0 - 1.0;
      s2sci(15*drand48() + 1);                  /* Random colour */
      s2pt1(x,y,z,1);
   }

   s2show(1);                                   /* Open the s2plot window */

   return 1;
}
Example #11
0
int main(int argc, char *argv[])
{
   s2opend("/s2mono", argc, argv);             	/* Open in mono mode */
   s2swin(-1.,1., -1.,1., -1.,1.);              /* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);  /* Draw coordinate box */
   
   xs2mp(master_panel, 0.0, 0.5, 0.5, 1.0);	/* Move to top left */

   slave_panel = xs2ap(0.5, 0.0, 1.0, 0.5);	/* Create panel in bottom right */
   xs2cp(slave_panel);				/* Choose this panel */
   s2swin(-2.,2., -2.,2., -2.,2.);              /* Set the window coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);  	/* Draw coordinate box */
  
   xs2cp(master_panel);				/* Go back to main panel */
   cs2scb(cb);					/* Install dynamic callback */

   fprintf(stderr,"Press <tab> to switch between panels\n");
   fprintf(stderr,"Press <spacebar> to link cameras together - cannot be undone\n");
   fprintf(stderr,"Futher presses of <spacebar> toggle panel visiblity\n");

   s2show(1);                                   /* Open the s2plot window */

   return 1;
}