home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Raytrace & Morphing / SOS-RAYTRACE.ISO / programm / source / rayce27s / objects.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-02  |  4.3 KB  |  170 lines

  1. /*
  2.  * objects.h --type definitions for primitives and nonprimitives.
  3.  */
  4.  
  5. /* quadric equation coefficients */
  6. struct quadric_data {
  7.     double          xx,
  8.                     yy,
  9.                     zz,
  10.                     xy,
  11.                     yz,
  12.                     xz,
  13.                     x0,
  14.                     y0,
  15.                     z0,
  16.                     a;
  17.     bool            isclosed;    /* closed surface, with finite inside? */
  18. };
  19.  
  20. /* the sphere structure */
  21. struct sphere_data {
  22.     vector          center;
  23.     double
  24.                     radius,
  25.                     rsq;    /* radius squared */
  26. };
  27.  
  28. /* finite cone */
  29. /* not used, really... Some day maybe... */
  30. struct cone_data {
  31.     vector          p1,
  32.                     p2;
  33.     double          r1,
  34.                     r2;
  35. };
  36.  
  37. struct extrusion_data {
  38.     object         *shape;    /* the shape to be extruded */
  39.     double          height;    /* height of the extrusion */
  40.     bool            locap,
  41.                     hicap;    /* are bottom/top to be capped ? */
  42. };
  43.  
  44. /* convex polygon */
  45. struct polygon_data {
  46.     int             no_vertices;/* number of vertices */
  47.     vector         *vertices;    /* vertices themselves */
  48.     vector         *clips;    /* inward facing normals */
  49.     vector          normal;    /* normal of the polygon */
  50.     double          mov;    /* mov (see plane_data) */
  51.     bool            convex;
  52.     char            project_to;
  53. };
  54.  
  55. struct triangle_data {
  56.     vector          n;        /* normal of plane defined by vertices */
  57.     double          mov;    /* translate of plane */
  58.     char            project_to;
  59.     vector          vertices[3];/* vertices of the triangle */
  60.     vector         *normals;    /* normals; if allocated, then they exist. */
  61.     vector          linfunc1,
  62.                     linfunc2;    /* linear functionals, which compute the
  63.                  * components of a vector in the basis
  64.                  * formed by vert[0]-vert[2], vert[1] -
  65.                  * vert[2] */
  66. };
  67.  
  68. /* plane info */
  69. struct plane_data {
  70.     vector          n;        /* the normal */
  71.     double          mov;    /* translation parallel to normal */
  72. };
  73.  
  74. struct disc_data {
  75.     vector          n;        /* the normal */
  76.     double          mov;    /* translation parallel to normal */
  77.     vector          center;
  78.     double          R,
  79.                     r;
  80. };
  81.  
  82. /* a PoV box */
  83. struct box_data {
  84.     vector          p1,
  85.                     p2;        /* point with minimum/maximum coordinates */
  86. };
  87.  
  88. /* light source info */
  89. struct light_data {
  90.     vector          org,    /* the place at which the light is. */
  91.                     direction;
  92.  
  93.     color           lcolor;    /* color of the light */
  94.  
  95.     bool            spotlight;
  96.  
  97.     double          attenuation_exp,    /* exponent E for intensity =
  98.                      * 1/ldist^E */
  99.                     tightness,    /* for spotlights */
  100.                     radius;    /* radius, used for falloff and penumbra */
  101.  
  102.     object         *scache[MAXCACHE];    /* the shadowcache */
  103. };
  104.  
  105. struct torus_data {        /* for a torus. */
  106.     double
  107.                     Rad,
  108.                     rad;    /* major/minor radius */
  109.     bool
  110.                     use_sturm;    /* sturm seqs? */
  111. };
  112.  
  113. struct superq_data {
  114.     vector          powvect;
  115. };
  116.  
  117. struct algebraic_data {
  118.     struct poly_instruction *code;    /* code needed to generate the
  119.                      * one-var polynomial */
  120.     int             codesize;
  121.     bool            usesturm,    /* calculate using sturm seqs? */
  122.                     isclosed;    /* closed + finite? */
  123. };
  124.  
  125.  
  126. /* types of optimisation */
  127. enum {
  128.     NONE,
  129.     BSP,
  130.     SEADS,
  131.     ABVH,
  132.     OCTTREE,
  133. };
  134.  
  135. struct composite_data {
  136.     object         *contents;    /* linked list of the elements */
  137.     /*
  138.      * union { } optidata
  139.      */
  140.     bool            (*all_intersections_method) (dqueue * q, object *op, struct ray * r, int flags, bool *b);
  141.     int             optitype;
  142. };
  143.  
  144.  
  145. /* for the shape->type variable */
  146. enum {
  147.     NOSHAPE, SPHERE, QUADRIC, PLANE, LIGHTSOURCE, BOX,
  148.     TORUS, CSGUNION, CSGINTER, COMPOSITE, ALGEBRAIC, SUPERQ,
  149.     POLYGON, EXTRUSION, TRIANGLE, DISC
  150. };
  151.  
  152. /* entry for stack of polynomial operations */
  153. struct poly_instruction {
  154.     int             type;    /* what kind of instruction */
  155.     union {
  156.     double          factor;    /* numeric factor */
  157.     char            op;    /* operator */
  158.     }
  159.     data;
  160. };
  161.  
  162. /* polynomial operations */
  163. enum {
  164.     POLY_CONS,            /* push constant */
  165.     POLY_OP,            /* do operation on stack */
  166.     POLY_X,            /* push X */
  167.     POLY_Y,            /* push Y */
  168.     POLY_Z,            /* push Z */
  169. };
  170.