Engine.h
上传用户:lhwx1029
上传日期:2013-03-07
资源大小:1173k
文件大小:33k
源码类别:

3D图形编程

开发平台:

Visual C++

  1. #if ((!defined(_CI_)) && (!defined(_RGB_)))
  2.  #error Either _CI_ or _RGB_ must be declared.
  3. #endif
  4. #if ((!defined(_Z_BUFFER_)) && (!defined(_PAINTER_)))
  5.  #error Either _Z_BUFFER_ or _PAINTER_ must be declared.
  6. #endif
  7. #if !defined(_ENGINE_H_)
  8. #define _ENGINE_H_
  9. /** 3DGPL *************************************************
  10.  * ()                                                     *
  11.  * Header for the polygonal 3D engine.                    *
  12.  *                                                        *
  13.  * Ifdefs:                                                *
  14.  *  _CI_                     Colour/Intensity model;      *
  15.  *  _RGB_                    RGB model;                   *
  16.  *  _Z_BUFFER_               Depth array;                 *
  17.  *  _PAINTER_                Back-front order.            *
  18.  *                                                        *
  19.  * Files:                                                 *
  20.  *  eng-base.c               Polymorphic polygon;         *
  21.  *  eng-poly.c               Polygonal object;            *
  22.  *  eng-bcub.c               Bicubic patch;               *
  23.  *  eng-grup.c               Group of objects;            *
  24.  *  eng-volm.c               Indoor volume object;        *
  25.  *  eng-surf.c               Landscape object.            *
  26.  *                                                        *
  27.  * (c) 1995-98 Sergei Savchenko, (savs@cs.mcgill.ca)      *
  28. **********************************************************/
  29. #include "Graphics.h"           /* G_MAX_POLYGON_VERTICES */
  30. #include "Trans.h"                 /* T_LNG_VECTOR */
  31. #include "Colour.h"               /* CL_LNG_COLOUR */
  32. extern unsigned char M_camera_gam;          /* needed for surfaces */
  33. extern int M_camera_x,M_camera_y,M_camera_z;
  34. extern int M_camera_log_focus;              /* camera parameters */
  35. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  36.  * The following semi-internal structures are            *
  37.  * used by the structures representing various 3D        *
  38.  * objects:                                              *
  39.  *                                                       *
  40.  *  M_texture                Texture and its size;       *
  41.  *  M_polygon                A polygon;                  *
  42.  *  M_light                  Ambient, point or direct;   *
  43.  *  M_bicubic                A patch;                    *
  44.  *  M_polygon_object_order   A BSP tree;                 *
  45.  *  M_gate                   Gate between volumes;       *
  46.  *  M_surface_cell           Element of the surface.     *
  47.  *                                                       *
  48.  * This external structures modeling various 3D objects: *
  49.  *                                                       *
  50.  *  M_polygon_object         Polygonal solid;            *
  51.  *  M_bicubic_object         Bicubic solid;              *
  52.  *  M_group                  Set of above models;        *
  53.  *  M_volume_object          Interconnected volumes;     *
  54.  *  M_surface_object         A landscape.                *
  55.  *                                                       *
  56. * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  57. #if defined(_CI_)                           /* colour/intensity model */
  58.  #define M_IDX_TEXTURE     4                /* where Tx is */
  59.  #define M_LNG_FLAT        3                /* X Y Z */
  60.  #define M_LNG_SHADED      4                /* X Y Z I */
  61.  #define M_LNG_TEXTURED    6                /* X Y Z I Tx Ty */
  62. #endif
  63. #if defined(_RGB_)                          /* RGB model */
  64.  #define M_IDX_TEXTURE     6                /* where Tx is */
  65.  #define M_LNG_FLAT        3                /* X Y Z */
  66.  #define M_LNG_SHADED      6                /* X Y Z R G B */
  67.  #define M_LNG_TEXTURED    8                /* X Y Z R G B Tx Ty */
  68. #endif
  69. #define M_P              G_P                /* fixed point precision */
  70. #define M_PB               8                /* for bicubic rasterization */
  71. #define M_WIRE          0x01                /* a wire frame */
  72. #define M_FLAT          0x02                /* constant colour polygon */
  73. #define M_SHADED        0x04                /* Gouraud shaded polygon */
  74. #define M_TEXTURED      0x08                /* texture mapped polygon */
  75. extern int M_force_linear_tmapping;         /* when the polygons are small */
  76. void M_init_rendering(int type);            /* highest drawable polygon type */
  77. void M_set_camera(unsigned char alp,unsigned char bet,unsigned char gam,
  78.                   int x,int y,int z,int log_focus
  79.                  );                         /* parameters of the camera */
  80. #ifdef _PAINTER_
  81. void M_sort_elements(int *vertices,int dimension,int *indices,int number);
  82. #endif
  83. /**********************************************************
  84.  * A light source, either a point light source or a       *
  85.  * directional light source. In the former cases the      *
  86.  * parameter describes the position in the latter case    *
  87.  * the orientation vector.                                *
  88.  *                                                        *
  89.  *  +------------------------+                            *
  90.  *  | m_type                 | M_AMBIENT|M_POINT|M_DIRECT *
  91.  *  |                  +---+---+---+                      *
  92.  *  | m_parameter      | X | Y | Z |                      *
  93.  *  |                  +---+---+---+                      *
  94.  *  | [m_intensity] or       |                            *
  95.  *  | [m_red m_green m_blue] |                            *
  96.  *  +------------------------+                            *
  97.  *                                                        *
  98. **********************************************************/
  99. #define M_AMBIENT 0x1                       /* ambient light source */
  100. #define M_POINT   0x2                       /* point light source */
  101. #define M_DIRECT  0x4                       /* directional light source */
  102. struct M_light                              /* describes a light source */
  103. {
  104.  int m_type;                                /* M_AMBIENT,M_POINT or M_DIRECT */
  105.  int m_parameter[T_LNG_VECTOR];             /* location of the light */
  106. #if defined(_CI_)
  107.  int m_intensity;                           /* ambient intensity */
  108. #endif
  109. #if defined(_RGB_)
  110.  int m_red;                                 /* intensity as RGB */
  111.  int m_green;
  112.  int m_blue;
  113. #endif
  114. };
  115. void M_shade_vertex(int *intensity,
  116.                     int *vertex,int *normal,
  117.                     int no_lights,struct M_light **lights
  118.                    );
  119. /**********************************************************
  120.  * Texture, basically only square textures with the size  *
  121.  * which is a power of two are allowed.                   *
  122.  *                                                        *
  123.  *  +--------------------+        +-------------+         *
  124.  *  | m_texture_bytes------------>|texture bytes|         *
  125.  *  | m_log_texure_size  |        |     ...     |         *
  126.  *  +--------------------+        +-------------+         *
  127.  *                                                        *
  128. **********************************************************/
  129. struct M_texture
  130. {
  131.  HW_pixel *m_texture_bytes;                 /* points raw data */
  132.  int m_log_texture_size;                    /* log base 2 of texture size */
  133. };
  134. /**********************************************************
  135.  * Polygon, either actual plane patch or part of some     *
  136.  * curved surface approximation. Has a colour or a        *
  137.  * texture. The illumination intensities for the hole     *
  138.  * patch or per vertex are set by object shading          *
  139.  * function. Vertices point to an array each element of   *
  140.  * which contains info relative to a vertex. NB whatever  *
  141.  * the type of the polygon is ALL parameters must be      *
  142.  * present. Texture coordinates are related to            *
  143.  * log_texture_...                                        *
  144.  *                                                        *
  145.  *  +--------------------------+                          *
  146.  *  | m_type                   |   M_PLANNAR | M_CURVED   *
  147.  *  |                          |                          *
  148.  *  | m_colour                 |                          *
  149.  *  |                          |                          *
  150.  *  | [ m_intensity ] or       |                          *
  151.  *  | [ m_red m_green m_blue ] |                          *
  152.  *  |                          |                          *
  153.  *  | m_log_texture_space_size | +-------------------+    *
  154.  *  | m_texture----------------->|M_texture structure|    *
  155.  *  |                          | +-------------------+    *
  156.  *  |                          |                          *
  157.  *  | m_no_edges               | +-----+----------+--+--+ *
  158.  *  | m_vertices---------------->|Index|[I]or[RGB]|Tx|Ty| *
  159.  *  |                          | |- - - - - - - - - - - | *
  160.  *  |                          | |           ...        | *
  161.  *  |                          | +----------------------+ *
  162.  *  |                          |                          *
  163.  *  |                          | +-----+                  *
  164.  *  | m_normals----------------->|Index|                  *
  165.  *  +--------------------------+ |- - -|                  *
  166.  *                               | ... |                  *
  167.  *                               +-----+                  *
  168. **********************************************************/
  169. #define M_PLANNAR              0x01         /* polygon models a plane */
  170. #define M_CURVED               0x02         /* polygon models a surface */
  171. #define M_QUAD_XY              0x04         /* easy to find texture vectors */
  172. #define M_QUAD_MINUS_XY        0x08         /* same but order reversed */
  173. #define M_QUAD                 0x0c         /* any of two above */
  174. #define M_NOT_QUAD             0xf3         /* to get rid of M_QUAD in splits */
  175. #define M_MAX_POLYGON_VERTICES G_MAX_POLYGON_VERTICES
  176. #if defined(_CI_)
  177.  #define M_IDX_POLYGON_TEXTURE 2            /* where texture is in the list */
  178.  #define M_LNG_POLYGON_VERTEX  4            /* Idx I Tx Ty */
  179. #endif
  180. #if defined(_RGB_)
  181.  #define M_IDX_POLYGON_TEXTURE 4            /* where texture is in the list */
  182.  #define M_LNG_POLYGON_VERTEX  6            /* Idx R G B Tx Ty */
  183. #endif
  184. struct M_polygon                            /* describes one polygon */
  185. {
  186.  int m_type;                                /* M_PLANNAR | M_CURVED */
  187.  HW_pixel m_colour;                         /* only for M_AMBIENT */
  188. #if defined(_CI_)
  189.  int m_intensity;                           /* ambient intensity */
  190. #endif
  191. #if defined(_RGB_)
  192.  int m_red;                                 /* intensity as RGB */
  193.  int m_green;
  194.  int m_blue;
  195. #endif
  196.  int m_log_texture_space_size;              /* mapping scale */
  197.  struct M_texture *m_texture;               /* raw data with sizes */
  198.  int m_no_edges;                            /* number of edges in the polygn */
  199.  int *m_vertices;                           /* array of indices */
  200.  int *m_normals;                            /* normals for the vertices */
  201. };
  202. void M_shade_polygon(struct M_polygon *polygon,int *vertices,
  203.                      int *normals,int no_lights,
  204.                      struct M_light **lights
  205.                     );
  206. void M_render_polygon(struct M_polygon *polygon,int *vertices,
  207.                       int *colours,int *textures
  208.                      );
  209. /**********************************************************
  210.  * Represents a single bicubic Bezier patch. It is shaded *
  211.  * using descretely precalculated normals (appears to be  *
  212.  * not that expensive compared to other methods). And     *
  213.  * rasterized through turning the controls finding the    *
  214.  * mesh and rasterizing the small polygons one at a time. *
  215.  *                                                        *
  216.  *  +--------------------------+                          *
  217.  *  | m_log_render_size        |                          *
  218.  *  |                          |                          *
  219.  *  | m_colour                 |                          *
  220.  *  | m_log_texture_space_size | +-------------------+    *
  221.  *  | m_texture----------------->|M_texture structure|    *
  222.  *  |                          | +-------------------+    *
  223.  *  |                          |                          *
  224.  *  |                   +---+---+---+                     *
  225.  *  | m_controls        | X | Y | Z |                     *
  226.  *  |                   |- - - - - -|                     *
  227.  *  |                   | ...16...  |                     *
  228.  *  |                   +-----------+                     *
  229.  *  |                          |                          *
  230.  *  |                          | +---+---+---+            *
  231.  *  | m_normals----------------->| X | Y | Z |            *
  232.  *  |                          | |- - - - - -|            *
  233.  *  |                          | |    ...    |            *
  234.  *  |                          | +-----------+            *
  235.  *  |                          |                          *
  236.  *  |                          | +------------+           *
  237.  *  | m_intensities------------->| I or R G B |           *
  238.  *  +--------------------------+ |- - - - - - |           *
  239.  *                               |     ...    |           *
  240.  *                               +------------+           *
  241.  *                                                        *
  242. **********************************************************/
  243. #define M_MAX_RENDER_SIZE 33                /* 2**5+1 */
  244. struct M_bicubic                            /* describes one polygon */
  245. {
  246.  int m_log_render_size;                     /* rasterized into polygons */
  247.  HW_pixel m_colour;                         /* for M_SHADED and M_FLAT */
  248.  int m_log_texture_space_size;              /* mapping scale */
  249.  struct M_texture *m_texture;               /* raw data with sizes */
  250.  int m_controls[16*T_LNG_VECTOR];           /* array of indices */
  251.  int *m_normals;                            /* normals for shading */
  252.  int *m_intensities;                        /* shading intensities */
  253. };
  254. void M_init_bicubic(struct M_bicubic *bicubic);
  255. void M_shade_bicubic(struct M_bicubic *bicubic,
  256.                      int x,int y,int z,
  257.                      int alp,int bet,int gam,
  258.                      int no_lights,
  259.                      struct M_light **lights
  260.                     );
  261. void M_render_bicubic(struct M_bicubic *bicubic,
  262.                       int x,int y,int z,
  263.                       int alp,int bet,int gam
  264.                      );
  265. /**********************************************************
  266.  * Polygon order object, a BSP tree.                      *
  267.  *                                                        *
  268.  *  +-----------------+    +-----------+                  *
  269.  *  | m_root-------------->| M_polygon |                  *
  270.  *  |                 |    +-----------+                  *
  271.  *  |                 |    +------------------------+     *
  272.  *  | m_positive---------->| M_polygon_object_order |     *
  273.  *  |                 |    +------------------------+     *
  274.  *  |                 |    +------------------------+     *
  275.  *  | m_negative---------->| M_polygon_object_order |     *
  276.  *  +-----------------+    +------------------------+     *
  277.  *                                                        *
  278. **********************************************************/
  279. struct M_polygon_object_order
  280. {
  281.  struct M_polygon *m_root;                  /* root polygon */
  282.  struct M_polygon_object_order *m_positive; /* one sub tree */
  283.  struct M_polygon_object_order *m_negative; /* another one */
  284. };
  285. /**********************************************************
  286.  * Gate between volume objects, like a polygon specified  *
  287.  * by a chain of vertices and pointing to the gate which  *
  288.  * it leads to.                                           *
  289.  *                                                        *
  290.  *  +-------------------+      +-----------------+        *
  291.  *  | m_volume---------------->| M_volume_object |        *
  292.  *  |                   |      +-----------------+        *
  293.  *  |                   |                                 *
  294.  *  | m_no_edges        |      +-------+                  *
  295.  *  | m_vertices-------------->| Index |                  *
  296.  *  |                   |      |       |                  *
  297.  *  +-------------------+      |- - - -|                  *
  298.  *                             |  ...  |                  *
  299.  *                             +-------+                  *
  300.  *                                                        *
  301. **********************************************************/
  302. struct M_gate
  303. {
  304.  struct M_volume_object *m_volume;          /* gate into this volume */
  305.  int m_no_edges;
  306.  int *m_vertices;                           /* shape of the gate */
  307. };
  308. int M_set_gate(struct M_gate *gate,int *vertices);
  309. /**********************************************************
  310.  * Surface cell, specifies a single cell of a landscape   *
  311.  * object. Can model either plannar area or curved. In    *
  312.  * the latter case modeled by two triangles instead of    *
  313.  * a single rectangle.                                    *
  314.  *                                                        *
  315.  *  +--------------------------------+                    *
  316.  *  | m_type                         | M_PLANNAR|M_CURVED *
  317.  *  |                                |                    *
  318.  *  | m_colour_1                     |                    *
  319.  *  | [ m_intensity_1 ] or           |                    *
  320.  *  | [ m_red_1 m_green_1 m_blue_1 ] |                    *
  321.  *  |                                |                    *
  322.  *  | m_colour_2                     |                    *
  323.  *  | [ m_intensity_2 ] or           |                    *
  324.  *  | [ m_red_2 m_green_2 m_blue_2 ] |                    *
  325.  *  |                                |    +-----------+   *
  326.  *  | m_texture-------------------------->| M_texture |   *
  327.  *  |                                |    | structure |   *
  328.  *  |                                |    +-----------+   *
  329.  *  +--------------------------------+                    *
  330.  *                                                        *
  331. **********************************************************/
  332. struct M_surface_cell
  333. {
  334.  int m_type;                                /* M_PLANNAR | M_CURVED */
  335.  HW_pixel m_colour_1;                       /* base colour */
  336.  HW_pixel m_colour_2;                       /* same for polyg #2 if M_CURVED */
  337. #if defined(_CI_)
  338.  int m_intensity_1;                         /* flat intensity */
  339.  int m_intensity_2;
  340. #endif
  341. #if defined(_RGB_)
  342.  int m_red_1,m_green_1,m_blue_1;            /* same for RGB model */
  343.  int m_red_2,m_green_2,m_blue_2;
  344. #endif
  345.  struct M_texture *m_texture;               /* if any */
  346. };
  347. /**********************************************************
  348.  * Polygonal object, a set of polygons on the common      *
  349.  * vertex set. Also carries the set of normals, which     *
  350.  * are, like the vertices, referenced by their respective *
  351.  * polygons. When a BSP tree pointer is non NULL, it is   *
  352.  * being used in hidden surface removal.                  *
  353.  *                                                        *
  354.  *  +-----------------+                                   *
  355.  *  | m_type          |   M_POLYGON_OBJECT                *
  356.  *  |                 |   +------------------------+      *
  357.  *  | m_order- - - - - - >| M_polygon_object_order |      *
  358.  *  |                 |   +------------------------+      *
  359.  *  |                 |                                   *
  360.  *  | m_no_polygons   |   +---+---+  - -+                 *
  361.  *  | m_polygons--------->| o | o | ... |                 *
  362.  *  |                 |   +-|-+-|-+ -  -+                 *
  363.  *  |                 |     V   V                         *
  364.  *  |              +---------+ +---------+                *
  365.  *  |              |M_polygon| |M_polygon|                *
  366.  *  |              +---------+ +---------+                *
  367.  *  |                 |                                   *
  368.  *  | m_no_vertices   |   +---+---+---+                   *
  369.  *  | m_vertices--------->| X | Y | Z |                   *
  370.  *  |                 |   |- - - - - -|                   *
  371.  *  |                 |   |    ...    |                   *
  372.  *  |                 |   +-----------+                   *
  373.  *  |                 |                                   *
  374.  *  | m_no_normals    |   +---+---+---+                   *
  375.  *  | m_normals---------->| X | Y | Z |                   *
  376.  *  +-----------------+   |- - - - - -|                   *
  377.  *                        |    ...    |                   *
  378.  *                        +-----------+                   *
  379.  *                                                        *
  380. **********************************************************/
  381. #define M_POLYGON_OBJECT 0x1                /* to id it in a group */
  382. #define M_MAX_OBJECT_VERTICES 1024          /* size of tmp structures */
  383. #define M_MAX_OBJECT_POLYGONS  256
  384. struct M_polygon_object
  385. {
  386.  int m_type;                                /* always M_POLYGON_OBJECT */
  387.  struct M_polygon_object_order *m_order;    /* BSP tree, if any */
  388.  int m_no_polygons;
  389.  struct M_polygon **m_polygons;             /* array of polygons */
  390.  int m_no_vertices;
  391.  int *m_vertices;                           /* array of coordinates */
  392.  int m_no_normals;
  393.  int *m_normals;                            /* array of coordinates */
  394. };
  395. void M_init_polygon_object(struct M_polygon_object *object);
  396. void M_shade_polygon_object(struct M_polygon_object *object,
  397.                             int x,int y,int z,
  398.                             int alp,int bet,int gam,
  399.                             int no_lights,
  400.                             struct M_light **lights
  401.                            );               /* object moves and rotates */
  402. void M_render_polygon_object(struct M_polygon_object *object,
  403.                              int x,int y,int z,
  404.                              int alp,int bet,int gam
  405.                             );
  406. /**********************************************************
  407.  * Represents a collection of bicubic patches, hidden     *
  408.  * surface elemination with _PAINTER_ option achieved     *
  409.  * by back to front ordering of the patches (may very     *
  410.  * well be wrong for many cases).                         *
  411.  *                                                        *
  412.  *  +--------------------------+                          *
  413.  *  | m_type                   | M_BICUBIC_OBJECT         *
  414.  *  |                          |                          *
  415.  *  | m_no_patches             | +---+---+  - -+          *
  416.  *  | m_patches----------------->| o | o | ... |          *
  417.  *  |                          | +-|-+-|-+ -  -+          *
  418.  *  |                          |   V   V                  *
  419.  *  |                     +---------+ +---------+         *
  420.  *  |                     | M_patch | | M_patch |         *
  421.  *  |                     +---------+ +---------+         *
  422.  *  |                          |                          *
  423.  *  |                          | +---+---+---+            *
  424.  *  | m_centres ---------------->| X | Y | Z |            *
  425.  *  |                          | +- - - - - -+            *
  426.  *  +--------------------------+ |    ...    |            *
  427.  *                               +-----------+            *
  428.  *                                                        *
  429.  *                                                        *
  430. **********************************************************/
  431. #define M_BICUBIC_OBJECT 0x2                /* to id it in a group */
  432. #define M_MAX_PATCHES    128                /* upper for tmp structures */
  433. struct M_generic_object
  434. {
  435.  int m_type;                                /* polygon or bicubic */
  436. };
  437. struct M_bicubic_object                     /* describes one polygon */
  438. {
  439.  int m_type;                                /* always M_POLYGON_OBJECT */
  440.  int m_no_patches;
  441.  struct M_bicubic **m_patches;              /* pointers to patches */
  442.  int *m_centres;                            /* centres of the patches */
  443. };
  444. void M_init_bicubic_object(struct M_bicubic_object *bicubic);
  445. void M_shade_bicubic_object(struct M_bicubic_object *object,
  446.                             int x,int y,int z,
  447.                             int alp,int bet,int gam,
  448.                             int no_lights,
  449.                             struct M_light **lights
  450.                            );
  451. void M_render_bicubic_object(struct M_bicubic_object *object,
  452.                              int x,int y,int z,
  453.                              int alp,int bet,int gam
  454.                             );
  455. /**********************************************************
  456.  * Group of objects, set of objects, each specified by    *
  457.  * position and orientation. Also contains a set of light *
  458.  * sources.                                               *
  459.  *                                                        *
  460.  *  +-------------------+                                 *
  461.  *  | m_no_objects      |                                 *
  462.  *  |                   |   +---+---+- -- --+             *
  463.  *  | m_objects ----------->| o | o |  ...  |             *
  464.  *  |                   |   +-|-+-|-+ - -- -+             *
  465.  *  |                   |     V   V                       *
  466.  *  |        +------------------+ +------------------+    *
  467.  *  |        | M_generic_object | | M_generic_object |    *
  468.  *  |        +------------------+ +------------------+    *
  469.  *  |                   |                                 *
  470.  *  |                   |   +---+---+---+                 *
  471.  *  | m_centres ----------->| X | Y | Z |                 *
  472.  *  |                   |   +- - - - - -+                 *
  473.  *  |                   |   |    ...    |                 *
  474.  *  |                   |   +-----------+                 *
  475.  *  |                   |                                 *
  476.  *  |                   |   +---+---+---+                 *
  477.  *  | m_orientations ------>|alp|bet|gam|                 *
  478.  *  |                   |   +- - - - - -+                 *
  479.  *  |                   |   |    ...    |                 *
  480.  *  |                   |   +-----------+                 *
  481.  *  |                   |                                 *
  482.  *  | m_no_lights       |   +---+---+- -- --+             *
  483.  *  | m_lights ------------>| o | o |  ...  |             *
  484.  *  |                   |   +-|-+-|-+ - -- -+             *
  485.  *  +-------------------+     V   V                       *
  486.  *                   +---------+ +---------+              *
  487.  *                   | M_light | | M_light |              *
  488.  *                   +---------+ +---------+              *
  489.  *                                                        *
  490. **********************************************************/
  491. #define M_MAX_GROUP_OBJECTS 32              /* defines size for tmp structs */
  492. struct M_group
  493. {
  494.  int m_no_objects;
  495.  struct M_generic_object **m_objects;       /* polygon or bicubic objects */
  496.  int *m_centres;                            /* centres of the objects */
  497.  int *m_orientations;                       /* their orientations */
  498.  int m_no_lights;
  499.  struct M_light **m_lights;                 /* light sources */
  500. };
  501. void M_init_group(struct M_group *group);   /* each object in the group */
  502. void M_shade_group(struct M_group *group);  /* group doesn't move */
  503. void M_render_group(struct M_group *object,
  504.                     int x,int y,int z
  505.                    );                       /* render at x y z */
  506. /**********************************************************
  507.  * Indoor volume object, similar in many respects to      *
  508.  * polygonal object, except that it contains a set of     *
  509.  * gates to the volumes which it is connected to.         *
  510.  *                                                        *
  511.  *  +--------------------+                                *
  512.  *  | m_no_polygons      |    +---+---+  - -+             *
  513.  *  | m_polygons------------->| o | o | ... |             *
  514.  *  |                    |    +-|-+-|-+ -  -+             *
  515.  *  |                    |      V   V                     *
  516.  *  |                  +---------+ +---------+            *
  517.  *  |                  |M_polygon| |M_polygon|            *
  518.  *  |                  +---------+ +---------+            *
  519.  *  |                    |                                *
  520.  *  | m_no_gates         |    +---+---+ -  -+             *
  521.  *  | m_gates---------------->| o | o | ... |             *
  522.  *  |                    |    +-|-+-|-+  - -+             *
  523.  *  |                    |      V   V                     *
  524.  *  |                    | +------+ +------+              *
  525.  *  |                    | |M_gate| |M_gate|              *
  526.  *  |                    | +------+ +------+              *
  527.  *  |                    |                                *
  528.  *  | m_no_vertices      |    +---+---+---+               *
  529.  *  | m_vertices------------->| X | Y | Z |               *
  530.  *  |                    |    |- - - - - -|               *
  531.  *  |                    |    |    ...    |               *
  532.  *  |                    |    +-----------+               *
  533.  *  |                    |                                *
  534.  *  | m_no_normals       |    +---+---+---+               *
  535.  *  | m_normals-------------->| X | Y | Z |               *
  536.  *  +--------------------+    |- - - - - -|               *
  537.  *                            |    ...    |               *
  538.  *                            +-----------+               *
  539.  *                                                        *
  540. **********************************************************/
  541. #define M_MAX_VOLUME_VERTICES 256           /* size of tmp structures */
  542. #define M_MAX_VOLUMES          64           /* can be rendered at once */
  543. struct M_volume_object
  544. {
  545.  int m_no_polygons;
  546.  struct M_polygon **m_polygons;             /* points an array */
  547.  int m_no_gates;
  548.  struct M_gate **m_gates;                   /* gateways to other volumes */
  549.  int m_no_vertices;
  550.  int *m_vertices;                           /* points 3 element array */
  551.  int m_no_normals;
  552.  int *m_normals;                            /* points 3 element array */
  553. };
  554. void M_init_volume_object(struct M_volume_object *object);
  555. void M_shade_volume_object(struct M_volume_object *object,
  556.                            int no_lights,
  557.                            struct M_light **lights
  558.                           );                /* volume doesn't move */
  559. void M_render_volume_object(struct M_volume_object *object,int depth);
  560. /**********************************************************
  561.  * Surface object, a height field with corresponding      *
  562.  * sets of vertices and normals.                          *
  563.  *                                                        *
  564.  *  +--------------------+ +------+---------+---------+   *
  565.  *  | m_orders------------>|m_cell|m_vertex1|m_vertex2|   *
  566.  *  |                    | +- - - - - - - - - - - - - +   *
  567.  *  | m_total_size       | |            ...           |   *
  568.  *  | m_display_size     | +--------------------------+   *
  569.  *  | m_cell_length      |                                *
  570.  *  |                    | +---+----------------+         *
  571.  *  | m_vertices---------->| Y | [I] or [R G B] |         *
  572.  *  |                    | |- - - - - - - - - - |         *
  573.  *  |                    | |         ...        |         *
  574.  *  |                    | +--------------------+         *
  575.  *  |                    |                                *
  576.  *  |                    | +----------------+             *
  577.  *  | m_cells------------->|M_surface_cell  |             *
  578.  *  |                    | |structures      |             *
  579.  *  |                    | |- - - - - - - - |             *
  580.  *  |                    | |       ...      |             *
  581.  *  |                    | +----------------+             *
  582.  *  |                    |                                *
  583.  *  |                    | +---+---+---+                  *
  584.  *  | m_normals----------->| X | Y | Z |                  *
  585.  *  +--------------------+ |- - - - - -|                  *
  586.  *                         |    ...    |                  *
  587.  *                         +-----------+                  *
  588.  *                                                        *
  589. **********************************************************/
  590. #define M_TEXTURE_LENGTH       127          /* size of texture in the cell */
  591. #define M_LOG_TEXTURE_LENGTH     7          /* log of the number above */
  592. #define M_MAX_SURFACE_VERTICES  20          /* maximum display size */
  593. #if defined(_CI_)
  594.  #define M_LNG_SURFACE_VERTEX    2          /* Y Intensity */
  595. #endif
  596. #if defined(_RGB_)
  597.  #define M_LNG_SURFACE_VERTEX    4          /* Y R G B */
  598. #endif
  599. struct M_surface_object
  600. {
  601.  int *m_orders;                             /* array of order indices */
  602.  int m_total_size;                          /* dimension of the struct */
  603.  int m_display_size;                        /* how many of those displayed */
  604.  int m_cell_length;                         /* size for one cell */
  605.  int *m_vertices;                           /* square array of vertices */
  606.  struct M_surface_cell *m_cells;            /* square array of cells */
  607.  int *m_normals;
  608. };
  609. void M_init_surface_object(struct M_surface_object *object);
  610. void M_shade_surface_object(struct M_surface_object *object,
  611.                             int no_lights,
  612.                             struct M_light **lights
  613.                            );               /* surface doesn't move */
  614. void M_render_surface_object(struct M_surface_object *object,
  615.                              int xcell,int zcell
  616.                             );              /* render at [xc,zc] cell */
  617. /**********************************************************/
  618. #endif