Function:ss2qnfp

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 03:25, 10 March 2008
S2plot admin (Talk | contribs)

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

Line 18: Line 18:
==Code Example== ==Code Example==
<code><pre> <code><pre>
 +#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 */
 +
 + double near, far; /* Distance to near/far clip planes */
 + ss2qnfp(&near, &far); /* Query these distances */
 + char string[64]; /* Output as a string */
 + sprintf(string,"Clipping plane distances: Near = %.2lf Far = %.2lf",near, far);
 + s2lab("","","",string); /* Show the string as a screen label */
 +
 +}
 +
 +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;
 +}
 +
</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

ss2qnfp

Query the near and far clip plane distances.

Prototype

void ss2qnfp(double *near, double *far);

Description

Get the actual near and far clip plane distances from the camera in DEVICE coordinates.

See Also

ss2snfeSet the clipping plane expansion factor.

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

   double near, far;                            /* Distance to near/far clip planes */
   ss2qnfp(&near, &far);                        /* Query these distances */
   char string[64];                             /* Output as a string */
   sprintf(string,"Clipping plane distances: Near = %.2lf Far = %.2lf",near, far);
   s2lab("","","",string);                      /* Show the string as a screen label */

}

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