Function:ss2snfe

From S2PLOT

Revision as of 03:25, 10 March 2008; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

ss2snfe

Set the clipping plane expansion factor.

Prototype

void ss2snfe(float expand);

Description

Set the expansion scale of near and far clipping planes. Use with great caution, particularly in stereoscopic display modes. In general, you should use the default configuration for the clipping planes.

See Also

ss2qnfpQuery the near and far clip plane distances.

Code Example

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

void cb(double *t, int *kc)
{
   XYZ foc = { 0, 0, 0 };                       /* Set the camera focus */
   ss2scf(foc, 1);

   if (*kc % 2 == 1)
      ss2snfe(0.5);                             /* Change the near/far */
   else                                         /*  expansion factor */
      ss2snfe(1.0);                             /*  on <space> press */
}

int main(int argc, char *argv[])
{
   srand48((long)time(NULL));                   /* Seed random numbers */
   s2opend("/s2dsana", argc, argv);             /* Open in anaglyph 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 */

   int i, N = 500;                              /* Loop variables */
   float bound = 2.0;                           /* Bound bigger than window */
   XYZ xyz;                                     /* Point location */
   COLOUR rgb;                                  /* Point colour */
   for (i=0;i<N;i++) {
      xyz.x = 0.0;
      xyz.y = 0.0;
      xyz.z = drand48()*(2.0*bound) - bound;    /* Random z-value for point */
      rgb.r = drand48();
      rgb.g = drand48();
      rgb.b = drand48();
      ns2vthpoint(xyz, rgb, 3);                 /* Draw the point */
   }
   cs2scb(cb);                                  /* Install a dynamic callback */

   XYZ pos = { 0.0, 0.0, +5.0 };                /* Move the camera closer */
   XYZ vd = { 0.0, 0, -1.0 };
   XYZ up = { 0.0, 1.0, 0 };
   ss2sc(pos, up, vd, 1);

   XYZ foc = { 0, 0, 0 };                       /* Set the camera focus */
   ss2scf(foc, 1);

   s2textxy(-1,0.1,0,"Rotate camera and press <space>");
   s2textxy(-0.5,-0.1,0,"to see effect of ss2snfe");

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

   return 1;
}

Back to S2PLOT function list.


Personal tools