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