optimized AngleVectors calls (pass NULL for vectors that should not be generated)
[divverent/darkplaces.git] / render.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 // refresh.h -- public interface to refresh functions
22
23 #define MAXCLIPPLANES   11
24
25 #define TOP_RANGE               16                      // soldier uniform colors
26 #define BOTTOM_RANGE    96
27
28 //=============================================================================
29
30 typedef struct efrag_s
31 {
32         struct mleaf_s          *leaf;
33         struct efrag_s          *leafnext;
34         struct entity_s         *entity;
35         struct efrag_s          *entnext;
36 } efrag_t;
37
38
39 typedef struct entity_s
40 {
41         qboolean                                forcelink;              // model changed
42
43         int                                             update_type;
44
45         entity_state_t                  baseline;               // to fill in defaults in updates
46         entity_state_t                  deltabaseline;  // LordHavoc: previous frame
47
48         double                                  msgtime;                // time of last update
49         vec3_t                                  msg_origins[2]; // last two updates (0 is newest)       
50         vec3_t                                  origin;
51         vec3_t                                  msg_angles[2];  // last two updates (0 is newest)
52         vec3_t                                  angles; 
53
54         // LordHavoc: added support for alpha transprency and other effects
55         float                                   alpha;                  // opacity (alpha) of the model
56         float                                   colormod[3];    // color tint for model
57         float                                   scale;                  // size the model is shown
58         float                                   trail_time;
59         float                                   glowsize;               // how big the glow is
60         byte                                    glowcolor;              // color of glow and particle trail (paletted)
61         byte                                    glowtrail;              // leaves a trail of particles
62         byte                                    isviewmodel;    // attached to view
63
64         struct model_s                  *model;                 // NULL = no model
65         struct efrag_s                  *efrag;                 // linked list of efrags
66         int                                             frame;                  // current desired frame (usually identical to frame2, but frame2 is not always used)
67         struct model_s                  *lerp_model;    // lerp resets when model changes
68         float                                   lerp_starttime; // start of this transition
69         int                                             frame1;                 // frame that the model is interpolating from
70         int                                             frame2;                 // frame that the model is interpolating to
71         double                                  framelerp;              // interpolation factor, usually computed from lerp_starttime
72         double                                  frame1start;    // time frame1 began playing (for framegroup animations)
73         double                                  frame2start;    // time frame2 began playing (for framegroup animations)
74         float                                   syncbase;               // for client-side animations
75         int                                             colormap;
76         int                                             effects;                // light, particles, etc
77         int                                             skinnum;                // for Alias models
78         int                                             visframe;               // last frame this entity was
79                                                                                         //  found in an active leaf
80                                                                                         
81         int                                             dlightframe;    // dynamic lighting
82         int                                             dlightbits[8];
83         
84 // FIXME: could turn these into a union
85         int                                             trivial_accept;
86         struct mnode_s                  *topnode;               // for bmodels, first world node
87                                                                                         //  that splits bmodel, or NULL if
88                                                                                         //  not split
89 } entity_t;
90
91 // !!! if this is changed, it must be changed in asm_draw.h too !!!
92 typedef struct
93 {
94         vrect_t         vrect;                          // subwindow in video for refresh
95                                                                         // FIXME: not need vrect next field here?
96         /*
97         vrect_t         aliasvrect;                     // scaled Alias version
98         int                     vrectright, vrectbottom;        // right & bottom screen coords
99         int                     aliasvrectright, aliasvrectbottom;      // scaled Alias versions
100         float           vrectrightedge;                 // rightmost right edge we care about,
101                                                                                 //  for use in edge list
102         float           fvrectx, fvrecty;               // for floating-point compares
103         float           fvrectx_adj, fvrecty_adj; // left and top edges, for clamping
104         int                     vrect_x_adj_shift20;    // (vrect.x + 0.5 - epsilon) << 20
105         int                     vrectright_adj_shift20; // (vrectright + 0.5 - epsilon) << 20
106         float           fvrectright_adj, fvrectbottom_adj;
107                                                                                 // right and bottom edges, for clamping
108         float           fvrectright;                    // rightmost edge, for Alias clamping
109         float           fvrectbottom;                   // bottommost edge, for Alias clamping
110         float           horizontalFieldOfView;  // at Z = 1.0, this many X is visible 
111                                                                                 // 2.0 = 90 degrees
112         float           xOrigin;                        // should probably always be 0.5
113         float           yOrigin;                        // between be around 0.3 to 0.5
114         */
115
116         vec3_t          vieworg;
117         vec3_t          viewangles;
118         
119         float           fov_x, fov_y;
120
121 //      int                     ambientlight;
122 } refdef_t;
123
124
125 //
126 // refresh
127 //
128
129
130 extern  refdef_t        r_refdef;
131 extern vec3_t   r_origin, vpn, vright, vup;
132
133 extern  struct texture_s        *r_notexture_mip;
134
135 void R_Init (void);
136 void R_InitTextures (void);
137 void R_InitEfrags (void);
138 void R_RenderView (void);               // must set r_refdef first
139 void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect);
140                                                                 // called whenever r_refdef or vid change
141 // LordHavoc: changed this for sake of GLQuake
142 void R_InitSky (byte *src, int bytesperpixel);  // called at level load
143 //void R_InitSky (struct texture_s *mt);        // called at level load
144
145 void R_AddEfrags (entity_t *ent);
146 void R_RemoveEfrags (entity_t *ent);
147
148 void R_NewMap (void);
149
150
151 void R_ParseParticleEffect (void);
152 void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
153 void R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
154 void R_RocketTrail2 (vec3_t start, vec3_t end, int type, entity_t *ent);
155 void R_SparkShower (vec3_t org, vec3_t dir, int count);
156 void R_BloodPuff (vec3_t org, vec3_t vel, int count);
157 void R_FlameCube (vec3_t mins, vec3_t maxs, int count);
158 void R_Flames (vec3_t org, vec3_t vel, int count);
159
160 void R_EntityParticles (entity_t *ent);
161 void R_BlobExplosion (vec3_t org);
162 void R_ParticleExplosion (vec3_t org, int smoke);
163 void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
164 void R_LavaSplash (vec3_t org);
165 void R_TeleportSplash (vec3_t org);
166
167 void R_NewExplosion(vec3_t org);
168
169 void R_PushDlights (void);
170 void R_DrawWorld (void);
171 //void R_RenderDlights (void);
172 void R_DrawParticles (void);
173 void R_MoveParticles (void);
174 void R_DrawExplosions (void);
175 void R_MoveExplosions (void);