home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Graphics / graphics-16000.iso / msdos / raytrace / rayshade / src / grid.h < prev    next >
C/C++ Source or Header  |  1991-07-18  |  2KB  |  60 lines

  1. /*
  2.  * grid.h
  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.  * $Id: grid.h,v 4.0 91/07/17 14:38:07 kolb Exp Locker: kolb $
  17.  *
  18.  * $Log:    grid.h,v $
  19.  * Revision 4.0  91/07/17  14:38:07  kolb
  20.  * Initial version.
  21.  * 
  22.  */
  23. #ifndef GRID_H
  24. #define GRID_H
  25.  
  26. #define GeomGridCreate(x,y,z)    GeomCreate((GeomRef)GridCreate(x,y,z), \
  27.                     GridMethods())
  28. /*
  29.  * Convert from voxel number along X/Y/Z to corresponding coordinate.
  30.  */
  31. #define voxel2x(g,x)        ((x) * g->voxsize[0] + g->bounds[0][0])
  32. #define voxel2y(g,y)        ((y) * g->voxsize[1] + g->bounds[0][1])
  33. #define voxel2z(g,z)        ((z) * g->voxsize[2] + g->bounds[0][2])
  34. /*
  35.  * And vice-versa.
  36.  */
  37. #define x2voxel(g,x)        (((x) - g->bounds[0][0]) / g->voxsize[0])
  38. #define y2voxel(g,y)        (((y) - g->bounds[0][1]) / g->voxsize[1])
  39. #define z2voxel(g,z)        (((z) - g->bounds[0][2]) / g->voxsize[2])
  40.  
  41. /*
  42.  * Grid object
  43.  */
  44. typedef struct {
  45.     short    xsize, ysize, zsize;    /* # of voxels along each axis */
  46.     Float    bounds[2][3];        /* bounding box */
  47.     Float    voxsize[3];        /* size of a voxel */
  48.     struct    Geom    *unbounded,    /* unbounded objects */
  49.             *objects;    /* all bounded objects */
  50.     struct    GeomList    ****cells;    /* Voxels */
  51. } Grid;
  52.  
  53. extern char    *GridName();
  54. extern void    *GirdBounds();
  55. extern int    GridIntersect(), GridConvert();
  56. extern Grid    *GridCreate();
  57. extern Methods    *GridMethods();
  58.  
  59. #endif /* GRID_H */
  60.