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