Function:ss2scaf

From S2PLOT

Jump to: navigation, search

ss2scaf

Set the camera position, up vector, view direction and camera rotate/focus point.

Prototype

void ss2scaf(XYZ position, XYZ up, XYZ vdir, XYZ focus, int worldcoords);

Description

Set the camera position, up vector, view direction AND focus (rotate-about) point, all in one shot. If worldcoords > 0 then caller has given world coordinates, otherwise viewport coordinates are used. It is up to the caller to ensure a self-consistent camera position is given (orthogonal vectors).

See Also

ss2sc Set the camera position, up vector and view direction.
ss2qc Query the camera position, up vector and view direction.
ss2sca Set the camera aperture.
ss2qca Query the camera aperture.
ss2scs Set the camera speed.
ss2qcs Query the camera speed.


Code Example

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

int main(int argc, char *argv[])
{
   XYZ pos;                                     /* Camera position */
   XYZ up;                                      /* Camera up vector */
   XYZ view;                                    /* Camera view vector */
   XYZ focus;
   int wc = 1;                                  /* Use world coordinates */
   int i, N = 20;                               /* Loop variables */
   float x, y, z;                               /* Temporary data */

   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("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);     /* Draw coordinate box */

   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  = 8.0;
   up.x   = 0.0; up.y   = 1.0; up.z   = 0.0;
   view.x = 0.0; view.y = 0.0; view.z = -1.0;
   focus.x = 0.0; focus.y = 0.0; focus.z = 1.0;
   ns2thpoint(focus.x, focus.y, focus.z, 1,1,1, 8);

   ss2scaf(pos, up, view, focus, wc);           /* Set new camera position */
   ss2sas(1);

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

   return 1;
}

Back to S2PLOT function list.


Personal tools