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 #define MAX_CLIENT_ENT_LEAFS 128
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 
47 	double					msgtime;		// time of last update
48 	vec3_t					msg_origins[2];	// last two updates (0 is newest)
49 	vec3_t					origin;
50 	vec3_t					msg_angles[2];	// last two updates (0 is newest)
51 	vec3_t					angles;
52 	struct model_s			*model;			// NULL = no model
53 	struct efrag_s			*efrag;			// linked list of efrags
54 	int						frame;
55 	float					syncbase;		// for client-side animations
56 	byte					*colormap;
57 	int						effects;		// light, particals, etc
58 	int						skinnum;		// for Alias models
59 	int						visframe;		// last frame this entity was
60 											//  found in an active leaf
61 	int						lightTimestamp; //PENTA:
62 
63 	int						dlightframe;	// dynamic lighting
64 	int						dlightbits;
65 
66 // FIXME: could turn these into a union
67 	int						trivial_accept;
68 	struct mnode_s			*topnode;		// for bmodels, first world node
69 											//  that splits bmodel, or NULL if
70 											//  not split
71 	//PENTA
72 	vec3_t	color;
73 	float	alpha;
74 	int		style;
75 	int		light_lev;
76 	int		pflags;
77 
78 
79 	// Animation interpolation (Based on QuakeForge)
80     float                   frame_start_time;
81     float                   frame_interval;
82 	float					blend;
83     int                     pose1;
84     int                     pose2;
85 
86      // frame instant chain
87      struct aliasframeinstant_s *aliasframeinstant;
88      void* brushlightinstant;
89 
90 	//PENTA:
91 	int			numleafs;
92 	short		leafnums[MAX_CLIENT_ENT_LEAFS];
93 
94 	//Erad - t lerp variables
95 	float                   translate_start_time;
96     vec3_t                  origin1;
97     vec3_t                  origin2;
98     float                   rotate_start_time;
99     vec3_t                  angles1;
100     vec3_t                  angles2;
101 
102 } entity_t;
103 
104 // !!! if this is changed, it must be changed in asm_draw.h too !!!
105 typedef struct
106 {
107 	vrect_t		vrect;				// subwindow in video for refresh
108 									// FIXME: not need vrect next field here?
109 	vrect_t		aliasvrect;			// scaled Alias version
110 	int			vrectright, vrectbottom;	// right & bottom screen coords
111 	int			aliasvrectright, aliasvrectbottom;	// scaled Alias versions
112 	float		vrectrightedge;			// rightmost right edge we care about,
113 										//  for use in edge list
114 	float		fvrectx, fvrecty;		// for floating-point compares
115 	float		fvrectx_adj, fvrecty_adj; // left and top edges, for clamping
116 	int			vrect_x_adj_shift20;	// (vrect.x + 0.5 - epsilon) << 20
117 	int			vrectright_adj_shift20;	// (vrectright + 0.5 - epsilon) << 20
118 	float		fvrectright_adj, fvrectbottom_adj;
119 										// right and bottom edges, for clamping
120 	float		fvrectright;			// rightmost edge, for Alias clamping
121 	float		fvrectbottom;			// bottommost edge, for Alias clamping
122 	float		horizontalFieldOfView;	// at Z = 1.0, this many X is visible
123 										// 2.0 = 90 degrees
124 	float		xOrigin;			// should probably allways be 0.5
125 	float		yOrigin;			// between be around 0.3 to 0.5
126 
127 	vec3_t		vieworg;
128 	vec3_t		viewangles;
129 
130 	float		fov_x, fov_y;
131 
132 	int			ambientlight;
133 } refdef_t;
134 
135 
136 //
137 // refresh
138 //
139 extern	int		reinit_surfcache;
140 
141 
142 extern	refdef_t	r_refdef;
143 extern vec3_t	r_origin, vpn, vright, vup;
144 
145 extern	struct texture_s	*r_notexture_mip;
146 
147 
148 void R_Init (void);
149 void R_InitTextures (void);
150 void R_InitEfrags (void);
151 void R_RenderView (void);		// must set r_refdef first
152 void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect);
153 								// called whenever r_refdef or vid change
154 void R_InitSky (struct texture_s *mt);	// called at level load
155 
156 void R_AddEfrags (entity_t *ent);
157 void R_RemoveEfrags (entity_t *ent);
158 
159 void R_NewMap (void);
160 
161 
162 void R_ParseParticleEffect (void);
163 void R_ParseBasicEmitter (void);
164 void R_ParseExtendedEmitter (void);
165 void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
166 void R_RocketTrail (vec3_t start, vec3_t end, int type);
167 
168 #ifdef QUAKE2
169 void R_DarkFieldParticles (entity_t *ent);
170 #endif
171 void R_EntityParticles (entity_t *ent);
172 void R_BlobExplosion (vec3_t org);
173 void R_ParticleExplosion (vec3_t org);
174 void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
175 void R_LavaSplash (vec3_t org);
176 void R_TeleportSplash (vec3_t org);
177 
178 //void R_PushDlights (void); PENTA: Removed
179 
180 
181 //
182 // surface cache related
183 //
184 extern	int		reinit_surfcache;	// if 1, surface cache is currently empty and
185 extern qboolean	r_cache_thrash;	// set if thrashing the surface cache
186 
187 int	D_SurfaceCacheForRes (int width, int height);
188 void D_FlushCaches (void);
189 void D_DeleteSurfaceCache (void);
190 void D_InitCaches (void *buffer, int size);
191 void R_SetVrect (vrect_t *pvrect, vrect_t *pvrectin, int lineadj);
192 
193