home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Graphics / Graphics.zip / povsrc31.zip / txttest.c < prev    next >
C/C++ Source or Header  |  1999-10-20  |  7KB  |  312 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(tm) Ray Tracer
  8. *  Copyright 1996,1999 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.
  15. *  If POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  16. *  Team Coordinator by email to team-coord@povray.org or visit us on the web at
  17. *  http://www.povray.org. The latest version of POV-Ray may be found at this site.
  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.  *
  29.  * Further Ideas Garnered from "The RenderMan Companion" (Addison Wesley)
  30.  */
  31.  
  32. #include "frame.h"
  33. #include "vector.h"
  34. #include "povproto.h"
  35. #include "texture.h"
  36. #include "povray.h"    /* [DB 9/94] */
  37. #include "txttest.h"   /* [DB 9/94] */
  38. #include "pattern.h"   /* [CY 10/94] */
  39.  
  40.  
  41.  
  42. /*****************************************************************************
  43. * Local preprocessor defines
  44. ******************************************************************************/
  45.  
  46.  
  47.  
  48. /*****************************************************************************
  49. * Local typedefs
  50. ******************************************************************************/
  51.  
  52.  
  53.  
  54. /*****************************************************************************
  55. * Local variables
  56. ******************************************************************************/
  57.  
  58.  
  59.  
  60. /*****************************************************************************
  61. * Static functions
  62. ******************************************************************************/
  63.  
  64.  
  65.  
  66. /*
  67.  * Test new textures in the routines that follow.
  68.  */
  69.  
  70. /*****************************************************************************
  71. *
  72. * FUNCTION
  73. *
  74. *   pattern1
  75. *
  76. * INPUT
  77. *   
  78. * OUTPUT
  79. *   
  80. * RETURNS
  81. *   
  82. * AUTHOR
  83. *
  84. *   POV-Ray Team
  85. *   
  86. * DESCRIPTION
  87. *
  88. *   The pattern routines take an x,y,z point on an object and a pointer to
  89. *   the object's texture description and return the color at that point
  90. *   Similar routines are granite, agate, marble. See txtcolor.c for examples.
  91. *
  92. * CHANGES
  93. *
  94. ******************************************************************************/
  95.  
  96. DBL pattern1 (VECTOR EPoint, TPATTERN *TPat)
  97. {
  98.   DBL value;
  99.   /* YOUR NAME HERE */
  100.  
  101.   TPat=TPat;
  102.  
  103.   value = Noise(EPoint);
  104.  
  105.   return(value);
  106.  
  107. }
  108.  
  109.  
  110.  
  111. /*****************************************************************************
  112. *
  113. * FUNCTION
  114. *
  115. *   pattern2
  116. *
  117. * INPUT
  118. *   
  119. * OUTPUT
  120. *   
  121. * RETURNS
  122. *   
  123. * AUTHOR
  124. *
  125. *   POV-Ray Team
  126. *   
  127. * DESCRIPTION
  128. *
  129. *   The pattern routines take an x,y,z point on an object and a pointer to
  130. *   the object's texture description and return the color at that point
  131. *   Similar routines are granite, agate, marble. See txtcolor.c for examples.
  132. *
  133. * CHANGES
  134. *
  135. ******************************************************************************/
  136.  
  137. DBL pattern2 (VECTOR EPoint, TPATTERN *TPat)
  138. {
  139.   DBL value;
  140.   /* YOUR NAME HERE */
  141.   TPat=TPat;
  142.  
  143.   value = Noise(EPoint);
  144.  
  145.   return(value);
  146.  
  147. }
  148.  
  149.  
  150.  
  151.  
  152. /*****************************************************************************
  153. *
  154. * FUNCTION
  155. *
  156. *   pattern3
  157. *
  158. * INPUT
  159. *   
  160. * OUTPUT
  161. *   
  162. * RETURNS
  163. *   
  164. * AUTHOR
  165. *
  166. *   POV-Ray Team
  167. *   
  168. * DESCRIPTION
  169. *
  170. *   The pattern routines take an x,y,z point on an object and a pointer to
  171. *   the object's texture description and return the color at that point
  172. *   Similar routines are granite, agate, marble. See txtcolor.c for examples.
  173. *
  174. * CHANGES
  175. *
  176. ******************************************************************************/
  177.  
  178. DBL pattern3 (VECTOR EPoint, TPATTERN *TPat)
  179. {
  180.   DBL value;
  181.   /* YOUR NAME HERE */
  182.   TPat=TPat;
  183.  
  184.   value = Noise(EPoint);
  185.  
  186.   return(value);
  187.  
  188. }
  189.  
  190.  
  191.  
  192. /*****************************************************************************
  193. *
  194. * FUNCTION
  195. *
  196. *   bumpy1
  197. *
  198. * INPUT
  199. *   
  200. * OUTPUT
  201. *   
  202. * RETURNS
  203. *   
  204. * AUTHOR
  205. *
  206. *   POV-Ray Team
  207. *   
  208. * DESCRIPTION
  209. *
  210. *   The bumpy routines take a point on an object,  a pointer to the
  211. *   object's texture description and the surface normal at that point and
  212. *   return a peturb surface normal to create the illusion that the surface
  213. *   has been displaced.
  214. *
  215. *   Similar routines are ripples, dents, bumps. See txtbump.c for examples.
  216. *
  217. * CHANGES
  218. *
  219. ******************************************************************************/
  220.  
  221. void bumpy1 (VECTOR EPoint, TNORMAL *Tnormal, VECTOR normal)
  222. {
  223.   /* YOUR NAME HERE */
  224.   EPoint=EPoint;
  225.  
  226.   Tnormal = Tnormal;
  227.  
  228.   Assign_Vector(normal, normal);
  229. }
  230.  
  231.  
  232.  
  233. /*****************************************************************************
  234. *
  235. * FUNCTION
  236. *
  237. *   bumpy2
  238. *
  239. * INPUT
  240. *   
  241. * OUTPUT
  242. *   
  243. * RETURNS
  244. *   
  245. * AUTHOR
  246. *
  247. *   POV-Ray Team
  248. *   
  249. * DESCRIPTION
  250. *
  251. *   The bumpy routines take a point on an object,  a pointer to the
  252. *   object's texture description and the surface normal at that point and
  253. *   return a peturb surface normal to create the illusion that the surface
  254. *   has been displaced.
  255. *
  256. *   Similar routines are ripples, dents, bumps. See txtbump.c for examples.
  257. *
  258. * CHANGES
  259. *
  260. ******************************************************************************/
  261.  
  262. void bumpy2 (VECTOR EPoint, TNORMAL *Tnormal, VECTOR normal)
  263. {
  264.   /* YOUR NAME HERE */
  265.   EPoint=EPoint;
  266.  
  267.   Tnormal = Tnormal;
  268.  
  269.   Assign_Vector(normal, normal);
  270. }
  271.  
  272.  
  273.  
  274. /*****************************************************************************
  275. *
  276. * FUNCTION
  277. *
  278. *   bumpy3
  279. *
  280. * INPUT
  281. *   
  282. * OUTPUT
  283. *   
  284. * RETURNS
  285. *   
  286. * AUTHOR
  287. *
  288. *   POV-Ray Team
  289. *   
  290. * DESCRIPTION
  291. *
  292. *   The bumpy routines take a point on an object,  a pointer to the
  293. *   object's texture description and the surface normal at that point and
  294. *   return a peturb surface normal to create the illusion that the surface
  295. *   has been displaced.
  296. *
  297. *   Similar routines are ripples, dents, bumps. See txtbump.c for examples.
  298. *
  299. * CHANGES
  300. *
  301. ******************************************************************************/
  302.  
  303. void bumpy3 (VECTOR EPoint, TNORMAL *Tnormal, VECTOR normal)
  304. {
  305.   /* YOUR NAME HERE */
  306.   EPoint=EPoint;
  307.  
  308.   Tnormal = Tnormal;
  309.  
  310.   Assign_Vector(normal, normal);
  311. }
  312.