home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / lib / editor.h < prev    next >
C/C++ Source or Header  |  1998-06-08  |  30KB  |  799 lines

  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.  
  155. #ifndef _EDITOR_H
  156. #define _EDITOR_H
  157.  
  158. #include "vecmat.h"
  159. #include "segment.h"
  160. #include "inferno.h"
  161. #include "gr.h"
  162. #include "ui.h"
  163.  
  164. /*
  165.  * Constants
  166.  *
  167.  */
  168.  
  169. #define ORTHO_VIEWS 0            // set to 1 to enable 3 orthogonal views
  170. #define ED_SCREEN_W    800        //width of editor screen
  171. #define ED_SCREEN_H    600        //height of editor screen
  172.  
  173. #define MENUBAR_H        16
  174.  
  175. #define GAMEVIEW_X    1        //where the 320x200 game window goes
  176. #define GAMEVIEW_Y    1+MENUBAR_H
  177. #define GAMEVIEW_W    320
  178. #define GAMEVIEW_H    200
  179.  
  180. #define STATUS_X    0
  181. #define STATUS_H    18
  182. #define STATUS_Y    (ED_SCREEN_H-STATUS_H)
  183. #define STATUS_W    ED_SCREEN_W
  184.  
  185. #define LVIEW_X    1            //large view
  186. #define LVIEW_Y    (GAMEVIEW_Y+GAMEVIEW_H+2)
  187. #define LVIEW_W    447
  188. #define LVIEW_H    (STATUS_Y-LVIEW_Y-2)
  189.  
  190. #define TMAPBOX_X    (LVIEW_X+LVIEW_W+4)    //location of first one
  191. #define TMAPBOX_Y    (LVIEW_Y+2)
  192. #define TMAPBOX_W    64
  193. #define TMAPBOX_H    64
  194.  
  195. #define TMAPCURBOX_X (TMAPBOX_X + 4*(TMAPBOX_W + 3))
  196. #define TMAPCURBOX_Y (TMAPBOX_Y + TMAPBOX_H)
  197.  
  198. #define OBJCURBOX_X (TMAPCURBOX_X)
  199. #define OBJCURBOX_Y (TMAPCURBOX_Y + 3*(TMAPBOX_H + 2) -40)
  200.  
  201. #define PAD_X (GAMEVIEW_X + GAMEVIEW_W + 16)
  202. #define PAD_Y (GAMEVIEW_Y + 4)
  203.  
  204. #define SMALLVIEW_W    173        //width of small view windows
  205. #define SMALLVIEW_H    148        //height of small view windows
  206.  
  207. #define TVIEW_X    (LVIEW_X+LVIEW_W+2)        //top view
  208. #define TVIEW_Y    LVIEW_Y
  209. #define TVIEW_W    SMALLVIEW_W
  210. #define TVIEW_H    SMALLVIEW_H
  211.  
  212. #define FVIEW_X    TVIEW_X                        //front view
  213. #define FVIEW_Y    (TVIEW_Y+SMALLVIEW_H+2)
  214. #define FVIEW_W    SMALLVIEW_W
  215. #define FVIEW_H    SMALLVIEW_H
  216.  
  217. #define RVIEW_X    (TVIEW_X+SMALLVIEW_W+2)    //right view
  218. #define RVIEW_Y    FVIEW_Y    
  219. #define RVIEW_W    SMALLVIEW_W
  220. #define RVIEW_H    SMALLVIEW_H
  221.  
  222. #define GVIEW_X    RVIEW_X                        //group view
  223. #define GVIEW_Y    TVIEW_Y    
  224. #define GVIEW_W    SMALLVIEW_W
  225. #define GVIEW_H    SMALLVIEW_H
  226.  
  227. //there were color constants here, but I moved them to meddraw.c - Matt
  228.  
  229. #define    SEGMOVE_PAD_ID        0
  230. #define    SEGSIZE_PAD_ID        1
  231. #define    CURVE_PAD_ID        2    
  232. #define    TEXTURE_PAD_ID        3
  233. #define    OBJECT_PAD_ID        4
  234. #define    OBJMOV_PAD_ID        5
  235. #define    GROUP_PAD_ID        6
  236. #define    LIGHTING_PAD_ID    7
  237. #define    TEST_PAD_ID            8
  238. #define    MAX_PAD_ID            8
  239.  
  240. /*
  241.  * Strucures
  242.  * 
  243.  */
  244.  
  245. #define VF_ANGLES 0
  246. #define VF_MATRIX 1
  247.  
  248. // Default size of a segment
  249. #define    DEFAULT_X_SIZE        F1_0*20
  250. #define    DEFAULT_Y_SIZE        F1_0*20
  251. #define    DEFAULT_Z_SIZE        F1_0*20
  252.  
  253. //    Scale factor from 3d units (integer portion) to uv coordinates (integer portion)
  254. #define    VMAG    (F1_0 / (DEFAULT_X_SIZE/F1_0))
  255. #define    UMAG    VMAG        // unused
  256.  
  257. //    Number of segments which can be found (size of Found_segs[])
  258. #define    MAX_FOUND_SEGS        200
  259. #define    MAX_SELECTED_SEGS    (MAX_SEGMENTS)
  260. #define    MAX_WARNING_SEGS    (MAX_SEGMENTS)
  261.  
  262. #define    MAX_GROUPS            10
  263. #define    ROT_GROUP            MAX_GROUPS
  264.  
  265. //    Modes for segment sizing
  266. #define SEGSIZEMODE_FREE         1
  267. #define SEGSIZEMODE_ALL             2
  268. #define SEGSIZEMODE_CURSIDE    3
  269. #define SEGSIZEMODE_EDGE        4
  270. #define SEGSIZEMODE_VERTEX        5
  271.  
  272. #define SEGSIZEMODE_MIN            SEGSIZEMODE_FREE
  273. #define SEGSIZEMODE_MAX            SEGSIZEMODE_VERTEX
  274.  
  275. //defines a view for an editor window
  276. typedef struct editor_view {
  277.     short ev_num;                //each view has it's own number
  278.     short ev_changed;            //set to true if view changed
  279.     grs_canvas *ev_canv;        //points to this window's canvas
  280.     fix ev_dist;                //the distance from the view point
  281.     vms_matrix ev_matrix;    //the view matrix
  282.     fix ev_zoom;                //zoom for this window
  283. } editor_view;
  284.  
  285. /*
  286.  * Global variables
  287.  * 
  288.  */
  289.  
  290. extern editor_view *Views[];
  291. extern int N_views;
  292. extern grs_canvas *canv_offscreen;        //for off-screen rendering
  293. extern int Large_view_index;
  294. extern UI_GADGET_USERBOX * LargeViewBox;
  295. extern int Found_seg_index;                // Index in Found_segs corresponding to Cursegp
  296. extern int gamestate_not_restored;
  297.  
  298.  
  299. extern    segment  *Cursegp;                // Pointer to current segment in the mine, the one to which things happen.
  300. extern    vms_vector Ed_view_target;        // what editor is looking at
  301. extern    segment  New_segment;            // The segment which can be added to the mine.
  302. extern    int        Curside;                    // Side index in 0..MAX_SIDES_PER_SEGMENT of active side.
  303. extern    int        Curedge;                    //    Current edge on current side, in 0..3
  304. extern    int        Curvert;                    //    Current vertex on current side, in 0..3
  305. extern    int        AttachSide;                //    Side on segment to attach
  306. extern    int        Draw_all_segments;    // Set to 1 means draw_world draws all segments in Segments, else draw only connected segments
  307. extern    segment    *Markedsegp;            // Marked segment, used in conjunction with *Cursegp to form joints.
  308. extern    int        Markedside;                // Marked side on Markedsegp.
  309. extern    byte        Vertex_active[MAX_VERTICES];    // !0 means vertex is in use, 0 means not in use.
  310.  
  311. extern    grs_canvas *Pad_text_canvas;        // Keypad text
  312.  
  313. // The extra group in the following arrays is used for group rotation.
  314. extern     group        GroupList[MAX_GROUPS+1];
  315. extern     segment  *Groupsegp[MAX_GROUPS+1];
  316. extern     int        Groupside[MAX_GROUPS+1];
  317. extern    int         current_group;
  318. extern    int         num_groups; 
  319. extern    int        Current_group;
  320.  
  321. extern    short        Found_segs[];            // List of segment numbers "found" under cursor click
  322. extern    int        N_found_segs;            // Number of segments found at Found_segs
  323.  
  324. extern    int        N_selected_segs;        // Number of segments found at Selected_segs
  325. extern    short        Selected_segs[];        // List of segment numbers currently selected
  326.  
  327. extern    int        N_warning_segs;        // Number of segments warning-worthy, such as a concave segment
  328. extern    short        Warning_segs[];        // List of warning-worthy segments
  329.  
  330. extern    int        Show_axes_flag;        // 0 = don't show, !0 = do show coordinate axes in *Cursegp orientation
  331.  
  332. extern   int        Autosave_count;        // Current counter for which autosave mine we are "on"
  333. extern    int        Autosave_flag;            // Whether or not Autosave is on.
  334. extern    struct tm Editor_time_of_day;
  335.  
  336. extern    int        SegSizeMode;            // Mode = 0/1 = not/is legal to move bound vertices, 
  337.  
  338. void init_editor(void);
  339. void editor(void);
  340. void close_editor(void);
  341. void init_editor_screen(void);
  342.  
  343. //    Returns true if vertex vi is contained in exactly one segment, else returns false.
  344. extern int is_free_vertex(int vi);
  345.  
  346. //    Set existing vertex vnum to value *vp.
  347. extern    int med_set_vertex(int vnum,vms_vector *vp);
  348.  
  349. extern void med_combine_duplicate_vertices(byte *vlp);
  350.  
  351. // Attach side newside of newseg to side destside of destseg.
  352. // Copies *newseg into global array Segments, increments Num_segments.
  353. // Forms a weld between the two segments by making the new segment fit to the old segment.
  354. // Updates number of faces per side if necessitated by new vertex coordinates.
  355. // Return value:
  356. //  0 = successful attach
  357. //  1 = No room in Segments[].
  358. //  2 = No room in Vertices[].
  359. extern    int med_attach_segment(segment *destseg, segment *newseg, int destside, int newside);
  360.  
  361. // Delete a segment.
  362. // Deletes a segment from the global array Segments.
  363. // Updates Cursegp to be the segment to which the deleted segment was connected.  If there is
  364. //    more than one connected segment, the new Cursegp will be the segment with the highest index
  365. //    of connection in the deleted segment (highest index = front)
  366. // Return value:
  367. //  0 = successful deletion
  368. //  1 = unable to delete
  369. extern    int med_delete_segment(segment *sp);
  370.  
  371. // Rotate the segment *seg by the pitch, bank, heading defined by *rot, destructively
  372. // modifying its four free vertices in the global array Vertices.
  373. // It is illegal to rotate a segment which has MAX_SIDES_PER_SEGMENT != 1.
  374. // Pitch, bank, heading are about the point which is the average of the four points
  375. // forming the side of connection.
  376. // Return value:
  377. //  0 = successful rotation
  378. //  1 = MAX_SIDES_PER_SEGMENT makes rotation illegal (connected to 0 or 2+ segments)
  379. //  2 = Rotation causes degeneracy, such as self-intersecting segment.
  380. extern    int med_rotate_segment(segment *seg, vms_matrix *rotmat);
  381. extern    int med_rotate_segment_ang(segment *seg, vms_angvec *ang);
  382.  
  383. // Scales a segment, destructively modifying vertex coordinates in global Vertices[].
  384. //    Uses scale factor in sp->scale.
  385. //    Modifies only free vertices (those which are not part of a segment other than *sp).
  386. // The vector *svp contains the x,y,z scale factors.  The x,y,z directions are relative
  387. // to the segment.  x scales in the dimension of the right vector, y of the up vector, z of the forward vector.
  388. // The dimension of the vectors is determined by averaging appropriate sets of 4 of the 8 points.
  389. extern void med_scale_segment(segment *sp);
  390.  
  391. //    Create a wall which can be removed.
  392. //    Creates wall at sp->sides[side], making it part of segment sp
  393. //    Removable walls must be placed between two connected segments.  You should add the removable
  394. //    wall on both sides.  In fact, you really must.
  395. extern void create_removable_wall(segment *sp, int side, int tmap_num);
  396.  
  397. // Loads mine *name from disk, updating global variables:
  398. //    Segments, Vertices
  399. //    Num_segments,Num_vertices
  400. //    Cursegp = pointer to active segment.  Written as an index in med_save_mine, converted to a pointer
  401. //        at load time.
  402. // Returns:
  403. //  0 = successfully loaded.
  404. //  1 = unable to load.
  405. extern    int med_load_mine(char *name);
  406.  
  407. // Loads game *name from disk.
  408. // This function automatically loads mine with name.MIN 
  409. extern    int med_load_game(char *name);
  410.  
  411.  
  412. // Loads a previous generation mine.  Needs to be updated in code. 
  413. extern    int med_load_pmine(char *name);
  414.  
  415. // Saves mine contained in Segments[] and Vertices[].
  416. // Num_segments = number of segments in mine.
  417. // Num_vertices = number of vertices in mine.
  418. // Cursegp = current segment.
  419. // Saves Num_segments, and index of current segment (which is Cursegp - Segments), which will be converted to a pointer
  420. // and written to Cursegp in med_load_mine.
  421. // Returns:
  422. //  0 = successfully saved.
  423. //  1 = unable to save.
  424. extern    int med_save_mine(char *name);
  425.  
  426. // Loads group *filename from disk.
  427. //    Adds group to global Segments and Vertices array.
  428. //    Returns:
  429. //     0 = successfully loaded.
  430. //     1 = unable to load.
  431. extern    int med_load_group( char *filename, short *vertex_ids, short *segment_ids, int *num_vertices, int *num_segments);
  432.  
  433. // Saves group *filename from disk.
  434. //    Saves group defined by vertex_ids and segment_ids to disk. 
  435. //    Returns:
  436. //     0 = successfully saved.
  437. //     1 = unable to save.
  438. extern    int med_save_group( char *filename, short *vertex_ids, short *segment_ids, int num_vertices, int num_segments);
  439.  
  440. // Updates the screen... (I put the prototype here for curves.c)
  441. extern   int medlisp_update_screen();
  442.  
  443. // Returns 0 if no error, 1 if error, whatever that might be.
  444. // Sets globals:
  445. //    Num_segments
  446. //    Num_vertices
  447. //    Cursegp = pointer to only segment.
  448. extern    int create_new_mine(void);
  449.  
  450. // extern    void med_create_segment(segment *sp, vms_vector *scale);
  451. 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);
  452.  
  453. // Copy a segment from *ssp to *dsp.  Do not simply copy the struct.  Use *dsp's vertices, copying in
  454. //    just the values, not the indices.
  455. extern    void med_copy_segment(segment *dsp,segment *ssp);
  456.  
  457. //    Create a default segment.
  458. //    Useful for when user creates a garbage segment.
  459. extern    void med_create_default_segment(segment *sp);
  460.  
  461. //    Create New_segment with sizes found in *scale.
  462. extern    void med_create_new_segment(vms_vector *scale);
  463.  
  464. //    Create New_segment with sizes found in Cursegp.
  465. extern void med_create_new_segment_from_cursegp(void);
  466.  
  467. //    Update New_segment using scale factors.
  468. extern    void med_update_new_segment(void);
  469.  
  470. //    Replace *sp with New_segment.
  471. extern    void med_update_segment(segment *sp);
  472.  
  473. //    Create a new segment and use it to form a bridge between two existing segments.
  474. //    Specify two segment:side pairs.  If either segment:side is not open (ie, segment->children[side] != -1)
  475. //    then it is not legal to form the brider.
  476. //    Return:
  477. //        0    bridge segment formed
  478. //        1    unable to form bridge because one (or both) of the sides is not open.
  479. //    Note that no new vertices are created by this process.
  480. extern    int med_form_bridge_segment(segment *seg1, int side1, segment *seg2, int side2);
  481.  
  482. //    Compress mine at Segments and Vertices by squeezing out all holes.
  483. //    If no holes (ie, an unused segment followed by a used segment), then no action.
  484. //    If Cursegp or Markedsegp is a segment which gets moved to fill in a hole, then
  485. //    they are properly updated.
  486. extern    void med_compress_mine(void);
  487.  
  488. //    Extract the forward vector from segment *sp, return in *vp.
  489. //    The forward vector is defined to be the vector from the the center of the front face of the segment
  490. // to the center of the back face of the segment.
  491. extern    void med_extract_forward_vector_from_segment(segment *sp,vms_vector *vp);
  492.  
  493. //    Extract the right vector from segment *sp, return in *vp.
  494. //    The forward vector is defined to be the vector from the the center of the left face of the segment
  495. // to the center of the right face of the segment.
  496. extern    void med_extract_right_vector_from_segment(segment *sp,vms_vector *vp);
  497.  
  498. //    Extract the up vector from segment *sp, return in *vp.
  499. //    The forward vector is defined to be the vector from the the center of the bottom face of the segment
  500. // to the center of the top face of the segment.
  501. extern    void med_extract_up_vector_from_segment(segment *sp,vms_vector *vp);
  502.  
  503. // Compute the center point of a side of a segment.
  504. //    The center point is defined to be the average of the 4 points defining the side.
  505. extern    void med_compute_center_point_on_side(vms_vector *vp,segment *sp,int side);
  506.  
  507. extern void    set_matrix_based_on_side(vms_matrix *rotmat,int destside);
  508.  
  509. // Given a forward vector, compute and return an angvec triple.
  510. //    [ THIS SHOULD BE MOVED TO THE VECTOR MATRIX LIBRARY ]
  511. extern    vms_angvec *vm_vec_to_angles(vms_angvec *result, vms_vector *forvec);
  512.  
  513.  
  514. // Curves stuff.
  515.  
  516. #define ACCURACY 0.1*F1_0
  517.  
  518. typedef struct vms_equation {
  519.     union {
  520.             struct {fix x3, x2, x1, x0, y3, y2, y1, y0, z3, z2, z1, z0;};
  521.             fix xyz[3][4];
  522.     };
  523. } vms_equation;
  524.  
  525. extern void create_curve(vms_vector *p1, vms_vector *p4, vms_vector *r1, vms_vector *r4, vms_equation *coeffs);
  526. // Q(t) = (2t^3 - 3t^2 + 1) p1 + (-2t^3 + 3t^2) p4 + (t^3 - 2t^2 + t) r1 + (t^3 - t^2 ) r4
  527.  
  528. extern vms_vector evaluate_curve(vms_equation *coeffs, int degree, fix t);
  529.  
  530. extern fix curve_dist(vms_equation *coeffs, int degree, fix t0, vms_vector *p0, fix dist);
  531.  
  532. extern void curve_dir(vms_equation *coeffs, int degree, fix t0, vms_vector *dir);
  533.  
  534. extern void plot_parametric(vms_equation *coeffs, fix min_t, fix max_t, fix del_t);
  535.  
  536. // Curve generation routine.
  537. // Returns 1 if curve is generated.
  538. // Returns 0 if no curve.
  539. extern int generate_curve( fix r1scale, fix r4scale );
  540.  
  541. // Deletes existing curve generated in generate_curve().
  542. extern void delete_curve();
  543.  
  544. // --- // -- Temporary function, identical to med_rotate_segment, but it takes a vector instead of an angvec
  545. // --- extern    int med_rotate_segment_vec(segment *seg, vms_vector *vec);
  546.  
  547. extern    void med_extract_matrix_from_segment(segment *sp,vms_matrix *rotmat);
  548.  
  549. //    Assign default u,v coordinates to all sides of a segment.
  550. //    This routine should only be used for segments which are not connected to anything else,
  551. //    ie the segment created at mine creation.
  552. extern    void assign_default_uvs_to_segment(segment *segp);
  553. extern    void assign_default_uvs_to_side(segment *segp, int side);
  554.  
  555. extern    void assign_default_uvs_to_side(segment *segp,int side);
  556.  
  557. //    Assign u,v coordinates to con_seg, con_common_side from base_seg, base_common_side
  558. //    They are connected at the edge defined by the vertices abs_id1, abs_id2.
  559. 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);
  560.  
  561. // Debug -- show a matrix.
  562. //    type: 0 --> mprintf, 1 --> printf
  563. //    *s = string to display
  564. //    *mp = matrix to display
  565. extern    void show_matrix(char *s,vms_matrix *mp,int type);
  566.  
  567. //    Create coordinate axes in orientation of specified segment, stores vertices at *vp.
  568. extern    void create_coordinate_axes_from_segment(segment *sp,short *vertnums);
  569.  
  570. //    Scale a segment.  Then, if it is connected to something, rotate it.
  571. extern    int med_scale_and_rotate_segment(segment *seg, vms_angvec *rot);
  572.  
  573. //    Set Vertex_active to number of occurrences of each vertex.
  574. //    Set Num_vertices.
  575. extern    void set_vertex_counts(void);
  576.  
  577. //    Modify seg2 to share side2 with seg1:side1.  This forms a connection between
  578. //    two segments without creating a new segment.  It modifies seg2 by sharing
  579. //    vertices from seg1.  seg1 is not modified.  Four vertices from seg2 are
  580. //    deleted.
  581. //    If the four vertices forming side2 in seg2 are not free, the joint is not formed.
  582. //    Return code:
  583. //        0            joint formed
  584. //        1            unable to form joint because one or more vertices of side2 is not free
  585. //        2            unable to form joint because side1 is already used
  586. extern    int med_form_joint(segment *seg1, int side1, segment *seg2, int side2);
  587.  
  588. // The current texture... use by saying something=bm_lock_bitmap(CurrentTexture)
  589. extern int CurrentTexture;
  590.  
  591. extern void compute_segment_center(vms_vector *vp,segment *sp);
  592.  
  593. extern void med_propagate_tmaps_to_segments(segment *base_seg,segment *con_seg, int uv_only_flag);
  594.  
  595. extern void med_propagate_tmaps_to_back_side(segment *base_seg, int back_side, int uv_only_flag);
  596.  
  597. extern void med_propagate_tmaps_to_any_side(segment *base_seg, int back_side, int tmap_num, int uv_only_flag);
  598.  
  599. //    Find segment adjacent to sp:side.
  600. //    Adjacent means a segment which shares all four vertices.
  601. //    Return true if segment found and fill in segment in adj_sp and side in adj_side.
  602. //    Return false if unable to find, in which case adj_sp and adj_side are undefined.
  603. extern int med_find_adjacent_segment_side(segment *sp, int side, segment **adj_sp, int *adj_side);
  604.  
  605. // Finds the closest segment and side to sp:side.
  606. extern int med_find_closest_threshold_segment_side(segment *sp, int side, segment **adj_sp, int *adj_side, fix threshold);
  607.  
  608. //    Given two segments, return the side index in the connecting segment which connects to the base segment
  609. extern int find_connect_side(segment *base_seg, segment *con_seg);
  610.  
  611. // Select previous segment.
  612. //    If there is a connection on the side opposite to the current side, then choose that segment.
  613. // If there is no connecting segment on the opposite face, try any segment.
  614. extern void get_previous_segment(int curseg_num, int curside,int *newseg_num, int *newside);
  615.  
  616. // Select next segment.
  617. //    If there is a connection on the current side, then choose that segment.
  618. // If there is no connecting segment on the current side, try any segment.
  619. extern void get_next_segment(int curseg_num, int curside, int *newseg_num, int *newside);
  620.  
  621. //    Copy texture maps in newseg to nsp.
  622. extern void copy_uvs_seg_to_seg(segment *nsp,segment *newseg);
  623.  
  624. //    Return true if segment is concave.
  625. extern int check_seg_concavity(segment *s);
  626.  
  627. //    Return N_found_segs = number of concave segments in mine.
  628. //    Segment ids stored at Found_segs
  629. extern void find_concave_segs(void);
  630.  
  631. //    High level call.  Check for concave segments, print warning message (using editor_status)
  632. //    if any concave segments.
  633. //    Calls find_concave_segs, therefore N_found_segs gets set, and Found_segs filled in.
  634. extern void warn_if_concave_segments(void);
  635.  
  636. //    Warn if segment s is concave.
  637. extern void warn_if_concave_segment(segment *s);
  638.  
  639. //    Add a vertex to the vertex list.
  640. extern int med_add_vertex(vms_vector *vp);
  641.  
  642. //    Add a vertex to the vertex list which may be identical to another vertex (in terms of coordinates).
  643. //    Don't scan list, looking for presence of a vertex with same coords, add this one.
  644. extern int med_create_duplicate_vertex(vms_vector *vp);
  645.  
  646. //    Create a new segment, duplicating exactly, including vertex ids and children, the passed segment.
  647. extern int med_create_duplicate_segment(segment *sp);
  648.  
  649. //    Returns the index of a free segment.
  650. //    Scans the Segments array.
  651. extern int get_free_segment_number(void);
  652.  
  653. //      Diagnostic message.
  654. extern void diagnostic_message(const char *format, ... );
  655.  
  656. //      Status Icon.
  657. extern void print_status_icon( char icon[1], int position );
  658. extern void clear_status_icon( char icon[1], int position );
  659.  
  660. //      Editor status message.
  661. extern void editor_status(const char *format, ... );
  662.  
  663. // Variables in editor.c that the k*.c files need
  664.  
  665. #define UF_NONE             0x000       //nothing has changed
  666. #define UF_WORLD_CHANGED    0x001       //something added or deleted
  667. #define UF_VIEWPOINT_MOVED  0x002       //what we're watching has moved
  668.  
  669. #define UF_GAME_VIEW_CHANGED 0x004        //the game window changed    
  670. #define UF_ED_STATE_CHANGED  0x008        //something like curside,curseg changed
  671.  
  672. #define UF_ALL                    0xffffffff  //all flags
  673.  
  674. extern uint        Update_flags;
  675. extern int         Funky_chase_mode;
  676. extern vms_angvec  Seg_orientation;
  677. extern vms_vector  Seg_scale;
  678. extern int         mine_changed;
  679. extern int         ModeFlag;
  680. extern editor_view *current_view;
  681.  
  682. //the view for the different windows
  683. extern editor_view LargeView;
  684. extern editor_view TopView;
  685. extern editor_view FrontView;
  686. extern editor_view RightView;
  687.  
  688. extern void set_view_target_from_segment(segment *sp);
  689. extern int SafetyCheck();
  690.  
  691. extern void editor_status( const char *format, ...);
  692.  
  693. extern int MacroNumEvents;
  694. extern int MacroStatus;
  695.  
  696. //extern    int    Highest_vertex_index;            // Highest index in Vertices and Vertex_active, an efficiency hack
  697. //extern    int    Highest_segment_index;            // Highest index in Segments, an efficiency hack
  698. extern    int    Lock_view_to_cursegp;            // !0 means whenever cursegp changes, view it
  699.  
  700. //    eglobal.c
  701. extern    int    Num_tilings;                        // number of tilings/wall
  702. extern    int    Degenerate_segment_found;
  703.  
  704. extern    byte    Been_visited[];                    //    List of segments visited in a recursive search, if element n set, segment n done been visited
  705.  
  706. // Initializes autosave system.
  707. // Sets global Autosave_count to 0.
  708. extern void init_autosave(void);
  709.  
  710. // Closes autosave system.
  711. // Deletes all autosaved files.
  712. extern void close_autosave(void);
  713.  
  714. // Saves current mine to name.miX where name = suffix of mine name and X = Autosave_count.
  715. // For example, if name = "cookie.min", and Autosave_count = 3, then writes "cookie.mi3".
  716. // Increments Autosave_count, wrapping from 9 to 0.
  717. // (If there is no current mine name, assume "temp.min")
  718. // Call med_save_mine to save the mine.
  719. extern void autosave_mine(char *name);
  720.  
  721. // Timed autosave
  722. extern void TimedAutosave(char *name);
  723. extern void set_editor_time_of_day();
  724.  
  725. // Undo function
  726. extern int undo(void);
  727. extern char mine_filename[128];
  728. extern char undo_status[10][100];
  729.  
  730. //    group.c
  731. int AttachSegmentNewAng(vms_angvec *pbh);
  732. int RotateSegmentNew(vms_angvec *pbh);
  733. int rotate_segment_new(vms_angvec *pbh);
  734.  
  735. //get & free vertices
  736. int alloc_vert();
  737. void free_vert(int vert_num);
  738.  
  739. // The current robot type declared in eglobal.c
  740. extern int Cur_robot_type;
  741.  
  742. //    From med.c
  743. extern int DisplayCurrentRobotType(void);
  744. extern short            Cur_object_index;
  745.  
  746. extern int render_3d_in_big_window;
  747. extern void move_object_to_mouse_click(void);
  748.  
  749. //these are instances of canvases, pointed to by variables below
  750. extern grs_canvas _canv_editor_game;        //the game on the editor screen
  751.  
  752. //these are pointers to our canvases
  753. extern grs_canvas *Canv_editor;            //the editor screen
  754. extern grs_canvas *Canv_editor_game; //the game on the editor screen
  755.  
  756. extern grs_canvas *canv_offscreen;        //for off-screen rendering
  757. extern grs_canvas *Pad_text_canvas;        // Keypad text
  758.  
  759. //where the editor is looking
  760. extern vms_vector Ed_view_target;
  761.  
  762. extern int gamestate_not_restored;
  763.  
  764. extern UI_WINDOW * EditorWindow;
  765.  
  766. extern int     Large_view_index;
  767.  
  768. extern UI_GADGET_USERBOX * GameViewBox;
  769. extern UI_GADGET_USERBOX * LargeViewBox;
  770. extern UI_GADGET_USERBOX * GroupViewBox;
  771.  
  772. extern med_point_2_vec(grs_canvas *canv,vms_vector *v,short sx,short sy);
  773.  
  774. //shutdown ui on the editor screen
  775. close_editor_screen(void);
  776.  
  777. //    From eobject.c
  778. extern int place_object(segment *segp, vms_vector *object_pos, int object_type);
  779.  
  780. // from ksegsize.c
  781. extern void med_extract_up_vector_from_segment_side(segment *sp, int sidenum, vms_vector *vp);
  782. extern void med_extract_right_vector_from_segment_side(segment *sp, int sidenum, vms_vector *vp);
  783. extern void med_extract_forward_vector_from_segment_side(segment *sp, int sidenum, vms_vector *vp);
  784.  
  785. //    In medmisc.c
  786. extern void draw_world_from_game(void);
  787.  
  788. //    In medrobot.c
  789. extern void close_all_windows(void);
  790.  
  791. //    In seguvs.c
  792.  
  793. //    Amount to stretch a texture map by.
  794. //    The two different ones are for the two dimensions of a texture map.
  795. extern fix Stretch_scale_x, Stretch_scale_y;
  796.  
  797. #endif
  798.  
  799.