EDITOR.H 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. /*
  2. * $Source: f:/miner/source/main/editor/rcs/editor.h $
  3. * $Revision: 2.0 $
  4. * $Author: john $
  5. * $Date: 1995/02/27 11:34:47 $
  6. *
  7. * Header for editor functions, data strcutures, etc.
  8. *
  9. * $Log: editor.h $
  10. * Revision 2.0 1995/02/27 11:34:47 john
  11. * Version 2.0! No anonymous unions, Watcom 10.0, with no need
  12. * for bitmaps.tbl.
  13. *
  14. * Revision 1.113 1994/11/17 14:47:55 mike
  15. * validation functions moved from editor to game.
  16. *
  17. * Revision 1.112 1994/08/03 10:30:51 mike
  18. * Prototype Stretch_scale_x and Stretch_scale_y.
  19. *
  20. * Revision 1.111 1994/08/02 14:18:23 mike
  21. * Clean up dialog boxes.
  22. *
  23. * Revision 1.110 1994/07/28 16:59:45 mike
  24. * objects containing objects.
  25. *
  26. * Revision 1.109 1994/07/21 12:45:18 mike
  27. * Add Editor_time_of_day, prototype render_3d_in_big_window, move_object_to_mouse_click.
  28. *
  29. * Revision 1.108 1994/07/20 16:43:33 mike
  30. * Move a bunch of things here so eobject can access variables in med
  31. *
  32. * Revision 1.107 1994/07/06 16:36:43 mike
  33. * Prototype draw_world_from_game.
  34. *
  35. * Revision 1.106 1994/06/24 17:04:26 john
  36. * *** empty log message ***
  37. *
  38. * Revision 1.105 1994/06/08 18:13:53 mike
  39. * Add prototype for med_validate_segment_all
  40. *
  41. * Revision 1.104 1994/05/23 14:47:59 mike
  42. * Make current segment be add segment.
  43. *
  44. * Revision 1.103 1994/05/19 23:34:46 mike
  45. * Change VMAG to be compatible with new uv coordinates in range 0..1.0.
  46. *
  47. * Revision 1.102 1994/05/19 12:10:12 matt
  48. * Use new vecmat macros and globals
  49. *
  50. * Revision 1.101 1994/05/14 18:00:34 matt
  51. * Got rid of externs in source (non-header) files
  52. *
  53. * Revision 1.100 1994/05/14 17:18:12 matt
  54. * Got rid of externs in source (non-header) files
  55. *
  56. * Revision 1.99 1994/05/09 23:33:20 mike
  57. * Current_group, make med_combine_duplicate_vertices take vlp parameter.
  58. * Change med_find_closest_threshold_segment_side take threshold as a parameter.
  59. *
  60. * Revision 1.98 1994/05/06 14:39:46 mike
  61. * Prototype place_object.
  62. *
  63. * Revision 1.97 1994/05/04 19:16:12 mike
  64. * Add prototype for Degenerate_segment_found.
  65. *
  66. * Revision 1.96 1994/05/04 13:07:34 matt
  67. * Moved a bunch of color constants to meddraw.c, which was the only file
  68. * that used them.
  69. *
  70. * Revision 1.95 1994/05/03 11:06:08 mike
  71. * Change VMAG, add constants for SEGSIZEMODE_FREE, etc.
  72. *
  73. * Revision 1.94 1994/05/02 17:56:29 yuan
  74. * Changed undo_status into array rather than malloced pointers.
  75. *
  76. * Revision 1.93 1994/04/19 18:29:37 matt
  77. * In wire-frame editor window, draw objects as "spheres"
  78. *
  79. * Revision 1.92 1994/04/13 13:25:12 mike
  80. * Add constant definitions for each keypad.
  81. *
  82. * Revision 1.91 1994/04/01 11:17:08 yuan
  83. * Added objects to objpage. Added buttons for easier tmap scrolling.
  84. * Objects are selected fully from objpage and add object menu or pad.
  85. *
  86. * Revision 1.90 1994/03/21 16:54:16 yuan
  87. * Fixed bogus group generated by segment rotation.
  88. *
  89. * Revision 1.89 1994/02/16 13:49:07 mike
  90. * enable editor to compile out.
  91. *
  92. * Revision 1.88 1994/02/10 16:04:57 mike
  93. * separate editor based on EDITOR flag.
  94. *
  95. * Revision 1.87 1994/02/08 12:41:29 yuan
  96. * Added med_load_game function prototype
  97. *
  98. * Revision 1.86 1994/01/14 12:16:04 yuan
  99. * Fixed function prototype for med_find_closest_threshold_segment_side.
  100. *
  101. * Revision 1.85 1994/01/14 11:58:55 yuan
  102. * New function in build menu.
  103. * "Punch" through walls to force a joint formation with
  104. * closest segment:side, if the closest segment:side allows
  105. * a connection.
  106. *
  107. * Revision 1.84 1994/01/06 12:57:47 mike
  108. * Fix bug in assigning texture maps and uv coordinates to removable wall.
  109. *
  110. * Revision 1.83 1994/01/05 17:51:04 mike
  111. * Add prototypes for create_removable_wall and remove_removable_wall
  112. *
  113. * Revision 1.82 1994/01/05 09:59:09 yuan
  114. * Added med_load_pmine function prototype
  115. *
  116. * Revision 1.81 1993/12/16 14:00:46 mike
  117. * Add Curvert and Curedge.
  118. *
  119. * Revision 1.80 1993/12/14 18:33:07 yuan
  120. * Added prototype for timed autosave.
  121. *
  122. * Revision 1.79 1993/12/10 14:48:48 mike
  123. * Kill orthogonal views.
  124. *
  125. * Revision 1.78 1993/12/09 16:27:16 yuan
  126. * Added toggle for autosave
  127. *
  128. * Revision 1.77 1993/12/09 14:02:52 mike
  129. * Add prototype for med_combine_duplicate_vertices.
  130. *
  131. * Revision 1.76 1993/12/08 10:59:52 mike
  132. * Add DisplayCurrentRobotType and Cur_object_index.
  133. *
  134. * Revision 1.75 1993/12/06 18:43:49 matt
  135. * Changed object loading & handling
  136. *
  137. * Revision 1.74 1993/12/05 22:50:49 matt
  138. * Reworked include files in an attempt to cut down on build times
  139. *
  140. * Revision 1.73 1993/12/02 17:51:31 john
  141. * Changed my variable to match Mike's
  142. *
  143. * Revision 1.72 1993/12/02 17:36:26 john
  144. * added cur_obj_type
  145. *
  146. * Revision 1.71 1993/11/30 17:06:33 mike
  147. * Add prototype for med_set_vertex.
  148. *
  149. * Revision 1.70 1993/11/29 19:47:11 matt
  150. * Changed how coordinate axes draw routine gets vertices
  151. * Added functions alloc_vert() & free_vert()
  152. *
  153. */
  154. #ifndef _EDITOR_H
  155. #define _EDITOR_H
  156. #include "vecmat.h"
  157. #include "segment.h"
  158. #include "inferno.h"
  159. #include "gr.h"
  160. #include "ui.h"
  161. /*
  162. * Constants
  163. *
  164. */
  165. #define ORTHO_VIEWS 0 // set to 1 to enable 3 orthogonal views
  166. #define ED_SCREEN_W 800 //width of editor screen
  167. #define ED_SCREEN_H 600 //height of editor screen
  168. #define MENUBAR_H 16
  169. #define GAMEVIEW_X 1 //where the 320x200 game window goes
  170. #define GAMEVIEW_Y 1+MENUBAR_H
  171. #define GAMEVIEW_W 320
  172. #define GAMEVIEW_H 200
  173. #define STATUS_X 0
  174. #define STATUS_H 18
  175. #define STATUS_Y (ED_SCREEN_H-STATUS_H)
  176. #define STATUS_W ED_SCREEN_W
  177. #define LVIEW_X 1 //large view
  178. #define LVIEW_Y (GAMEVIEW_Y+GAMEVIEW_H+2)
  179. #define LVIEW_W 447
  180. #define LVIEW_H (STATUS_Y-LVIEW_Y-2)
  181. #define TMAPBOX_X (LVIEW_X+LVIEW_W+4) //location of first one
  182. #define TMAPBOX_Y (LVIEW_Y+2)
  183. #define TMAPBOX_W 64
  184. #define TMAPBOX_H 64
  185. #define TMAPCURBOX_X (TMAPBOX_X + 4*(TMAPBOX_W + 3))
  186. #define TMAPCURBOX_Y (TMAPBOX_Y + TMAPBOX_H)
  187. #define OBJCURBOX_X (TMAPCURBOX_X)
  188. #define OBJCURBOX_Y (TMAPCURBOX_Y + 3*(TMAPBOX_H + 2) -40)
  189. #define PAD_X (GAMEVIEW_X + GAMEVIEW_W + 16)
  190. #define PAD_Y (GAMEVIEW_Y + 4)
  191. #define SMALLVIEW_W 173 //width of small view windows
  192. #define SMALLVIEW_H 148 //height of small view windows
  193. #define TVIEW_X (LVIEW_X+LVIEW_W+2) //top view
  194. #define TVIEW_Y LVIEW_Y
  195. #define TVIEW_W SMALLVIEW_W
  196. #define TVIEW_H SMALLVIEW_H
  197. #define FVIEW_X TVIEW_X //front view
  198. #define FVIEW_Y (TVIEW_Y+SMALLVIEW_H+2)
  199. #define FVIEW_W SMALLVIEW_W
  200. #define FVIEW_H SMALLVIEW_H
  201. #define RVIEW_X (TVIEW_X+SMALLVIEW_W+2) //right view
  202. #define RVIEW_Y FVIEW_Y
  203. #define RVIEW_W SMALLVIEW_W
  204. #define RVIEW_H SMALLVIEW_H
  205. #define GVIEW_X RVIEW_X //group view
  206. #define GVIEW_Y TVIEW_Y
  207. #define GVIEW_W SMALLVIEW_W
  208. #define GVIEW_H SMALLVIEW_H
  209. //there were color constants here, but I moved them to meddraw.c - Matt
  210. #define SEGMOVE_PAD_ID 0
  211. #define SEGSIZE_PAD_ID 1
  212. #define CURVE_PAD_ID 2
  213. #define TEXTURE_PAD_ID 3
  214. #define OBJECT_PAD_ID 4
  215. #define OBJMOV_PAD_ID 5
  216. #define GROUP_PAD_ID 6
  217. #define LIGHTING_PAD_ID 7
  218. #define TEST_PAD_ID 8
  219. #define MAX_PAD_ID 8
  220. /*
  221. * Strucures
  222. *
  223. */
  224. #define VF_ANGLES 0
  225. #define VF_MATRIX 1
  226. // Default size of a segment
  227. #define DEFAULT_X_SIZE F1_0*20
  228. #define DEFAULT_Y_SIZE F1_0*20
  229. #define DEFAULT_Z_SIZE F1_0*20
  230. // Scale factor from 3d units (integer portion) to uv coordinates (integer portion)
  231. #define VMAG (F1_0 / (DEFAULT_X_SIZE/F1_0))
  232. #define UMAG VMAG // unused
  233. // Number of segments which can be found (size of Found_segs[])
  234. #define MAX_FOUND_SEGS 200
  235. #define MAX_SELECTED_SEGS (MAX_SEGMENTS)
  236. #define MAX_WARNING_SEGS (MAX_SEGMENTS)
  237. #define MAX_GROUPS 10
  238. #define ROT_GROUP MAX_GROUPS
  239. // Modes for segment sizing
  240. #define SEGSIZEMODE_FREE 1
  241. #define SEGSIZEMODE_ALL 2
  242. #define SEGSIZEMODE_CURSIDE 3
  243. #define SEGSIZEMODE_EDGE 4
  244. #define SEGSIZEMODE_VERTEX 5
  245. #define SEGSIZEMODE_MIN SEGSIZEMODE_FREE
  246. #define SEGSIZEMODE_MAX SEGSIZEMODE_VERTEX
  247. //defines a view for an editor window
  248. typedef struct editor_view {
  249. short ev_num; //each view has it's own number
  250. short ev_changed; //set to true if view changed
  251. grs_canvas *ev_canv; //points to this window's canvas
  252. fix ev_dist; //the distance from the view point
  253. vms_matrix ev_matrix; //the view matrix
  254. fix ev_zoom; //zoom for this window
  255. } editor_view;
  256. /*
  257. * Global variables
  258. *
  259. */
  260. extern editor_view *Views[];
  261. extern int N_views;
  262. extern grs_canvas *canv_offscreen; //for off-screen rendering
  263. extern int Large_view_index;
  264. extern UI_GADGET_USERBOX * LargeViewBox;
  265. extern int Found_seg_index; // Index in Found_segs corresponding to Cursegp
  266. extern int gamestate_not_restored;
  267. extern segment *Cursegp; // Pointer to current segment in the mine, the one to which things happen.
  268. extern vms_vector Ed_view_target; // what editor is looking at
  269. extern segment New_segment; // The segment which can be added to the mine.
  270. extern int Curside; // Side index in 0..MAX_SIDES_PER_SEGMENT of active side.
  271. extern int Curedge; // Current edge on current side, in 0..3
  272. extern int Curvert; // Current vertex on current side, in 0..3
  273. extern int AttachSide; // Side on segment to attach
  274. extern int Draw_all_segments; // Set to 1 means draw_world draws all segments in Segments, else draw only connected segments
  275. extern segment *Markedsegp; // Marked segment, used in conjunction with *Cursegp to form joints.
  276. extern int Markedside; // Marked side on Markedsegp.
  277. extern byte Vertex_active[MAX_VERTICES]; // !0 means vertex is in use, 0 means not in use.
  278. extern grs_canvas *Pad_text_canvas; // Keypad text
  279. // The extra group in the following arrays is used for group rotation.
  280. extern group GroupList[MAX_GROUPS+1];
  281. extern segment *Groupsegp[MAX_GROUPS+1];
  282. extern int Groupside[MAX_GROUPS+1];
  283. extern int current_group;
  284. extern int num_groups;
  285. extern int Current_group;
  286. extern short Found_segs[]; // List of segment numbers "found" under cursor click
  287. extern int N_found_segs; // Number of segments found at Found_segs
  288. extern int N_selected_segs; // Number of segments found at Selected_segs
  289. extern short Selected_segs[]; // List of segment numbers currently selected
  290. extern int N_warning_segs; // Number of segments warning-worthy, such as a concave segment
  291. extern short Warning_segs[]; // List of warning-worthy segments
  292. extern int Show_axes_flag; // 0 = don't show, !0 = do show coordinate axes in *Cursegp orientation
  293. extern int Autosave_count; // Current counter for which autosave mine we are "on"
  294. extern int Autosave_flag; // Whether or not Autosave is on.
  295. extern struct tm Editor_time_of_day;
  296. extern int SegSizeMode; // Mode = 0/1 = not/is legal to move bound vertices,
  297. void init_editor(void);
  298. void editor(void);
  299. void close_editor(void);
  300. void init_editor_screen(void);
  301. // Returns true if vertex vi is contained in exactly one segment, else returns false.
  302. extern int is_free_vertex(int vi);
  303. // Set existing vertex vnum to value *vp.
  304. extern int med_set_vertex(int vnum,vms_vector *vp);
  305. extern void med_combine_duplicate_vertices(byte *vlp);
  306. // Attach side newside of newseg to side destside of destseg.
  307. // Copies *newseg into global array Segments, increments Num_segments.
  308. // Forms a weld between the two segments by making the new segment fit to the old segment.
  309. // Updates number of faces per side if necessitated by new vertex coordinates.
  310. // Return value:
  311. // 0 = successful attach
  312. // 1 = No room in Segments[].
  313. // 2 = No room in Vertices[].
  314. extern int med_attach_segment(segment *destseg, segment *newseg, int destside, int newside);
  315. // Delete a segment.
  316. // Deletes a segment from the global array Segments.
  317. // Updates Cursegp to be the segment to which the deleted segment was connected. If there is
  318. // more than one connected segment, the new Cursegp will be the segment with the highest index
  319. // of connection in the deleted segment (highest index = front)
  320. // Return value:
  321. // 0 = successful deletion
  322. // 1 = unable to delete
  323. extern int med_delete_segment(segment *sp);
  324. // Rotate the segment *seg by the pitch, bank, heading defined by *rot, destructively
  325. // modifying its four free vertices in the global array Vertices.
  326. // It is illegal to rotate a segment which has MAX_SIDES_PER_SEGMENT != 1.
  327. // Pitch, bank, heading are about the point which is the average of the four points
  328. // forming the side of connection.
  329. // Return value:
  330. // 0 = successful rotation
  331. // 1 = MAX_SIDES_PER_SEGMENT makes rotation illegal (connected to 0 or 2+ segments)
  332. // 2 = Rotation causes degeneracy, such as self-intersecting segment.
  333. extern int med_rotate_segment(segment *seg, vms_matrix *rotmat);
  334. extern int med_rotate_segment_ang(segment *seg, vms_angvec *ang);
  335. // Scales a segment, destructively modifying vertex coordinates in global Vertices[].
  336. // Uses scale factor in sp->scale.
  337. // Modifies only free vertices (those which are not part of a segment other than *sp).
  338. // The vector *svp contains the x,y,z scale factors. The x,y,z directions are relative
  339. // to the segment. x scales in the dimension of the right vector, y of the up vector, z of the forward vector.
  340. // The dimension of the vectors is determined by averaging appropriate sets of 4 of the 8 points.
  341. extern void med_scale_segment(segment *sp);
  342. // Create a wall which can be removed.
  343. // Creates wall at sp->sides[side], making it part of segment sp
  344. // Removable walls must be placed between two connected segments. You should add the removable
  345. // wall on both sides. In fact, you really must.
  346. extern void create_removable_wall(segment *sp, int side, int tmap_num);
  347. // Loads mine *name from disk, updating global variables:
  348. // Segments, Vertices
  349. // Num_segments,Num_vertices
  350. // Cursegp = pointer to active segment. Written as an index in med_save_mine, converted to a pointer
  351. // at load time.
  352. // Returns:
  353. // 0 = successfully loaded.
  354. // 1 = unable to load.
  355. extern int med_load_mine(char *name);
  356. // Loads game *name from disk.
  357. // This function automatically loads mine with name.MIN
  358. extern int med_load_game(char *name);
  359. // Loads a previous generation mine. Needs to be updated in code.
  360. extern int med_load_pmine(char *name);
  361. // Saves mine contained in Segments[] and Vertices[].
  362. // Num_segments = number of segments in mine.
  363. // Num_vertices = number of vertices in mine.
  364. // Cursegp = current segment.
  365. // Saves Num_segments, and index of current segment (which is Cursegp - Segments), which will be converted to a pointer
  366. // and written to Cursegp in med_load_mine.
  367. // Returns:
  368. // 0 = successfully saved.
  369. // 1 = unable to save.
  370. extern int med_save_mine(char *name);
  371. // Loads group *filename from disk.
  372. // Adds group to global Segments and Vertices array.
  373. // Returns:
  374. // 0 = successfully loaded.
  375. // 1 = unable to load.
  376. extern int med_load_group( char *filename, short *vertex_ids, short *segment_ids, int *num_vertices, int *num_segments);
  377. // Saves group *filename from disk.
  378. // Saves group defined by vertex_ids and segment_ids to disk.
  379. // Returns:
  380. // 0 = successfully saved.
  381. // 1 = unable to save.
  382. extern int med_save_group( char *filename, short *vertex_ids, short *segment_ids, int num_vertices, int num_segments);
  383. // Updates the screen... (I put the prototype here for curves.c)
  384. extern int medlisp_update_screen();
  385. // Returns 0 if no error, 1 if error, whatever that might be.
  386. // Sets globals:
  387. // Num_segments
  388. // Num_vertices
  389. // Cursegp = pointer to only segment.
  390. extern int create_new_mine(void);
  391. // extern void med_create_segment(segment *sp, vms_vector *scale);
  392. extern void old_med_attach_segment(segment *sp,int main_side,int branch_side,fix cx, fix cy, fix cz, fix length, fix width, fix height, vms_matrix *mp);
  393. // Copy a segment from *ssp to *dsp. Do not simply copy the struct. Use *dsp's vertices, copying in
  394. // just the values, not the indices.
  395. extern void med_copy_segment(segment *dsp,segment *ssp);
  396. // Create a default segment.
  397. // Useful for when user creates a garbage segment.
  398. extern void med_create_default_segment(segment *sp);
  399. // Create New_segment with sizes found in *scale.
  400. extern void med_create_new_segment(vms_vector *scale);
  401. // Create New_segment with sizes found in Cursegp.
  402. extern void med_create_new_segment_from_cursegp(void);
  403. // Update New_segment using scale factors.
  404. extern void med_update_new_segment(void);
  405. // Replace *sp with New_segment.
  406. extern void med_update_segment(segment *sp);
  407. // Create a new segment and use it to form a bridge between two existing segments.
  408. // Specify two segment:side pairs. If either segment:side is not open (ie, segment->children[side] != -1)
  409. // then it is not legal to form the brider.
  410. // Return:
  411. // 0 bridge segment formed
  412. // 1 unable to form bridge because one (or both) of the sides is not open.
  413. // Note that no new vertices are created by this process.
  414. extern int med_form_bridge_segment(segment *seg1, int side1, segment *seg2, int side2);
  415. // Compress mine at Segments and Vertices by squeezing out all holes.
  416. // If no holes (ie, an unused segment followed by a used segment), then no action.
  417. // If Cursegp or Markedsegp is a segment which gets moved to fill in a hole, then
  418. // they are properly updated.
  419. extern void med_compress_mine(void);
  420. // Extract the forward vector from segment *sp, return in *vp.
  421. // The forward vector is defined to be the vector from the the center of the front face of the segment
  422. // to the center of the back face of the segment.
  423. extern void med_extract_forward_vector_from_segment(segment *sp,vms_vector *vp);
  424. // Extract the right vector from segment *sp, return in *vp.
  425. // The forward vector is defined to be the vector from the the center of the left face of the segment
  426. // to the center of the right face of the segment.
  427. extern void med_extract_right_vector_from_segment(segment *sp,vms_vector *vp);
  428. // Extract the up vector from segment *sp, return in *vp.
  429. // The forward vector is defined to be the vector from the the center of the bottom face of the segment
  430. // to the center of the top face of the segment.
  431. extern void med_extract_up_vector_from_segment(segment *sp,vms_vector *vp);
  432. // Compute the center point of a side of a segment.
  433. // The center point is defined to be the average of the 4 points defining the side.
  434. extern void med_compute_center_point_on_side(vms_vector *vp,segment *sp,int side);
  435. extern void set_matrix_based_on_side(vms_matrix *rotmat,int destside);
  436. // Given a forward vector, compute and return an angvec triple.
  437. // [ THIS SHOULD BE MOVED TO THE VECTOR MATRIX LIBRARY ]
  438. extern vms_angvec *vm_vec_to_angles(vms_angvec *result, vms_vector *forvec);
  439. // Curves stuff.
  440. #define ACCURACY 0.1*F1_0
  441. typedef struct vms_equation {
  442. union {
  443. struct {fix x3, x2, x1, x0, y3, y2, y1, y0, z3, z2, z1, z0;};
  444. fix xyz[3][4];
  445. };
  446. } vms_equation;
  447. extern void create_curve(vms_vector *p1, vms_vector *p4, vms_vector *r1, vms_vector *r4, vms_equation *coeffs);
  448. // Q(t) = (2t^3 - 3t^2 + 1) p1 + (-2t^3 + 3t^2) p4 + (t^3 - 2t^2 + t) r1 + (t^3 - t^2 ) r4
  449. extern vms_vector evaluate_curve(vms_equation *coeffs, int degree, fix t);
  450. extern fix curve_dist(vms_equation *coeffs, int degree, fix t0, vms_vector *p0, fix dist);
  451. extern void curve_dir(vms_equation *coeffs, int degree, fix t0, vms_vector *dir);
  452. extern void plot_parametric(vms_equation *coeffs, fix min_t, fix max_t, fix del_t);
  453. // Curve generation routine.
  454. // Returns 1 if curve is generated.
  455. // Returns 0 if no curve.
  456. extern int generate_curve( fix r1scale, fix r4scale );
  457. // Deletes existing curve generated in generate_curve().
  458. extern void delete_curve();
  459. // --- // -- Temporary function, identical to med_rotate_segment, but it takes a vector instead of an angvec
  460. // --- extern int med_rotate_segment_vec(segment *seg, vms_vector *vec);
  461. extern void med_extract_matrix_from_segment(segment *sp,vms_matrix *rotmat);
  462. // Assign default u,v coordinates to all sides of a segment.
  463. // This routine should only be used for segments which are not connected to anything else,
  464. // ie the segment created at mine creation.
  465. extern void assign_default_uvs_to_segment(segment *segp);
  466. extern void assign_default_uvs_to_side(segment *segp, int side);
  467. extern void assign_default_uvs_to_side(segment *segp,int side);
  468. // Assign u,v coordinates to con_seg, con_common_side from base_seg, base_common_side
  469. // They are connected at the edge defined by the vertices abs_id1, abs_id2.
  470. extern void med_assign_uvs_to_side(segment *con_seg, int con_common_side, segment *base_seg, int base_common_side, int abs_id1, int abs_id2);
  471. // Debug -- show a matrix.
  472. // type: 0 --> mprintf, 1 --> printf
  473. // *s = string to display
  474. // *mp = matrix to display
  475. extern void show_matrix(char *s,vms_matrix *mp,int type);
  476. // Create coordinate axes in orientation of specified segment, stores vertices at *vp.
  477. extern void create_coordinate_axes_from_segment(segment *sp,short *vertnums);
  478. // Scale a segment. Then, if it is connected to something, rotate it.
  479. extern int med_scale_and_rotate_segment(segment *seg, vms_angvec *rot);
  480. // Set Vertex_active to number of occurrences of each vertex.
  481. // Set Num_vertices.
  482. extern void set_vertex_counts(void);
  483. // Modify seg2 to share side2 with seg1:side1. This forms a connection between
  484. // two segments without creating a new segment. It modifies seg2 by sharing
  485. // vertices from seg1. seg1 is not modified. Four vertices from seg2 are
  486. // deleted.
  487. // If the four vertices forming side2 in seg2 are not free, the joint is not formed.
  488. // Return code:
  489. // 0 joint formed
  490. // 1 unable to form joint because one or more vertices of side2 is not free
  491. // 2 unable to form joint because side1 is already used
  492. extern int med_form_joint(segment *seg1, int side1, segment *seg2, int side2);
  493. // The current texture... use by saying something=bm_lock_bitmap(CurrentTexture)
  494. extern int CurrentTexture;
  495. extern void compute_segment_center(vms_vector *vp,segment *sp);
  496. extern void med_propagate_tmaps_to_segments(segment *base_seg,segment *con_seg, int uv_only_flag);
  497. extern void med_propagate_tmaps_to_back_side(segment *base_seg, int back_side, int uv_only_flag);
  498. extern void med_propagate_tmaps_to_any_side(segment *base_seg, int back_side, int tmap_num, int uv_only_flag);
  499. // Find segment adjacent to sp:side.
  500. // Adjacent means a segment which shares all four vertices.
  501. // Return true if segment found and fill in segment in adj_sp and side in adj_side.
  502. // Return false if unable to find, in which case adj_sp and adj_side are undefined.
  503. extern int med_find_adjacent_segment_side(segment *sp, int side, segment **adj_sp, int *adj_side);
  504. // Finds the closest segment and side to sp:side.
  505. extern int med_find_closest_threshold_segment_side(segment *sp, int side, segment **adj_sp, int *adj_side, fix threshold);
  506. // Given two segments, return the side index in the connecting segment which connects to the base segment
  507. extern int find_connect_side(segment *base_seg, segment *con_seg);
  508. // Select previous segment.
  509. // If there is a connection on the side opposite to the current side, then choose that segment.
  510. // If there is no connecting segment on the opposite face, try any segment.
  511. extern void get_previous_segment(int curseg_num, int curside,int *newseg_num, int *newside);
  512. // Select next segment.
  513. // If there is a connection on the current side, then choose that segment.
  514. // If there is no connecting segment on the current side, try any segment.
  515. extern void get_next_segment(int curseg_num, int curside, int *newseg_num, int *newside);
  516. // Copy texture maps in newseg to nsp.
  517. extern void copy_uvs_seg_to_seg(segment *nsp,segment *newseg);
  518. // Return true if segment is concave.
  519. extern int check_seg_concavity(segment *s);
  520. // Return N_found_segs = number of concave segments in mine.
  521. // Segment ids stored at Found_segs
  522. extern void find_concave_segs(void);
  523. // High level call. Check for concave segments, print warning message (using editor_status)
  524. // if any concave segments.
  525. // Calls find_concave_segs, therefore N_found_segs gets set, and Found_segs filled in.
  526. extern void warn_if_concave_segments(void);
  527. // Warn if segment s is concave.
  528. extern void warn_if_concave_segment(segment *s);
  529. // Add a vertex to the vertex list.
  530. extern int med_add_vertex(vms_vector *vp);
  531. // Add a vertex to the vertex list which may be identical to another vertex (in terms of coordinates).
  532. // Don't scan list, looking for presence of a vertex with same coords, add this one.
  533. extern int med_create_duplicate_vertex(vms_vector *vp);
  534. // Create a new segment, duplicating exactly, including vertex ids and children, the passed segment.
  535. extern int med_create_duplicate_segment(segment *sp);
  536. // Returns the index of a free segment.
  537. // Scans the Segments array.
  538. extern int get_free_segment_number(void);
  539. // Diagnostic message.
  540. extern void diagnostic_message(const char *format, ... );
  541. // Status Icon.
  542. extern void print_status_icon( char icon[1], int position );
  543. extern void clear_status_icon( char icon[1], int position );
  544. // Editor status message.
  545. extern void editor_status(const char *format, ... );
  546. // Variables in editor.c that the k*.c files need
  547. #define UF_NONE 0x000 //nothing has changed
  548. #define UF_WORLD_CHANGED 0x001 //something added or deleted
  549. #define UF_VIEWPOINT_MOVED 0x002 //what we're watching has moved
  550. #define UF_GAME_VIEW_CHANGED 0x004 //the game window changed
  551. #define UF_ED_STATE_CHANGED 0x008 //something like curside,curseg changed
  552. #define UF_ALL 0xffffffff //all flags
  553. extern uint Update_flags;
  554. extern int Funky_chase_mode;
  555. extern vms_angvec Seg_orientation;
  556. extern vms_vector Seg_scale;
  557. extern int mine_changed;
  558. extern int ModeFlag;
  559. extern editor_view *current_view;
  560. //the view for the different windows
  561. extern editor_view LargeView;
  562. extern editor_view TopView;
  563. extern editor_view FrontView;
  564. extern editor_view RightView;
  565. extern void set_view_target_from_segment(segment *sp);
  566. extern int SafetyCheck();
  567. extern void editor_status( const char *format, ...);
  568. extern int MacroNumEvents;
  569. extern int MacroStatus;
  570. //extern int Highest_vertex_index; // Highest index in Vertices and Vertex_active, an efficiency hack
  571. //extern int Highest_segment_index; // Highest index in Segments, an efficiency hack
  572. extern int Lock_view_to_cursegp; // !0 means whenever cursegp changes, view it
  573. // eglobal.c
  574. extern int Num_tilings; // number of tilings/wall
  575. extern int Degenerate_segment_found;
  576. extern byte Been_visited[]; // List of segments visited in a recursive search, if element n set, segment n done been visited
  577. // Initializes autosave system.
  578. // Sets global Autosave_count to 0.
  579. extern void init_autosave(void);
  580. // Closes autosave system.
  581. // Deletes all autosaved files.
  582. extern void close_autosave(void);
  583. // Saves current mine to name.miX where name = suffix of mine name and X = Autosave_count.
  584. // For example, if name = "cookie.min", and Autosave_count = 3, then writes "cookie.mi3".
  585. // Increments Autosave_count, wrapping from 9 to 0.
  586. // (If there is no current mine name, assume "temp.min")
  587. // Call med_save_mine to save the mine.
  588. extern void autosave_mine(char *name);
  589. // Timed autosave
  590. extern void TimedAutosave(char *name);
  591. extern void set_editor_time_of_day();
  592. // Undo function
  593. extern int undo(void);
  594. extern char mine_filename[128];
  595. extern char undo_status[10][100];
  596. // group.c
  597. int AttachSegmentNewAng(vms_angvec *pbh);
  598. int RotateSegmentNew(vms_angvec *pbh);
  599. int rotate_segment_new(vms_angvec *pbh);
  600. //get & free vertices
  601. int alloc_vert();
  602. void free_vert(int vert_num);
  603. // The current robot type declared in eglobal.c
  604. extern int Cur_robot_type;
  605. // From med.c
  606. extern int DisplayCurrentRobotType(void);
  607. extern short Cur_object_index;
  608. extern int render_3d_in_big_window;
  609. extern void move_object_to_mouse_click(void);
  610. //these are instances of canvases, pointed to by variables below
  611. extern grs_canvas _canv_editor_game; //the game on the editor screen
  612. //these are pointers to our canvases
  613. extern grs_canvas *Canv_editor; //the editor screen
  614. extern grs_canvas *Canv_editor_game; //the game on the editor screen
  615. extern grs_canvas *canv_offscreen; //for off-screen rendering
  616. extern grs_canvas *Pad_text_canvas; // Keypad text
  617. //where the editor is looking
  618. extern vms_vector Ed_view_target;
  619. extern int gamestate_not_restored;
  620. extern UI_WINDOW * EditorWindow;
  621. extern int Large_view_index;
  622. extern UI_GADGET_USERBOX * GameViewBox;
  623. extern UI_GADGET_USERBOX * LargeViewBox;
  624. extern UI_GADGET_USERBOX * GroupViewBox;
  625. extern med_point_2_vec(grs_canvas *canv,vms_vector *v,short sx,short sy);
  626. //shutdown ui on the editor screen
  627. close_editor_screen(void);
  628. // From eobject.c
  629. extern int place_object(segment *segp, vms_vector *object_pos, int object_type);
  630. // from ksegsize.c
  631. extern void med_extract_up_vector_from_segment_side(segment *sp, int sidenum, vms_vector *vp);
  632. extern void med_extract_right_vector_from_segment_side(segment *sp, int sidenum, vms_vector *vp);
  633. extern void med_extract_forward_vector_from_segment_side(segment *sp, int sidenum, vms_vector *vp);
  634. // In medmisc.c
  635. extern void draw_world_from_game(void);
  636. // In medrobot.c
  637. extern void close_all_windows(void);
  638. // In seguvs.c
  639. // Amount to stretch a texture map by.
  640. // The two different ones are for the two dimensions of a texture map.
  641. extern fix Stretch_scale_x, Stretch_scale_y;
  642. #endif