home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / libray / libobj / fractalobject.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-09  |  4.7 KB  |  172 lines

  1. /*
  2.  * fractalobject.h
  3.  *
  4.  * Peter Janssen - janssen@cs.kuleuven.ac.be
  5.  *
  6.  */
  7.  
  8. #ifndef FRACTALOBJECT_H
  9. #define FRACTALOBJECT_H
  10.  
  11. #define GeomFractalObjCreate(m, n, d, s, e) \
  12.            GeomCreate((GeomRef)FractalObjCreate(m, n, d, s, e), FractalObjMethods())
  13.  
  14. #define MAXVALUE              2147483647
  15. #define PointsToAllocate      70
  16. #define TrianglesToAllocate   150
  17. #define EntitiesToAllocate    6
  18.  
  19. #define max3(a, b, c) (((a) > (b)) && ((a) > (c)) ? (a) :  \
  20.                       (((b) > (c)) ? (b) : (c)))
  21. #define min3(a, b, c) (((a) < (b)) && ((a) < (c)) ? (a) :  \
  22.                       (((b) < (c)) ? (b) : (c)))
  23.  
  24.  
  25. #define CheckPoints(p, n, a)                               \
  26.            if (n == a) {                                   \
  27.                a += PointsToAllocate;                      \
  28.                p = (FractalPoint *)realloc((char *)p, a * sizeof(FractalPoint));   \
  29.            }
  30.  
  31. #define CheckTriangles(t, n, a)                              \
  32.            if (n == a) {                                     \
  33.                a += TrianglesToAllocate;                     \
  34.                t = (FractalTriangle *)realloc((char *)t, a  * sizeof(FractalTriangle)); \
  35.            }
  36.  
  37. #define CheckEntities(e, n, a)                               \
  38.            if (n == a) {                                     \
  39.                a += EntitiesToAllocate;                      \
  40.                e = (FractalEntity *)realloc((char *)e, a * sizeof(FractalEntity));    \
  41.            }
  42.  
  43. /*
  44.  * Convert from voxel number along X/Y/Z to corresponding coordinate.
  45.  */
  46. #define Fvoxel2x(g,x)            ((x) * g->VoxelSize[0] + g->Bounds[0][0])
  47. #define Fvoxel2y(g,y)            ((y) * g->VoxelSize[1] + g->Bounds[0][1])
  48. #define Fvoxel2z(g,z)            ((z) * g->VoxelSize[2] + g->Bounds[0][2])
  49. /*
  50.  * And vice-versa.
  51.  */
  52. #define Fx2voxel(g,x)            (equal(g->VoxelSize[0], 0.) ? 0 :             \
  53.                                    (((x) - g->Bounds[0][0]) / g->VoxelSize[0]))
  54. #define Fy2voxel(g,y)            (equal(g->VoxelSize[1], 0.) ? 0 :             \
  55.                                    (((y) - g->Bounds[0][1]) / g->VoxelSize[1]))
  56. #define Fz2voxel(g,z)            (equal(g->VoxelSize[2], 0.) ? 0 :             \
  57.                                    (((z) - g->Bounds[0][2]) / g->VoxelSize[2]))
  58.  
  59. typedef struct DeltaInfo {
  60.     Float   x, y, z, distance;
  61. } DeltaInfo;
  62.  
  63. typedef struct FractalPoint {
  64.     Float  x, y, z;
  65. } FractalPoint;
  66.  
  67. typedef struct PointPool {
  68.     int            NumberOfPoints;
  69.     int            PointsAllocated;
  70.     FractalPoint  *Points;
  71. } PointPool;
  72.  
  73. typedef struct FractalTriangle {
  74.    int    Point[3];
  75. } FractalTriangle;
  76.  
  77. typedef struct TrianglePool {
  78.    int               NumberOfTriangles;
  79.    int               TrianglesAllocated;
  80.    int               PoolChanged;
  81.    FractalTriangle  *Triangles;
  82. } TrianglePool;
  83.  
  84. typedef struct TriangleList {
  85.    int                   TriangleNumber;
  86.    struct TriangleList  *Next;
  87. } TriangleList;
  88.  
  89. typedef struct FractalEntity {
  90.    int            XSize, YSize, ZSize;
  91.    TriangleList  *Triangles;
  92. } FractalEntity;
  93.  
  94. typedef struct EntityPool {
  95.     int             XSize, YSize, ZSize;
  96.     int             NumberOfEntities;
  97.     int             EntitiesAllocated;
  98.     FractalEntity  *Entities;
  99. } EntityPool;
  100.  
  101. typedef struct LastPoint {
  102.     int                  Point;
  103.     int                  NewPoint;
  104.     struct LastPoint    *Next;
  105. } LastPoint;
  106.  
  107. typedef struct FirstPoint {
  108.     int                  Point;
  109.     LastPoint           *Info;
  110.     struct FirstPoint   *Next;
  111. } FirstPoint;
  112.  
  113.  
  114.  
  115. typedef struct FractalClosure {
  116.     PointPool      *Pointpool;
  117.     TrianglePool   *Trianglepool;
  118.     EntityPool     *Entitypool;
  119. } FractalClosure;
  120.  
  121. typedef struct TriangleInfo {
  122.     int                       Point[3];
  123.     unsigned long             Counter;
  124. } TriangleInfo;
  125.  
  126. typedef struct TriangleClosure {
  127.     TriangleInfo             *Triangle;
  128.     struct TriangleClosure   *Next;
  129. } TriangleClosure;
  130.  
  131.  
  132. typedef struct SubObject {
  133.     Float                 Bounds[2][3];
  134.     short                 XSize, YSize, ZSize;
  135.     Float                 VoxelSize[3];
  136.     TriangleClosure   ****Cells;
  137.     TrianglePool         *Trianglepool;
  138.     struct SubObject     *Next;
  139. } SubObject;
  140.  
  141.  
  142.  
  143. typedef struct FractalObj {
  144.    Float            MaximumSize;
  145.    Float            Dimension;
  146.    Float            Excentricity;
  147.    Float            Bounds[2][3];
  148.    SubObject       *SubObjects;
  149.    FractalClosure  *Closure;
  150.  
  151.    Vector           IntersectPos;
  152.    Vector           Normal;
  153.  
  154. } FractalObj;
  155.  
  156.  
  157.  
  158. extern FractalObj *FractalObjCreate();
  159. extern int         FractalObjIntersect(), FractalObjNormal();
  160. extern void        FractalObjStats();
  161. extern char       *FractalObjName();
  162. extern Methods    *FractalObjMethods();
  163.  
  164. extern FractalClosure *Fractalclosure;
  165.  
  166. #endif /* FRACTALOBJECT_H */
  167.  
  168.  
  169.  
  170.  
  171.  
  172.