home *** CD-ROM | disk | FTP | other *** search
/ Chestnut's Multimedia Mania / MM_MANIA.ISO / graphics / povsrc20 / txttest.c < prev    next >
C/C++ Source or Header  |  1993-07-29  |  4KB  |  144 lines

  1. /****************************************************************************
  2. *                txttest.c
  3. *
  4. *  This module implements "fill-in-the-blank" pre-programmed texture 
  5. *  functions for easy modification and testing. Create new textures here.
  6. *
  7. *  from Persistence of Vision Raytracer
  8. *  Copyright 1993 Persistence of Vision Team
  9. *---------------------------------------------------------------------------
  10. *  NOTICE: This source code file is provided so that users may experiment
  11. *  with enhancements to POV-Ray and to port the software to platforms other 
  12. *  than those supported by the POV-Ray Team.  There are strict rules under
  13. *  which you are permitted to use this file.  The rules are in the file
  14. *  named POVLEGAL.DOC which should be distributed with this file. If 
  15. *  POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  16. *  Team Coordinator by leaving a message in CompuServe's Graphics Developer's
  17. *  Forum.  The latest version of POV-Ray may be found there as well.
  18. *
  19. * This program is based on the popular DKB raytracer version 2.12.
  20. * DKBTrace was originally written by David K. Buck.
  21. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  22. *
  23. *****************************************************************************/
  24.  
  25. /*
  26.    Some texture ideas garnered from SIGGRAPH '85 Volume 19 Number 3, 
  27.    "An Image Synthesizer" By Ken Perlin.
  28.    Further Ideas Garnered from "The RenderMan Companion" (Addison Wesley)
  29. */
  30.  
  31. #include "frame.h"
  32. #include "vector.h"
  33. #include "povproto.h"
  34. #include "texture.h"
  35.  
  36. /* Test new textures in the routines that follow */
  37.  
  38. /* The painted routines take an x,y,z point on an object and a pointer to the*/
  39. /* object's texture description and return the color at that point           */
  40. /* Similar routines are granite, agate, marble. See txtcolor.c for examples. */ 
  41.  
  42. void painted1 (x, y, z, Pigment, colour)
  43. DBL x, y, z;
  44. PIGMENT *Pigment;
  45. COLOUR *colour;
  46.   {
  47.   /* YOUR NAME HERE */
  48.   VECTOR Colour_Vector;   
  49.  
  50.   if (Options & DEBUGGING)
  51.     printf ("painted1 %g %g %g\n", x, y, z);
  52.  
  53.   DNoise(&Colour_Vector,x,y,z);
  54.   colour ->Red += Colour_Vector.x;
  55.   colour ->Green += Colour_Vector.y;
  56.   colour ->Blue += Colour_Vector.z;
  57.   return;
  58.   }
  59. void painted2 (x, y, z, Pigment, colour)
  60. DBL x, y, z;
  61. PIGMENT *Pigment;
  62. COLOUR *colour;
  63.   {
  64.   int brkindx;
  65.   COLOUR Colour1, Colour2;
  66.  
  67.   /* You could change the parser to take two colors after PAINTED2,           */
  68.   /* but since the colormap is already parsed it's easier to use it during    */
  69.   /* testing. If the texture works out right you can change the parser later. */
  70.   if (Pigment -> Colour_Map != NULL)
  71.     {
  72.     Compute_Colour (&Colour1, Pigment, 0.1);
  73.     Compute_Colour (&Colour2, Pigment, 0.9);
  74.     }
  75.   else
  76.     {
  77.     Make_Colour (&Colour1, 1.0, 1.0, 1.0);
  78.     Colour1.Filter = 0.0;
  79.     Make_Colour (&Colour2, 0.0, 1.0, 0.0);
  80.     Colour2.Filter = 0.0;
  81.     }
  82.  
  83.  
  84.  
  85.   brkindx = (int) FLOOR(x) + (int) FLOOR(z);
  86.  
  87.   if (Options & DEBUGGING)
  88.     printf ("checker %g %g %g\n", x, y, z);
  89.  
  90.   if (brkindx & 1)
  91.     {
  92.     colour->Red = Colour1.Red;
  93.     colour->Green = Colour1.Green;
  94.     colour->Blue = Colour1.Blue;
  95.     colour->Filter = Colour1.Filter;
  96.     }
  97.     else{
  98.     colour->Red = Colour2.Red;
  99.     colour->Green = Colour2.Green;
  100.     colour->Blue = Colour2.Blue;
  101.     colour->Filter = Colour2.Filter;
  102.     }
  103.   return;
  104.   }
  105. void painted3 (x, y, z, Pigment, colour)
  106. DBL x, y, z;
  107. PIGMENT *Pigment;
  108. COLOUR *colour;
  109.   {
  110.   /* YOUR NAME HERE */
  111.   ;
  112.   }
  113.  
  114. /* The bumpy routines take a point on an object,  a pointer to the          */
  115. /* object's texture description and the surface normal at that point and    */
  116. /* return a peturb surface normal to create the illusion that the surface   */
  117. /* has been displaced.                                                      */
  118. /* Similar routines are ripples, dents, bumps. See txtbump.c for examples.  */ 
  119.  
  120. void bumpy1 (x, y, z, Tnormal, normal)
  121. DBL x, y, z;
  122. TNORMAL *Tnormal;
  123. VECTOR *normal;
  124.   {
  125.   /* YOUR NAME HERE */
  126.  
  127.   }
  128.  
  129. void bumpy2 (x, y, z, Tnormal, normal)
  130. DBL x, y, z;
  131. TNORMAL *Tnormal;
  132. VECTOR *normal;
  133.   {
  134.   /* YOUR NAME HERE */
  135.   ;
  136.   }
  137. void bumpy3 (x, y, z, Tnormal, normal)
  138. DBL x, y, z;
  139. TNORMAL *Tnormal;
  140. VECTOR *normal;
  141.   {
  142.   ;
  143.   }
  144.