Function:ss2sc

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 01:24, 30 October 2007
S2plot admin (Talk | contribs)

← Previous diff
Current revision
S2plot admin (Talk | contribs)

Line 16: Line 16:
<table> <table>
<tr><td>[[Function:ss2qc | ss2qc ]]</td><td>Query the camera position, up vector and view direction. </td></tr> <tr><td>[[Function:ss2qc | ss2qc ]]</td><td>Query the camera position, up vector and view direction. </td></tr>
-<tr><td>[[Function:ss2tc | ss2tc ]]</td><td>Enable/disable (1,0) camera translation. </td></tr>+<tr><td>[[Function:ss2sca | ss2sca ]]</td><td>Set the camera aperture. </td></tr>
 +<tr><td>[[Function:ss2qca | ss2qca ]]</td><td>Query the camera aperture. </td></tr>
 +<tr><td>[[Function:ss2scs | ss2scs ]]</td><td>Set the camera speed. </td></tr>
 +<tr><td>[[Function:ss2qcs | ss2qcs ]]</td><td>Query the camera speed. </td></tr>
</table> </table>
Line 24: Line 27:
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
 +#include <time.h>
#include "s2plot.h" #include "s2plot.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
- XYZ pos; /* Camera position */+ XYZ pos; /* Camera position */
- XYZ up; /* Camera up vector */+ XYZ up; /* Camera up vector */
- XYZ view; /* Camera view vector */+ XYZ view; /* Camera view vector */
- int wc = 1; /* Use world coordinates */+ int wc = 1; /* Use world coordinates */
- int i, N = 20; /* Loop variables */+ int i, N = 20; /* Loop variables */
- float x, y, z; /* Temporary data */+ 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 */+ 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++) { for (i=0;i<N;i++) {
- x = drand48()*2.0 - 1.0; /* Random positions */+ x = drand48()*2.0 - 1.0; /* Random positions */
y = drand48()*2.0 - 1.0; y = drand48()*2.0 - 1.0;
z = drand48()*2.0 - 1.0; z = drand48()*2.0 - 1.0;
- s2sci(15*drand48()+1); /* Random colour */+ s2sci(15*drand48()+1); /* Random colour */
s2pt1(x, y, z, 1); s2pt1(x, y, z, 1);
} }
Line 52: Line 58:
view.x = 0.0; view.y = 0.0; view.z = -1.0; view.x = 0.0; view.y = 0.0; view.z = -1.0;
- ss2sc(pos, up, view, wc); /* Set new camera position */+ ss2sc(pos, up, view, wc); /* Set new camera position */
 + 
 + s2show(1); /* Open the s2plot window */
- s2show(1); /* Open the s2plot window */ 
-  
return 1; return 1;
} }
 +
</pre></code> </pre></code>
[[S2PLOT:Function List | Back]] to S2PLOT function list. [[S2PLOT:Function List | Back]] to S2PLOT function list.
__NOTOC__ __NOTOC__
__NOEDITSECTION__ __NOEDITSECTION__

Current revision

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.
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 */
   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("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