GAMESEG.H 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/main/rcs/gameseg.h $
  15. * $Revision: 2.0 $
  16. * $Author: john $
  17. * $Date: 1995/02/27 11:31:20 $
  18. *
  19. * Header file for stuff moved from segment.c to gameseg.c.
  20. *
  21. * $Log: gameseg.h $
  22. * Revision 2.0 1995/02/27 11:31:20 john
  23. * New version 2.0, which has no anonymous unions, builds with
  24. * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  25. *
  26. * Revision 1.24 1995/02/01 16:34:03 john
  27. * Linted.
  28. *
  29. * Revision 1.23 1995/01/16 21:06:36 mike
  30. * Move function pick_random_point_in_segment from fireball.c to gameseg.c.
  31. *
  32. * Revision 1.22 1994/11/23 12:18:59 mike
  33. * prototype for level names.
  34. *
  35. * Revision 1.21 1994/11/17 14:56:59 mike
  36. * moved segment validation functions from editor to main.
  37. *
  38. * Revision 1.20 1994/11/16 23:38:46 mike
  39. * new improved boss teleportation behavior.
  40. *
  41. * Revision 1.19 1994/10/30 14:12:14 mike
  42. * rip out local segments stuff.
  43. *
  44. * Revision 1.18 1994/10/09 23:51:07 matt
  45. * Made find_hitpoint_uv() work with triangulated sides
  46. *
  47. * Revision 1.17 1994/10/06 14:08:22 matt
  48. * Added new function, extract_orient_from_segment()
  49. *
  50. * Revision 1.16 1994/09/19 21:05:52 mike
  51. * Prototype for find_connected_distance.
  52. *
  53. * Revision 1.15 1994/08/11 18:58:45 mike
  54. * Change shorts to ints.
  55. *
  56. * Revision 1.14 1994/08/04 00:21:09 matt
  57. * Cleaned up fvi & physics error handling; put in code to make sure objects
  58. * are in correct segment; simplified segment finding for objects and points
  59. *
  60. * Revision 1.13 1994/08/02 19:04:25 matt
  61. * Cleaned up vertex list functions
  62. *
  63. * Revision 1.12 1994/07/21 19:01:53 mike
  64. * lsegment stuff.
  65. *
  66. * Revision 1.11 1994/07/07 09:31:13 matt
  67. * Added comments
  68. *
  69. * Revision 1.10 1994/06/14 12:21:20 matt
  70. * Added new function, find_point_seg()
  71. *
  72. * Revision 1.9 1994/05/29 23:17:38 matt
  73. * Move find_object_seg() from physics.c to gameseg.c
  74. * Killed unused find_point_seg()
  75. *
  76. * Revision 1.8 1994/05/20 11:56:57 matt
  77. * Cleaned up find_vector_intersection() interface
  78. * Killed check_point_in_seg(), check_player_seg(), check_object_seg()
  79. *
  80. * Revision 1.7 1994/03/17 18:07:38 yuan
  81. * Removed switch code... Now we just have Walls, Triggers, and Links...
  82. *
  83. * Revision 1.6 1994/02/22 18:14:44 yuan
  84. * Added new wall system
  85. *
  86. * Revision 1.5 1994/02/17 11:33:22 matt
  87. * Changes in object system
  88. *
  89. * Revision 1.4 1994/02/16 13:48:33 mike
  90. * enable editor to compile out.
  91. *
  92. * Revision 1.3 1994/02/14 12:05:07 mike
  93. * change segment data structure.
  94. *
  95. * Revision 1.2 1994/02/10 16:07:20 mike
  96. * separate editor from game based on EDITOR flag.
  97. *
  98. * Revision 1.1 1994/02/09 15:45:38 mike
  99. * Initial revision
  100. *
  101. *
  102. */
  103. #ifndef _GAMESEG_H
  104. #define _GAMESEG_H
  105. #include "types.h"
  106. #include "fix.h"
  107. #include "vecmat.h"
  108. #include "segment.h"
  109. //figure out what seg the given point is in, tracing through segments
  110. int get_new_seg(vms_vector *p0,int startseg);
  111. typedef struct segmasks {
  112. short facemask; //which faces sphere pokes through (12 bits)
  113. byte sidemask; //which sides sphere pokes through (6 bits)
  114. byte centermask; //which sides center point is on back of (6 bits)
  115. } segmasks;
  116. extern int Highest_vertex_index; // Highest index in Vertices and Vertex_active, an efficiency hack
  117. extern int Highest_segment_index; // Highest index in Segments, an efficiency hack
  118. extern void compute_center_point_on_side(vms_vector *vp,segment *sp,int side);
  119. extern void compute_segment_center(vms_vector *vp,segment *sp);
  120. extern int find_connect_side(segment *base_seg, segment *con_seg);
  121. // Fill in array with four absolute point numbers for a given side
  122. get_side_verts(short *vertlist,int segnum,int sidenum);
  123. // Create all vertex lists (1 or 2) for faces on a side.
  124. // Sets:
  125. // num_faces number of lists
  126. // vertices vertices in all (1 or 2) faces
  127. // If there is one face, it has 4 vertices.
  128. // If there are two faces, they both have three vertices, so face #0 is stored in vertices 0,1,2,
  129. // face #1 is stored in vertices 3,4,5.
  130. // Note: these are not absolute vertex numbers, but are relative to the segment
  131. // Note: for triagulated sides, the middle vertex of each trianle is the one NOT
  132. // adjacent on the diagonal edge
  133. extern void create_all_vertex_lists(int *num_faces, int *vertices, int segnum, int sidenum);
  134. //like create_all_vertex_lists(), but generate absolute point numbers
  135. extern void create_abs_vertex_lists(int *num_faces, int *vertices, int segnum, int sidenum);
  136. // -----------------------------------------------------------------------------------
  137. // Like create all vertex lists, but returns the vertnums (relative to
  138. // the side) for each of the faces that make up the side.
  139. // If there is one face, it has 4 vertices.
  140. // If there are two faces, they both have three vertices, so face #0 is stored in vertices 0,1,2,
  141. // face #1 is stored in vertices 3,4,5.
  142. void create_all_vertnum_lists(int *num_faces, int *vertnums, int segnum, int sidenum);
  143. // Given a side, return the number of faces
  144. extern int get_num_faces(side *sidep);
  145. //returns 3 different bitmasks with info telling if this sphere is in
  146. //this segment. See segmasks structure for info on fields
  147. segmasks get_seg_masks(vms_vector *checkp,int segnum,fix rad);
  148. //this macro returns true if the segnum for an object is correct
  149. #define check_obj_seg(obj) (get_seg_masks(&(obj)->pos,(obj)->segnum,0).centermask == 0)
  150. //Tries to find a segment for a point, in the following way:
  151. // 1. Check the given segment
  152. // 2. Recursively trace through attached segments
  153. // 3. Check all the segmentns
  154. //Returns segnum if found, or -1
  155. int find_point_seg(vms_vector *p,int segnum);
  156. //--repair-- // Create data specific to segments which does not need to get written to disk.
  157. //--repair-- extern void create_local_segment_data(void);
  158. // Sort of makes sure create_local_segment_data has been called for the currently executing mine.
  159. // Returns 1 if Lsegments appears valid, 0 if not.
  160. int check_lsegments_validity(void);
  161. // ----------------------------------------------------------------------------------------------------------
  162. // Determine whether seg0 and seg1 are reachable using wid_flag to go through walls.
  163. // For example, set to WID_RENDPAST_FLAG to see if sound can get from one segment to the other.
  164. // set to WID_FLY_FLAG to see if a robot could fly from one to the other.
  165. // Search up to a maximum depth of max_depth.
  166. // Return the distance.
  167. extern fix find_connected_distance(vms_vector *p0, int seg0, vms_vector *p1, int seg1, int max_depth, int wid_flag);
  168. //create a matrix that describes the orientation of the given segment
  169. extern void extract_orient_from_segment(vms_matrix *m,segment *seg);
  170. // In segment.c
  171. // Make a just-modified segment valid.
  172. // check all sides to see how many faces they each should have (0,1,2)
  173. // create new vector normals
  174. extern void validate_segment(segment *sp);
  175. extern void validate_segment_all(void);
  176. // Extract the forward vector from segment *sp, return in *vp.
  177. // The forward vector is defined to be the vector from the the center of the front face of the segment
  178. // to the center of the back face of the segment.
  179. extern void extract_forward_vector_from_segment(segment *sp,vms_vector *vp);
  180. // Extract the right vector from segment *sp, return in *vp.
  181. // The forward vector is defined to be the vector from the the center of the left face of the segment
  182. // to the center of the right face of the segment.
  183. extern void extract_right_vector_from_segment(segment *sp,vms_vector *vp);
  184. // Extract the up vector from segment *sp, return in *vp.
  185. // The forward vector is defined to be the vector from the the center of the bottom face of the segment
  186. // to the center of the top face of the segment.
  187. extern void extract_up_vector_from_segment(segment *sp,vms_vector *vp);
  188. extern void create_walls_on_side(segment *sp, int sidenum);
  189. extern void pick_random_point_in_seg(vms_vector *new_pos, int segnum);
  190. #endif
  191.