Function:ss2sc

From S2PLOT

Revision as of 01:24, 30 October 2007; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

ss2sc

Set the camera position, up vector and view direction.

Prototype

void ss2sc(XYZ position, XYZ up, XYZ vdir, int worldcoords);

Description

Set the camera position, up vector and view direction (vdir). If worldcoords > 0 then caller has given world coordinates, otherwise they are viewport-relative coordinates.

See Also

ss2qc Query the camera position, up vector and view direction.
ss2tc Enable/disable (1,0) camera translation.


Code Example

#include <stdio.h>
#include <stdlib.h>
#include "s2plot.h"

int main(int argc, char *argv[])
{
   XYZ pos;					/* Camera position */
   XYZ up;					/* Camera up vector */
   XYZ view;					/* Camera view vector */
   int wc = 1;					/* Use world coordinates */
   int i, N = 20;				/* Loop variables */
   float x, y, z;				/* Temporary data */
   
   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 positions */
      y = drand48()*2.0 - 1.0;
      z = drand48()*2.0 - 1.0;
      s2sci(15*drand48()+1);			/* Random colour */
      s2pt1(x, y, z, 1);
   }

   pos.x  = 0.0; pos.y  = 0.0; pos.z  = 10.0;
   up.x   = 0.5; up.y   = 0.5; up.z   = 0.0;
   view.x = 0.0; view.y = 0.0; view.z = -1.0;

   ss2sc(pos, up, view, wc);		/* Set new camera position */

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

Back to S2PLOT function list.


Personal tools