Function:ss2scs
From S2PLOT
(Difference between revisions)
Revision as of 01:54, 6 January 2009 S2plot admin (Talk | contribs) ← Previous diff |
Current revision S2plot admin (Talk | contribs) |
||
Line 1: | Line 1: | ||
==ss2scs== | ==ss2scs== | ||
+ | Set the camera speed. | ||
==Prototype== | ==Prototype== | ||
<code><pre> | <code><pre> | ||
+ | void ss2scs(float spd); | ||
</pre></code> | </pre></code> | ||
==Description== | ==Description== | ||
+ | Set the camera speed (ie. increment amount for camera movements. Values between 0.01 and 20.0 are reasonably sensible. | ||
+ | |||
+ | ==See Also== | ||
+ | <table> | ||
+ | <tr><td>[[Function:ss2qcs | ss2qcs ]]</td><td>Query the camera speed. </td></tr> | ||
+ | <tr><td>[[Function:ss2qca | ss2qca ]]</td><td>Query the camera aperture. </td></tr> | ||
+ | <tr><td>[[Function:ss2sca | ss2sca ]]</td><td>Set the camera aperture. </td></tr> | ||
+ | <tr><td>[[Function:ss2sc | ss2sc ]]</td><td>Set 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> | ||
+ | </table> | ||
==Code Example== | ==Code Example== | ||
<code><pre> | <code><pre> | ||
- | </pre></code> | + | #include <stdio.h> |
+ | #include <stdlib.h> | ||
+ | #include <time.h> | ||
+ | #include "s2plot.h" | ||
- | [[S2PLOT:Function List | Back]] to S2PLOT function list. | + | void cb(double *t, int *kc) |
+ | { | ||
+ | static int lkc = 0; /* Count of key presses */ | ||
+ | static float spd = 1.0; /* Set the camera increment */ | ||
+ | if (lkc != *kc) { /* Query whether <space> was pressed */ | ||
+ | spd += 2.0; /* Update the camera increment */ | ||
+ | } | ||
+ | ss2scs(spd); /* Set the new camera increment */ | ||
+ | char string[32]; /* Write current increment to screen */ | ||
+ | sprintf(string,"%.2f",spd); | ||
+ | s2textxy(0,0,0,string); /* Display text */ | ||
- | __NOTOC__ | + | lkc = *kc; /* Update key press count */ |
- | __NOEDITSECTION__ | + | } |
- | Back to [[Function:Template | template]] page. | + | int main(int argc, char *argv[]) |
+ | { | ||
+ | |||
+ | srand48((long)time(NULL)); /* Seed random numbers */ | ||
+ | s2opend("/s2mono",argc, argv); /* Open the display: mono */ | ||
+ | s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */ | ||
+ | s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0); /* Draw coordinate box */ | ||
+ | |||
+ | s2lab("","","","Press <space> to change camera movement increment, then +/- to test zooming\n"); | ||
+ | |||
+ | cs2scb(cb); /* Install dynamic callback */ | ||
+ | s2show(1); /* Open the s2plot window */ | ||
+ | |||
+ | return 1; | ||
+ | } | ||
+ | </pre></code> | ||
+ | |||
+ | [[S2PLOT:Function List | Back]] to S2PLOT function list. | ||
+ | |||
+ | __NOTOC__ | ||
+ | __NOEDITSECTION__ |
Current revision
ss2scs
Set the camera speed.
Prototype
void ss2scs(float spd);
Description
Set the camera speed (ie. increment amount for camera movements. Values between 0.01 and 20.0 are reasonably sensible.
See Also
ss2qcs | Query the camera speed. |
ss2qca | Query the camera aperture. |
ss2sca | Set the camera aperture. |
ss2sc | Set the camera position, up vector and view direction. |
ss2qc | Query the camera position, up vector and view direction. |
Code Example
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "s2plot.h"
void cb(double *t, int *kc)
{
static int lkc = 0; /* Count of key presses */
static float spd = 1.0; /* Set the camera increment */
if (lkc != *kc) { /* Query whether <space> was pressed */
spd += 2.0; /* Update the camera increment */
}
ss2scs(spd); /* Set the new camera increment */
char string[32]; /* Write current increment to screen */
sprintf(string,"%.2f",spd);
s2textxy(0,0,0,string); /* Display text */
lkc = *kc; /* Update key press count */
}
int main(int argc, char *argv[])
{
srand48((long)time(NULL)); /* Seed random numbers */
s2opend("/s2mono",argc, argv); /* Open the display: mono */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0); /* Draw coordinate box */
s2lab("","","","Press <space> to change camera movement increment, then +/- to test zooming\n");
cs2scb(cb); /* Install dynamic callback */
s2show(1); /* Open the s2plot window */
return 1;
}
Back to S2PLOT function list.