]> icculus.org git repositories - btb/d2x.git/blob - main/polyobj.h
use the orientation parameter of g3_draw_bitmap
[btb/d2x.git] / main / polyobj.h
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-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 /*
15  *
16  * Header for polyobj.c, the polygon object code
17  *
18  */
19
20
21 #ifndef _POLYOBJ_H
22 #define _POLYOBJ_H
23
24 #include "vecmat.h"
25 #include "gr.h"
26 #include "3d.h"
27
28 #ifndef DRIVE
29 #include "robot.h"
30 #endif
31 #include "piggy.h"
32
33 #define MAX_POLYGON_MODELS 200
34
35 //used to describe a polygon model
36 typedef struct polymodel {
37         int     n_models;
38         int     model_data_size;
39         ubyte   *model_data;
40         int     submodel_ptrs[MAX_SUBMODELS];
41         vms_vector submodel_offsets[MAX_SUBMODELS];
42         vms_vector submodel_norms[MAX_SUBMODELS];   // norm for sep plane
43         vms_vector submodel_pnts[MAX_SUBMODELS];    // point on sep plane
44         fix     submodel_rads[MAX_SUBMODELS];       // radius for each submodel
45         ubyte   submodel_parents[MAX_SUBMODELS];    // what is parent for each submodel
46         vms_vector submodel_mins[MAX_SUBMODELS];
47         vms_vector submodel_maxs[MAX_SUBMODELS];
48         vms_vector mins,maxs;                       // min,max for whole model
49         fix     rad;
50         ubyte   n_textures;
51         ushort  first_texture;
52         ubyte   simpler_model;                      // alternate model with less detail (0 if none, model_num+1 else)
53         //vms_vector min,max;
54 } __pack__ polymodel;
55
56 // array of pointers to polygon objects
57 extern polymodel Polygon_models[];
58 extern int D1Share_Polymodel_map[];
59 extern int D1_Polymodel_map[];
60 extern int D2Demo_Polymodel_map[];
61
62 // switch to simpler model when the object has depth
63 // greater than this value times its radius.
64 extern int Simple_model_threshhold_scale;
65
66 // how many polygon objects there are
67 extern int N_polygon_models;
68
69
70 // array of names of currently-loaded models
71 extern char Pof_names[MAX_POLYGON_MODELS][13];
72
73 void init_polygon_models(void);
74
75 #ifndef DRIVE
76 int load_polygon_model(char *filename,int n_textures,int first_texture,robot_info *r);
77 #else
78 int load_polygon_model(char *filename,int n_textures,grs_bitmap ***textures);
79 #endif
80
81 // draw a polygon model
82 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[]);
83
84 // fills in arrays gun_points & gun_dirs, returns the number of guns read
85 int read_model_guns(char *filename,vms_vector *gun_points, vms_vector *gun_dirs, int *gun_submodels);
86
87 // draws the given model in the current canvas.  The distance is set to
88 // more-or-less fill the canvas.  Note that this routine actually renders
89 // into an off-screen canvas that it creates, then copies to the current
90 // canvas.
91 void draw_model_picture(int mn,vms_angvec *orient_angles);
92
93 // free up a model, getting rid of all its memory
94 void free_model(polymodel *po);
95
96 #define MAX_POLYOBJ_TEXTURES 100
97 extern grs_bitmap *texture_list[MAX_POLYOBJ_TEXTURES];
98 extern bitmap_index texture_list_index[MAX_POLYOBJ_TEXTURES];
99 extern g3s_point robot_points[];
100
101 #ifdef FAST_FILE_IO
102 #define polymodel_read(pm, fp) cfread(pm, sizeof(polymodel), 1, fp)
103 #define polymodel_read_n(pm, n, fp) cfread(pm, sizeof(polymodel), n, fp)
104 #else
105 /*
106  * reads a polymodel structure from a CFILE
107  */
108 extern void polymodel_read(polymodel *pm, CFILE *fp);
109
110 /*
111  * reads n polymodel structs from a CFILE
112  */
113 extern int polymodel_read_n(polymodel *pm, int n, CFILE *fp);
114 #endif
115
116 /*
117  * routine which allocates, reads, and inits a polymodel's model_data
118  */
119 void polygon_model_data_read(polymodel *pm, CFILE *fp);
120
121 #endif /* _POLYOBJ_H */