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

  1. /*
  2.  * infinite.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.  * infinite.c,v 4.1 1994/08/09 07:56:55 explorer Exp
  17.  *
  18.  * infinite.c,v
  19.  * Revision 4.1  1994/08/09  07:56:55  explorer
  20.  * Bump version to 4.1
  21.  *
  22.  * Revision 1.1.1.1  1994/08/08  04:52:03  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:34:28  kolb
  26.  * Initial version.
  27.  * 
  28.  */
  29. #include "light.h"
  30. #include "infinite.h"
  31.  
  32. static LightMethods *iInfMethods = NULL;
  33.  
  34. Infinite *
  35. InfiniteCreate(dir)
  36. Vector *dir;
  37. {
  38.     Infinite *inf;
  39.  
  40.     inf = (Infinite *)share_malloc(sizeof(Infinite));
  41.     inf->dir = *dir;
  42.     if (VecNormalize(&inf->dir) == 0.) {
  43.         RLerror(RL_ABORT, "Invalid directional light.\n");
  44.         return (Infinite *)NULL;
  45.     }
  46.     return inf;
  47. }
  48.  
  49. LightMethods *
  50. InfiniteMethods()
  51. {
  52.     if (iInfMethods == (LightMethods *)NULL) {
  53.         iInfMethods = LightMethodsCreate();
  54.         iInfMethods->intens = InfiniteIntens;
  55.         iInfMethods->dir = InfiniteDirection;
  56.     }
  57.     return iInfMethods;
  58. }
  59.  
  60. int
  61. InfiniteIntens(inf, lcolor, cache, ray, dist, noshadow, color)
  62. Infinite *inf;
  63. Color *lcolor, *color;
  64. ShadowCache *cache;
  65. Ray *ray;
  66. Float dist;
  67. int noshadow;
  68. {
  69.     return !Shadowed(color, lcolor, cache, ray, dist, noshadow);
  70. }
  71.  
  72. void
  73. InfiniteDirection(lp, pos, dir, dist)
  74. Infinite *lp;
  75. Vector *pos, *dir;
  76. Float *dist;
  77. {
  78.     *dir = lp->dir;
  79.     *dist = FAR_AWAY;
  80. }
  81.  
  82. InfiniteMethodRegister(meth)
  83. UserMethodType meth;
  84. {
  85.     if (iInfMethods)
  86.         iInfMethods->user = meth;
  87. }
  88.