1 #ifndef __RENDER_H
2 #define __RENDER_H
3 
4 /*
5 RENDER.H
6 
7 	Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
8 	and the "Aleph One" developers.
9 
10 	This program is free software; you can redistribute it and/or modify
11 	it under the terms of the GNU General Public License as published by
12 	the Free Software Foundation; either version 3 of the License, or
13 	(at your option) any later version.
14 
15 	This program is distributed in the hope that it will be useful,
16 	but WITHOUT ANY WARRANTY; without even the implied warranty of
17 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 	GNU General Public License for more details.
19 
20 	This license is contained in the file "COPYING",
21 	which is included with this source code; it is available online at
22 	http://www.gnu.org/licenses/gpl.html
23 
24 Thursday, September 8, 1994 5:40:59 PM  (Jason)
25 
26 Feb 18, 2000 (Loren Petrich):
27 	Added "show_weapons_in_hand" to "view_data", so as to have support third-person
28 	as well as first-person view
29 
30 Feb 25, 2000 (Loren Petrich):
31 	Added support for tunnel-vision mode (sniper mode);
32 	this includes "tunnel_vision_active" in "view_data"
33 
34 May 22, 2000 (Loren Petrich):
35 	Moved field-of-view definitions into ViewControl.c;
36 	using accessors to that file to get field-of-view parameters
37 
38 Nov 12, 2000 (Loren Petrich):
39 	Added automap reset function
40 */
41 
42 #include "world.h"
43 #include "textures.h"
44 #include "scottish_textures.h"
45 // Stuff to control the view
46 #include "ViewControl.h"
47 
48 /* ---------- constants */
49 
50 /* the distance behind which we are not required to draw objects */
51 #define MINIMUM_OBJECT_DISTANCE ((short)(WORLD_ONE/20))
52 
53 // LP change: suppressed going/leaving states, because of alternative way of
54 // adjusting the FOV.
55 enum /* render effects */
56 {
57 	_render_effect_fold_in,
58 	_render_effect_fold_out,
59 	// _render_effect_going_fisheye,
60 	// _render_effect_leaving_fisheye,
61 	_render_effect_explosion,
62 	// LP additions:
63 	// _render_effect_going_tunnel,
64 	// _render_effect_leaving_tunnel
65 };
66 
67 enum /* shading tables */
68 {
69 	_shading_normal, /* to black */
70 	_shading_infravision /* false color */
71 };
72 
73 // LP change: using accessors instead
74 #define TUNNEL_VISION_FIELD_OF_VIEW View_FOV_TunnelVision()
75 #define NORMAL_FIELD_OF_VIEW View_FOV_Normal()
76 #define EXTRAVISION_FIELD_OF_VIEW View_FOV_ExtraVision()
77 
78 
79 /* ---------- structures */
80 
81 struct definition_header
82 {
83 	short tag;
84 	short clip_left, clip_right;
85 };
86 
87 struct view_data
88 {
89 	// LP change: specifying current and target field-of-view as floats;
90 	// one changes the field of view by setting a new target then adjusting
91 	// the current FOV toward it
92 	float field_of_view;
93 	float target_field_of_view;
94 	short standard_screen_width; /* this is *not* the width of the projected image (see initialize_view_data() in RENDER.C */
95 	short screen_width, screen_height; /* dimensions of the projected image */
96 	short horizontal_scale, vertical_scale;
97 
98 	short half_screen_width, half_screen_height;
99 	short world_to_screen_x, world_to_screen_y;
100 	short dtanpitch; /* world_to_screen*tan(pitch) */
101 	angle half_cone; /* often ==field_of_view/2 (when screen_width==standard_screen_width) */
102 	angle half_vertical_cone;
103 
104 	world_vector2d untransformed_left_edge, untransformed_right_edge;
105 	world_vector2d left_edge, right_edge, top_edge, bottom_edge;
106 
107 	short ticks_elapsed;
108 	uint32 tick_count; /* for effects and transfer modes */
109 	short origin_polygon_index;
110 	angle yaw, pitch, roll;
111 	fixed_angle virtual_yaw, virtual_pitch;
112 	world_point3d origin;
113 	_fixed maximum_depth_intensity; /* in fixed units */
114 
115 	short shading_mode;
116 
117 	short effect, effect_phase;
118 	short real_world_to_screen_x, real_world_to_screen_y;
119 
120 	bool overhead_map_active;
121 	short overhead_map_scale;
122 
123 	bool under_media_boundary;
124 	short under_media_index;
125 
126 	bool terminal_mode_active;
127 
128 	// LP addition: this indicates whether to show weapons-in-hand display;
129 	// this is on in first-person, off in third-person
130 	bool show_weapons_in_hand;
131 
132 	// LP: Indicates whether or not tunnel vision is active
133 	bool tunnel_vision_active;
134 
135 	// LP addition: value of yaw used by landscapes; this is so that the center
136 	// can stay stationary
137 	angle landscape_yaw;
138 
139 	// whether to mimic software renderer when looking up/down
140 	bool mimic_sw_perspective;
141 };
142 
143 /* ---------- render flags */
144 
145 #define TEST_STATE_FLAG(i,f) TEST_RENDER_FLAG(i,f)
146 #define SET_STATE_FLAG(i,f,v) SET_RENDER_FLAG(i,f)
147 
148 #define TEST_RENDER_FLAG(index, flag) (render_flags[index]&(flag))
149 #define SET_RENDER_FLAG(index, flag) render_flags[index]|= (flag)
150 
151 #define RENDER_FLAGS_BUFFER_SIZE MAX(MAX(MAXIMUM_ENDPOINTS_PER_MAP,MAXIMUM_LINES_PER_MAP),MAX(MAXIMUM_SIDES_PER_MAP,MAXIMUM_POLYGONS_PER_MAP))
152 //#define RENDER_FLAGS_BUFFER_SIZE (8*KILO)
153 enum /* render flags */
154 {
155 	_polygon_is_visible_bit, /* some part of this polygon is horizontally in the view cone */
156 	_endpoint_has_been_visited_bit, /* we�ve already tried to cast a ray out at this endpoint */
157 	_endpoint_is_visible_bit, /* this endpoint is horizontally in the view cone */
158 	_side_is_visible_bit, /* this side was crossed while building the tree and should be drawn */
159 	_line_has_clip_data_bit, /* this line has a valid clip entry */
160 	_endpoint_has_clip_data_bit, /* this endpoint has a valid clip entry */
161 	_endpoint_has_been_transformed_bit, /* this endpoint has been transformed into screen-space */
162 	NUMBER_OF_RENDER_FLAGS, /* should be <=16 */
163 
164 	_polygon_is_visible= 1<<_polygon_is_visible_bit,
165 	_endpoint_has_been_visited= 1<<_endpoint_has_been_visited_bit,
166 	_endpoint_is_visible= 1<<_endpoint_is_visible_bit,
167 	_side_is_visible= 1<<_side_is_visible_bit,
168 	_line_has_clip_data= 1<<_line_has_clip_data_bit,
169 	_endpoint_has_clip_data= 1<<_endpoint_has_clip_data_bit,
170 	_endpoint_has_been_transformed= 1<<_endpoint_has_been_transformed_bit
171 };
172 
173 /* ---------- globals */
174 
175 extern vector<uint16> RenderFlagList;
176 #define render_flags (RenderFlagList.data())
177 
178 // extern uint16 *render_flags;
179 
180 /* ---------- prototypes/RENDER.C */
181 
182 void allocate_render_memory(void);
183 
184 void initialize_view_data(struct view_data *view, bool ignore_preferences = false);
185 void render_view(struct view_data *view, struct bitmap_definition *destination);
186 
187 void start_render_effect(struct view_data *view, short effect);
188 
189 void check_m1_exploration(void);
190 
191 
192 /* ----------- prototypes/SCREEN.C */
193 void render_overhead_map(struct view_data *view);
194 void render_computer_interface(struct view_data *view);
195 
196 // LP: definitions moved up here because they are referred to
197 // outside of render.c, where they are defined.
198 
199 void instantiate_rectangle_transfer_mode(view_data *view,
200 	rectangle_definition *rectangle, short transfer_mode, _fixed transfer_phase);
201 
202 void instantiate_polygon_transfer_mode(view_data *view,
203 	polygon_definition *polygon, short transfer_mode, bool horizontal);
204 
205 
206 // In overhead_map.cpp:
207 
208 void ResetOverheadMap();
209 
210 #endif
211