home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / libray / libtext / windy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-09  |  1.8 KB  |  76 lines

  1. /*
  2.  * windy.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * windy.c,v 4.1 1994/08/09 08:03:30 explorer Exp
  17.  *
  18.  * windy.c,v
  19.  * Revision 4.1  1994/08/09  08:03:30  explorer
  20.  * Bump version to 4.1
  21.  *
  22.  * Revision 1.1.1.1  1994/08/08  04:52:16  explorer
  23.  * Initial import.  This is a prerelease of 4.0.6enh3, or 4.1 possibly.
  24.  *
  25.  * Revision 4.0  91/07/17  14:44:25  kolb
  26.  * Initial version.
  27.  * 
  28.  */
  29. #include "texture.h"
  30. #include "windy.h"
  31.  
  32. /*
  33.  * Create and return a reference to a "windy" texture.
  34.  */
  35. WindyText *
  36. WindyCreate(scale, wscale, cscale, bscale, octaves, tscale, hscale, offset)
  37. Float scale, wscale, cscale, bscale, tscale, hscale, offset;
  38. int octaves;
  39. {
  40.     WindyText *windy;
  41.  
  42.     windy = (WindyText *)Malloc(sizeof(WindyText));
  43.     windy->scale = scale;
  44.     windy->windscale = wscale;
  45.     windy->chaoscale = cscale;
  46.     windy->bumpscale = bscale;
  47.     windy->tscale = tscale;
  48.     windy->hscale = hscale;
  49.     windy->offset = offset;
  50.     windy->octaves = octaves;
  51.     return windy;
  52. }
  53.  
  54. /*
  55.  * Apply a "windy" texture.
  56.  */
  57. void
  58. WindyApply(windy, prim, ray, pos, norm, gnorm, surf)
  59. WindyText *windy;
  60. Geom *prim;
  61. Ray *ray;
  62. Vector *pos, *norm, *gnorm;
  63. Surface *surf;
  64. {
  65.     Vector bump;
  66.  
  67.     Windy(pos, windy->windscale, windy->chaoscale, windy->bumpscale,
  68.           windy->octaves, windy->tscale, windy->hscale, windy->offset,
  69.           &bump);
  70.  
  71.     norm->x += windy->scale * bump.x;
  72.     norm->y += windy->scale * bump.y;
  73.     norm->z += windy->scale * bump.z;
  74.     VecNormalize(norm);
  75. }
  76.