altEngine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
types.h
Go to the documentation of this file.
1 #ifndef TYPES_H
2 #define TYPES_H
3 typedef unsigned int uint;
4 
5 
6 #ifndef WIN32
7 #endif
8 
9 typedef enum
10 {
16 } primitive_t;
17 
18 typedef struct
19 {
20  vec3 position; // (x, y, z) position.
21  vec2 texCoord0; // (u, v) texture coordinate
22  vec2 texCoord1; // (u, v) lightmap coordinate
23  vec3 normal; // (x, y, z) normal vector
24  int color; // RGBA color for the vertex
26 } vertex_t;
27 
28 typedef struct
29 {
30  short format;
31  short channels;
34  short align;
35  short sampleSize;
36 } waveFormat_t;
37 
38 typedef struct
39 {
40  char file[LINE_SIZE];
42  void *pcmData;
43  int dataSize;
44  int duration;
45  char *data;
46  int buffer;
47 } wave_t;
48 
49 /*
50  Temporarily saves original entity position
51  that may be restored if integration yields
52  too much interpenetration.
53 */
54 typedef struct
55 {
61 } cfg_t;
62 
63 /*
64  Holds data read in from menu definition files
65 */
66 typedef struct
67 {
68  int state;
69  float position[3];
70  float scale;
71  float color[3];
72  int flag;
74  char msg[LINE_SIZE];
75 } menu_t;
76 
77 /*
78  Holds state transition information for menu definition files
79 */
80 typedef struct
81 {
82  int start;
83  char delta[LINE_SIZE];
84  int end;
85  char cmd[LINE_SIZE];
86 } state_t;
87 
88 
89 
90 
91 
92 // size of fixed part of network packets
93 // length + sequence + ack + num_cmds
94 #define CLIENT_HEADER 45
95 
96 #ifdef LINUX
97 typedef unsigned char byte;
98 #endif
99 
100 /*
101  Variable length client msg
102  after num_cmds is a variable number of key / cmd states
103  after keystate list is a null terminated reliably
104  transmitted msg string that is retransmitted until acked.
105 */
106 typedef struct
107 {
108  unsigned short int length;
109  unsigned short int qport;
110  unsigned short int sequence;
111  unsigned short int server_sequence;
112  float up[3];
113  float forward[3];
114  float pos[3]; // Sending position (not used, but interesting to calculate delta's on server)
115  char num_cmds;
116  unsigned char data[16834];
117 } clientmsg_t;
118 
119 
120 #define SERVER_HEADER 14
121 /*
122  Variable length server msg
123  after num_ents is a variable number of entity states
124  after entity state list is a null terminated reliably
125  transmitted msg string that is retransmitted until acked.
126 */
127 #pragma pack(1)
128 typedef struct
129 {
130  unsigned short int length;
131  unsigned short int compressed_size;
132  unsigned short int sequence;
133  unsigned short int client_sequence;
134  unsigned short int num_ents; // not really neeeded with size, but worth the two bytes info wise
135  unsigned int data_size;
136  unsigned char data[16384];
137 } servermsg_t;
138 #pragma pack(8)
139 
140 typedef struct
141 {
142  unsigned short int sequence;
143  unsigned short int size; // size of entire header + data
144  char msg[2048];
145 } reliablemsg_t;
146 
147 typedef struct
148 {
149  bool attack;
150  bool use;
151  bool zoom;
152  bool jump;
153  bool escape;
154  bool duck;
155  bool control;
156  bool pickup;
157  bool moveup;
158  bool moveleft;
159  bool movedown;
160  bool moveright;
161  bool walk;
162 
163  bool weapon_up;
165 
166  bool scores;
167 } input_t;
168 
169 typedef struct
170 {
172  int ping;
174  int dropped;
175  int num_ents;
176  int size;
178  bool send_full;
181 } netinfo_t;
182 
183 typedef struct
184 {
185  char socketname[32];
186  unsigned int qport;
187  int ent_id;
188  unsigned short int client_sequence;
189  unsigned short int server_sequence;
190  unsigned int last_time;
195 } client_t;
196 
197 
198 //8 units equal 1 foot
199 //sin -1,1
200 //triangle 0,1
201 //square -1,1
202 //sawtooth 0,1,0
203 //inverse 0,1,0
204 //sawtooth 0,1,0
205 //base amp phase frequency
206 
207 typedef struct
208 {
209  char wave[64];
210  float div;
211  float func;
212  float base;
213  float amplitude;
214  float phase;
215  float freq;
216 } deform_t;
217 
218 typedef struct
219 {
220  // char *stage; //raw parser output
221 
222  bool map;
223  char map_tex[128];
224  bool clampmap;
225  char clampmap_tex[128];
226  bool anim_map;
227  char anim_map_tex[512];
229  bool lightmap;
230 
231  bool alpha;
234  bool blendfunc_blend; //source * srccoef + dest * destcoef
251  bool alpha_gt0;
258  float tcmod_rotate_value; // deg/sec
271  bool tcgen_env;
272 
279 
280 } stage_t;
281 
282 
283 // Keeping size small, because there are a lot of these
284 struct surface_t
285 {
286  char file[128];
287  char name[128];
288  // char *cmd[64]; //raw parser output
289  stage_t stage[8]; //looks like it quake3 maxes out at 4, but doing 8
290  unsigned int num_stage;
291 
292  bool nomipmaps;
293  bool nopicmip;
295  bool portal;
296  //sort value 1:portal,2:sky,3:opaque,6:banner,8:underwater,9:additive,16:nearest
324  bool q3map_sun;
325  vec3 q3map_sun_value[2]; //rgb + intensity degrees elevation
327  bool cull_none;
331  bool fog;
335 };
336 
337 
338 // Maps opengl texture object to q3shader index and stage (if available)
339 typedef struct
340 {
341  char name[128];
342  int texObj[MAX_TEXTURES];
343  int texObjAnim[8];
345  int freq;
346  int num_anim;
348  int index; // index into surface list (if it exists)
349  int num_tex;
350  bool portal;
351 } texture_t;
352 
353 typedef struct
354 {
355  char *name;
356  int face;
357  bool shader;
358  bool sky;
359  bool tcmod_rotate[MAX_TEXTURES];
360  bool tcmod_scroll[MAX_TEXTURES];
361  bool tcmod_scale[MAX_TEXTURES];
362  bool tcmod_stretch_sin[MAX_TEXTURES];
363  bool tcmod_stretch_square[MAX_TEXTURES];
364  bool tcmod_stretch_triangle[MAX_TEXTURES];
365  bool tcmod_stretch_sawtooth[MAX_TEXTURES];
366  bool tcmod_stretch_inverse_sawtooth[MAX_TEXTURES];
367  vec4 stretch_value[MAX_TEXTURES];
368  float deg[MAX_TEXTURES];
371  vec2 scroll_value[MAX_TEXTURES]; // integrated with time
372  bool cull_none;
373  bool blend;
391  bool alpha_gt0;
394  bool envmap;
395  bool turb;
396  bool portal;
397  bool alpha;
398 
400  bool rgbgen_wave_sin[MAX_TEXTURES];
401  bool rgbgen_wave_square[MAX_TEXTURES];
402  bool rgbgen_wave_triangle[MAX_TEXTURES];
403  bool rgbgen_wave_sawtooth[MAX_TEXTURES];
404  bool rgbgen_wave_inverse_sawtooth[MAX_TEXTURES];
405  vec4 rgbgen_wave_value[MAX_TEXTURES];
406 
407 
408  bool lightmap[MAX_TEXTURES];
409  unsigned int stage;
410 
411  bool fog;
414 } faceinfo_t;
415 
416 
417 typedef struct
418 {
423 
424  int facevert;
425  unsigned int vbo;
426  unsigned int ibo;
427  int num_mesh;
428 } patch_t;
429 
430 
431 
432 typedef struct
433 {
434  int a;
435  int b;
436  float weight;
437 } graph_arc_t;
438 
439 typedef struct
440 {
441  graph_arc_t arc[8];
442  int num_arcs;
443 } graph_node_t;
444 
445 typedef struct
446 {
447  int x;
448  int y;
449  int z;
450 } ref_t;
451 
452 
453 typedef struct
454 {
455  // must have at least number of nodes (assume we take the longest path possible)
456  int *path;
457  int length;
458  int step;
459 } path_t;
460 
461 typedef struct
462 {
464  char targetname[64];
465  char target[512];
466 } navpoint_t;
467 
468 //Uniform data
469 typedef struct
470 {
476  float size;
477  float life_min;
478  float life_range;
479  float delta_time;
480  int color;
481  unsigned int num;
482  int bsp_leaf;
483  bool visible;
484  bool enabled;
485 } emitter_t;
486 
487 typedef struct
488 {
489  float x;
490  float y;
491  int tex;
492  char filename[128];
493 } icon_t;
494 
495 typedef enum
496 {
501 } gametype_t;
502 
503 
504 typedef enum
505 {
509 } team_t;
510 
511 typedef struct
512 {
513  int drawcall;
514  int triangle;
517 } gpustat_t;
518 
519 
520 typedef struct
521 {
522  int length;
523  int pos;
524 } rletable_t;
525 
526 
527 // I should really just use binary for everything
528 typedef struct
529 {
530  char header[6]; // <data>
531  uint8_t warmup;
532  uint32_t warmup_time;
533  uint32_t round_time;
534  uint8_t fraglimit;
535  uint8_t timelimit;
536  uint8_t red_flag_caps;
537  uint8_t blue_flag_caps;
538  char footer[8]; // </data>
539 } serverdata_t;
540 
541 
542 
543 typedef enum
544 {
547 } rendermode_t;
548 
549 typedef struct
550 {
551  char magic[5];
552  char map[64];
554 
555 typedef struct
556 {
557  char magic[6];
558  int num_ents;
559  int tick_num;
561 
562 #pragma pack(1)
563 typedef struct
564 {
565  char type[2];
567  int reserved;
568  int offset;
569 } bmpheader_t;
570 #pragma pack(8)
571 
572 #pragma pack(1)
573 typedef struct
574 {
575  int size;
576  int width;
577  int height;
578  short planes;
579  short bpp;
582  int xres;
583  int yres;
584  int clr_used;
586 } dib_t;
587 #pragma pack(8)
588 
589 #pragma pack(1)
590 typedef struct
591 {
594 } bitmap_t;
595 #pragma pack(8)
596 
597 typedef enum
598 {
621  ENT_AMMO_CELLS, // ENT_AMMO_PLASMA
656  ENT_FUNC_TIMER, // not visible, keeping seperate
742  ENT_FUNC_TERRAIN // giant OBJ file with texture, need to figure out collision
743 } entity_type_t;
744 
745 // Any dynamically created entity type that should be synced over network
746 // dropped items, muzzle flashes, shells, projectiles etc
747 typedef enum {
773 } net_ent_t;
774 
775 typedef enum
776 {
782 } net_type_t;
783 
784 typedef struct
785 {
786  unsigned short int ctype; // class type [net_type_t]
787  unsigned short int etype; // net entity type [net_ent_t] need to combine with entity_type_t really
788  unsigned short int index; // index into entity_list
789  unsigned short int data_size; // size of data packet below not including header
790  char data[1024]; // data size depends on ctype
791 } net_entity_t;
792 #define SIZE_NET_ENTITY_HEADER 8
793 
794 typedef struct
795 {
796 // matrix3 morientation;
802 } net_rigid_t;
803 
804 typedef struct
805 {
806  uint8_t active; // whether trigger is active
807 } net_trigger_t;
808 
809 typedef struct
810 {
811  uint8_t active;
812  short int owner;
813 
814 // matrix3 morientation;
821 
822 
823 
824 typedef struct
825 {
826 // matrix3 morientation;
833 
834  short int health;
835  unsigned short int armor;
836  unsigned short int current_weapon;
837  unsigned short int ammo_bullets;
838  unsigned short int ammo_shells;
839  unsigned short int ammo_rockets;
840  unsigned short int ammo_lightning;
841  unsigned short int ammo_slugs;
842  unsigned short int ammo_plasma;
843  unsigned short int flight_timer;
844  unsigned short int regen_timer;
845  unsigned short int haste_timer;
846  unsigned short int quad_timer;
847  uint8_t weapon_flags;
848  uint8_t holdable_flags;
849  char name[32];
850 } net_player_t;
851 
852 
853 typedef struct
854 {
855  int index;
856  int count;
859  int loop;
860 
861  vec3 path_list[8];
862  int num_path;
863 } func_path_t;
864 
865 typedef struct
866 {
867  vec3 dState; // Last position input
868  vec3 iState; // Integrator state
869  float iMin, iMax; // min max integrator state
870 
871  float iGain;
872  float pGain;
873  float dGain;
874 } pid_state_t;
875 
876 typedef struct
877 {
879  int vsync;
880  char resolution[64];
881  char window[64];
882  char monitor[128];
883  float rscale;
884  float fov;
885  float sensitivity;
889 
890  char apply[64];
891 
892  char attack[64];
893  char jump[64];
894  char duck[64];
895  char zoom[64];
896  char use[64];
897  char weapnext[64];
898  char weapprev[64];
899  char moveforward[64];
900  char moveback[64];
901  char moveleft[64];
902  char moveright[64];
903  char walk[64];
904  char spectate[64];
905  char console[64];
906  char menu[64];
907  char scores[64];
908 
909  char name[128];
910  char model[128];
911  char skin[128];
912  char team[128];
913 
914  float volume;
915  float musicvol;
916  float sfxvol;
917  float brightness;
918  float contrast;
919 
920  bool ssao;
921  bool bloom;
923  bool shadowvol;
924  bool skyray;
925  bool portal;
926  bool invert;
927 } menudata_t;
928 
929 typedef struct
930 {
931  bool lava;
932  bool slime;
933  bool water;
934  bool fog;
935  int contents;
938 
939 typedef struct
940 {
941  unsigned int rigid0;
942  unsigned int rigid1;
943  unsigned int vertex0;
944  unsigned int vertex1;
945 } body_spring_t;
946 
947 typedef struct
948 {
949  unsigned int rigid0;
950  unsigned int vertex0;
952 } spring_t;
953 
954 typedef struct
955 {
956  float size;
958  int num_col;
959  int num_row;
960  float trilength;
961 } terrain_t;
962 
963 
964 #endif