Function:ns2vplanett

From S2PLOT

Jump to: navigation, search

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

ns2vplanetxDraw a planet - vector input.
ns2vsphere Draw a sphere, with a given centre, radius and colour - vector input.
ns2spheretDraw a textured sphere, with given centre, radius, colour and texture filename
ns2vspheretDraw a textured sphere, with given centre, radius, colour and texture filename - vector input.
ns2spherexDraw a textured sphere, with given centre, radius, colour and texture ID
ns2vspherexDraw a textured sphere, with given centre, radius, colour and texture ID - vector input.
ns2sphereDraw 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.


Personal tools