]> icculus.org git repositories - btb/d2x.git/blob - main/polyobj.h
fix automap background image
[btb/d2x.git] / main / polyobj.h
1 /* $Id: polyobj.h,v 1.7 2003-10-10 09:36:35 btb Exp $ */
2 /*
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.
13 */
14
15 /*
16  *
17  * Header for polyobj.c, the polygon object code
18  *
19  * Old Log:
20  * Revision 1.2  1995/09/14  14:10:30  allender
21  * two functions should be void
22  *
23  * Revision 1.1  1995/05/16  16:01:27  allender
24  * Initial revision
25  *
26  * Revision 2.1  1995/02/27  18:21:54  john
27  * Added extern for robot_points.
28  *
29  * Revision 2.0  1995/02/27  11:29:58  john
30  * New version 2.0, which has no anonymous unions, builds with
31  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
32  *
33  * Revision 1.28  1995/01/12  12:10:16  adam
34  * *** empty log message ***
35  *
36  * Revision 1.27  1994/11/11  19:28:58  matt
37  * Added code to show low detail polygon models
38  *
39  * Revision 1.26  1994/11/10  14:03:05  matt
40  * Hacked in support for player ships with different textures
41  *
42  * Revision 1.25  1994/11/02  16:18:24  matt
43  * Moved draw_model_picture() out of editor
44  *
45  * Revision 1.24  1994/10/18  10:55:57  adam
46  * bumped MAX_POLYGON_OBJECTS up
47  *
48  * Revision 1.23  1994/10/17  21:35:01  matt
49  * Added support for new Control Center/Main Reactor
50  *
51  * Revision 1.22  1994/09/09  14:23:42  matt
52  * Added glow code to polygon models for engine glow
53  *
54  * Revision 1.21  1994/08/26  18:03:43  matt
55  * Added code to remap polygon model numbers by matching filenames
56  *
57  * Revision 1.20  1994/08/26  15:36:00  matt
58  * Made eclips usable on more than one object at a time
59  *
60  * Revision 1.19  1994/07/22  20:44:23  matt
61  * Killed unused fields in polygon model structure
62  *
63  * Revision 1.18  1994/06/16  17:52:11  matt
64  * Made submodels rotate around their centers, not their pivot points
65  *
66  * Revision 1.17  1994/06/14  12:22:05  matt
67  * Integrated with drive code, using #defines to switch versions
68  *
69  * Revision 1.16  1994/06/09  16:25:01  matt
70  * Fixed confusion with two constants, MAX_SUBOBJS & MAX_SUBMODELS, which
71  * were used for the same things, but had different values.
72  *
73  * Revision 1.15  1994/06/08  10:56:38  matt
74  * Improved debris: now get submodel size from new POF files; debris now has
75  * limited life; debris can now be blown up.
76  *
77  * Revision 1.14  1994/06/07  16:51:57  matt
78  * Made object lighting work correctly; changed name of Ambient_light to
79  * Dynamic_light; cleaned up polygobj object rendering a little.
80  *
81  * Revision 1.13  1994/05/26  21:08:59  matt
82  * Moved robot stuff out of polygon model and into robot_info struct
83  * Made new file, robot.c, to deal with robots
84  *
85  * Revision 1.12  1994/05/18  19:35:05  matt
86  * Added fields for the rest of the subobj data
87  *
88  * Revision 1.11  1994/05/16  16:17:13  john
89  * Bunch of stuff on my Inferno Task list May16-23
90  *
91  * Revision 1.10  1994/05/13  11:08:31  matt
92  * Added support for multiple gun positions on polygon models
93  *
94  * Revision 1.9  1994/04/29  09:18:04  matt
95  * Added support for multiple-piece explosions
96  *
97  * Revision 1.8  1994/04/28  18:44:18  matt
98  * Took out code for old-style (non-interpreted) objects.
99  *
100  * Revision 1.7  1994/03/25  16:54:38  matt
101  * draw_polygon_object() now takes pointer to animation data
102  *
103  * Revision 1.6  1994/03/15  17:44:33  matt
104  * Changed a bunch of names
105  *
106  * Revision 1.5  1994/03/07  20:02:29  matt
107  * Added pointer to normals in polyobj struct
108  * Added prototype for draw_polygon_object()
109  *
110  * Revision 1.4  1994/03/01  17:16:19  matt
111  * Lots of changes to support loadable binary ".pof" robot files
112  *
113  * Revision 1.3  1994/01/31  15:51:20  matt
114  * Added ptr for rgb table for robot colors
115  *
116  * Revision 1.2  1994/01/28  13:52:01  matt
117  * Added flesh to this previously skeletal file.
118  *
119  * Revision 1.1  1994/01/28  13:47:42  matt
120  * Initial revision
121  *
122  *
123  */
124
125
126 #ifndef _POLYOBJ_H
127 #define _POLYOBJ_H
128
129 #include "vecmat.h"
130 #include "gr.h"
131 #include "3d.h"
132
133 #ifndef DRIVE
134 #include "robot.h"
135 #endif
136 #include "piggy.h"
137
138 #define MAX_POLYGON_MODELS 200
139
140 //used to describe a polygon model
141 typedef struct polymodel {
142         int     n_models;
143         int     model_data_size;
144         ubyte   *model_data;
145         int     submodel_ptrs[MAX_SUBMODELS];
146         vms_vector submodel_offsets[MAX_SUBMODELS];
147         vms_vector submodel_norms[MAX_SUBMODELS];   // norm for sep plane
148         vms_vector submodel_pnts[MAX_SUBMODELS];    // point on sep plane
149         fix     submodel_rads[MAX_SUBMODELS];       // radius for each submodel
150         ubyte   submodel_parents[MAX_SUBMODELS];    // what is parent for each submodel
151         vms_vector submodel_mins[MAX_SUBMODELS];
152         vms_vector submodel_maxs[MAX_SUBMODELS];
153         vms_vector mins,maxs;                       // min,max for whole model
154         fix     rad;
155         ubyte   n_textures;
156         ushort  first_texture;
157         ubyte   simpler_model;                      // alternate model with less detail (0 if none, model_num+1 else)
158         //vms_vector min,max;
159 } __pack__ polymodel;
160
161 // array of pointers to polygon objects
162 extern polymodel Polygon_models[];
163
164 // switch to simpler model when the object has depth
165 // greater than this value times its radius.
166 extern int Simple_model_threshhold_scale;
167
168 // how many polygon objects there are
169 extern int N_polygon_models;
170
171
172 // array of names of currently-loaded models
173 extern char Pof_names[MAX_POLYGON_MODELS][13];
174
175 void init_polygon_models();
176
177 #ifndef DRIVE
178 int load_polygon_model(char *filename,int n_textures,int first_texture,robot_info *r);
179 #else
180 int load_polygon_model(char *filename,int n_textures,grs_bitmap ***textures);
181 #endif
182
183 // draw a polygon model
184 void draw_polygon_model(vms_vector *pos,vms_matrix *orient,vms_angvec *anim_angles,int model_num,int flags,fix light,fix *glow_values,bitmap_index alt_textures[]);
185
186 // fills in arrays gun_points & gun_dirs, returns the number of guns read
187 int read_model_guns(char *filename,vms_vector *gun_points, vms_vector *gun_dirs, int *gun_submodels);
188
189 // draws the given model in the current canvas.  The distance is set to
190 // more-or-less fill the canvas.  Note that this routine actually renders
191 // into an off-screen canvas that it creates, then copies to the current
192 // canvas.
193 void draw_model_picture(int mn,vms_angvec *orient_angles);
194
195 // free up a model, getting rid of all its memory
196 void free_model(polymodel *po);
197
198 #define MAX_POLYOBJ_TEXTURES 100
199 extern grs_bitmap *texture_list[MAX_POLYOBJ_TEXTURES];
200 extern bitmap_index texture_list_index[MAX_POLYOBJ_TEXTURES];
201 extern g3s_point robot_points[];
202
203 #ifdef FAST_FILE_IO
204 #define polymodel_read(pm, fp) cfread(pm, sizeof(polymodel), 1, fp)
205 #define polymodel_read_n(pm, n, fp) cfread(pm, sizeof(polymodel), n, fp)
206 #else
207 /*
208  * reads a polymodel structure from a CFILE
209  */
210 extern void polymodel_read(polymodel *pm, CFILE *fp);
211
212 /*
213  * reads n polymodel structs from a CFILE
214  */
215 extern int polymodel_read_n(polymodel *pm, int n, CFILE *fp);
216 #endif
217
218 /*
219  * routine which allocates, reads, and inits a polymodel's model_data
220  */
221 void polygon_model_data_read(polymodel *pm, CFILE *fp);
222
223 #endif /* _POLYOBJ_H */