Function:ns2vplanett
From S2PLOT
(Difference between revisions)
Revision as of 22:15, 6 January 2009 S2plot admin (Talk | contribs) ← Previous diff |
Current revision S2plot admin (Talk | contribs) |
||
Line 1: | Line 1: | ||
==ns2vplanett== | ==ns2vplanett== | ||
+ | Draw a planet with texture filename. | ||
==Prototype== | ==Prototype== | ||
<code><pre> | <code><pre> | ||
+ | void ns2vplanett(XYZ iP, float ir, COLOUR icol, char *itexturefn,float texture_phase, XYZ axis, float rotation); | ||
</pre></code> | </pre></code> | ||
==Description== | ==Description== | ||
+ | |||
+ | Draw a planet, which is a textured sphere whose texture can be "slid" around the planet, and the planet then rotated about an arbitrary axis. Texture phase is in the range [0..1], while rotation angle is in degrees. | ||
==See Also== | ==See Also== | ||
+ | <table> | ||
+ | <tr><td>[[Function:ns2vplanetx | ns2vplanetx]]</td><td>Draw a planet - vector input.</td></tr> | ||
+ | <tr><td>[[Function:ns2vsphere | ns2vsphere ]]</td><td>Draw a sphere, with a given centre, radius and colour - vector input.</td></tr> | ||
+ | <tr><td>[[Function:ns2spheret | ns2spheret]]</td><td>Draw a textured sphere, with given centre, radius, colour and texture filename </td></tr> | ||
+ | <tr><td>[[Function:ns2vspheret | ns2vspheret]]</td><td>Draw a textured sphere, with given centre, radius, colour and texture filename - vector input.</td></tr> | ||
+ | <tr><td>[[Function:ns2spherex| ns2spherex]]</td><td>Draw a textured sphere, with given centre, radius, colour and texture ID</td></tr> | ||
+ | <tr><td>[[Function:ns2vspherex | ns2vspherex]]</td><td>Draw a textured sphere, with given centre, radius, colour and texture ID - vector input.</td></tr> | ||
+ | <tr><td>[[Function:ns2sphere| ns2sphere]]</td><td>Draw a sphere.</td></tr> | ||
+ | </table> | ||
==Code Example== | ==Code Example== | ||
<code><pre> | <code><pre> | ||
- | </pre></code> | + | #include <stdio.h> |
+ | #include <stdlib.h> | ||
+ | #include "s2plot.h" | ||
- | [[S2PLOT:Function List | Back]] to S2PLOT function list. | + | void cb(double *t, int *kc) |
+ | { | ||
+ | float radius = 0.5; /* Radius of planet */ | ||
+ | XYZ xyz = { -1.0, 0.0, 0.0 }; /* Location of planet */ | ||
+ | static char *texture = "firetile2_pow2_rgb.tga"; /* Texture filename */ | ||
+ | COLOUR colour = { 1.0, 1.0, 0.0 }; /* Yellow */ | ||
+ | static float phase = 30.0; /* Set the texture phase */ | ||
+ | XYZ axis = { 0.0, 0.0, 1.0 }; /* Set the rotation axis */ | ||
+ | static float rotation = 0.0; /* Set the rotation value */ | ||
- | __NOTOC__ | + | ns2vplanett(xyz, radius, colour, texture, phase, axis, rotation); |
- | __NOEDITSECTION__ | + | /* Draw the "planet" */ |
+ | xyz.x = 0.0; /* Shift centre */ | ||
+ | axis.x = 0.0; axis.y = 1.0; axis.z = 0.0; /* New rotation axis */ | ||
+ | ns2vplanett(xyz, radius, colour, texture, phase, axis, rotation); | ||
+ | /* Draw the "planet" */ | ||
- | Back to [[Function:Template | template]] page. | + | xyz.x = 1.0; /* Shift centre */ |
+ | axis.x = 1.0; axis.y = 0.0; axis.z = 0.0; /* New rotation axis */ | ||
+ | ns2vplanett(xyz, radius, colour, texture, phase, axis, rotation); | ||
+ | /* Draw the "planet" */ | ||
+ | |||
+ | rotation += 1.0; /* Update rotation in degrees */ | ||
+ | if (rotation > 360.0) rotation = 0.0; /* Full circle? Reset */ | ||
+ | |||
+ | |||
+ | } | ||
+ | |||
+ | int main(int argc, char *argv[]) | ||
+ | { | ||
+ | |||
+ | s2opend("/?",argc, argv); /* Open the display */ | ||
+ | s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */ | ||
+ | |||
+ | ss2ssr(32); /* Set the sphere resolution */ | ||
+ | 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
ns2vplanett
Draw a planet with texture filename.
Prototype
void ns2vplanett(XYZ iP, float ir, COLOUR icol, char *itexturefn,float texture_phase, XYZ axis, float rotation);
Description
Draw a planet, which is a textured sphere whose texture can be "slid" around the planet, and the planet then rotated about an arbitrary axis. Texture phase is in the range [0..1], while rotation angle is in degrees.
See Also
ns2vplanetx | Draw a planet - vector input. |
ns2vsphere | Draw a sphere, with a given centre, radius and colour - vector input. |
ns2spheret | Draw a textured sphere, with given centre, radius, colour and texture filename |
ns2vspheret | Draw a textured sphere, with given centre, radius, colour and texture filename - vector input. |
ns2spherex | Draw a textured sphere, with given centre, radius, colour and texture ID |
ns2vspherex | Draw a textured sphere, with given centre, radius, colour and texture ID - vector input. |
ns2sphere | Draw a sphere. |
Code Example
#include <stdio.h>
#include <stdlib.h>
#include "s2plot.h"
void cb(double *t, int *kc)
{
float radius = 0.5; /* Radius of planet */
XYZ xyz = { -1.0, 0.0, 0.0 }; /* Location of planet */
static char *texture = "firetile2_pow2_rgb.tga"; /* Texture filename */
COLOUR colour = { 1.0, 1.0, 0.0 }; /* Yellow */
static float phase = 30.0; /* Set the texture phase */
XYZ axis = { 0.0, 0.0, 1.0 }; /* Set the rotation axis */
static float rotation = 0.0; /* Set the rotation value */
ns2vplanett(xyz, radius, colour, texture, phase, axis, rotation);
/* Draw the "planet" */
xyz.x = 0.0; /* Shift centre */
axis.x = 0.0; axis.y = 1.0; axis.z = 0.0; /* New rotation axis */
ns2vplanett(xyz, radius, colour, texture, phase, axis, rotation);
/* Draw the "planet" */
xyz.x = 1.0; /* Shift centre */
axis.x = 1.0; axis.y = 0.0; axis.z = 0.0; /* New rotation axis */
ns2vplanett(xyz, radius, colour, texture, phase, axis, rotation);
/* Draw the "planet" */
rotation += 1.0; /* Update rotation in degrees */
if (rotation > 360.0) rotation = 0.0; /* Full circle? Reset */
}
int main(int argc, char *argv[])
{
s2opend("/?",argc, argv); /* Open the display */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
ss2ssr(32); /* Set the sphere resolution */
cs2scb(cb); /* Install dynamic callback */
s2show(1); /* Open the s2plot window */
return 1;
}
Back to S2PLOT function list.