1 #ifndef _RENDER_RASTERIZER_CLASS_ 2 #define _RENDER_RASTERIZER_CLASS_ 3 /* 4 5 Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc. 6 and the "Aleph One" developers. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 3 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 This license is contained in the file "COPYING", 19 which is included with this source code; it is available online at 20 http://www.gnu.org/licenses/gpl.html 21 22 Rendering Clipping/Rasterization Class 23 by Loren Petrich, 24 August 7, 2000 25 26 Defines a class for doing rasterization from the prepared lists of objects; from render.c 27 28 Made [view_data *view] a member and removed it as an argument 29 Doing the setup and rasterization of each object through a RasterizerClass object 30 Also removed [bitmap_definition *destination] as superfluous, 31 now that there is a special rasterizer object that can contain it. 32 33 Oct 13, 2000 34 LP: replaced ResizableList with STL vector class 35 */ 36 37 #include <vector> 38 #include "world.h" 39 #include "render.h" 40 #include "RenderSortPoly.h" 41 #include "RenderPlaceObjs.h" 42 #include "Rasterizer.h" 43 44 45 /* ---------- flagged world points */ 46 47 struct flagged_world_point2d /* for floors */ 48 { 49 // LP change: made this more long-distance friendly 50 int32 x, y; 51 uint16 flags; /* _clip_left, _clip_right, _clip_top, _clip_bottom are valid */ 52 }; 53 54 struct flagged_world_point3d /* for ceilings */ 55 { 56 // LP change: made this more long-distance friendly 57 int32 x, y; 58 world_distance z; 59 uint16 flags; /* _clip_left, _clip_right, _clip_top, _clip_bottom are valid */ 60 }; 61 62 63 /* ---------- vertical surface definition */ 64 65 /* it�s not worth putting this into the side_data structure, although the transfer mode should 66 be in the side_texture_definition structure */ 67 struct vertical_surface_data 68 { 69 short lightsource_index; 70 _fixed ambient_delta; /* a delta to the lightsource�s intensity, then pinned to [0,FIXED_ONE] */ 71 72 world_distance length; 73 world_distance h0, h1, hmax; /* h0<h1; hmax<=h1 and is the height where this wall side meets the ceiling */ 74 // LP change: made this more long-distance friendly 75 long_vector2d p0, p1; /* will transform into left, right points on the screen (respectively) */ 76 77 struct side_texture_definition *texture_definition; 78 short transfer_mode; 79 }; 80 81 typedef enum { 82 kDiffuse, 83 kGlow 84 } RenderStep; 85 86 class RenderRasterizerClass 87 { 88 protected: 89 // Auxiliary data and routines: 90 virtual void render_tree(RenderStep renderStep); 91 virtual void render_node(sorted_node_data *node, bool SeeThruLiquids, RenderStep renderStep); 92 virtual void store_endpoint(endpoint_data *endpoint, long_vector2d& p); 93 94 // LP change: indicate whether the void is present on one side; 95 // useful for suppressing semitransparency to the void 96 virtual void render_node_floor_or_ceiling( 97 clipping_window_data *window, polygon_data *polygon, horizontal_surface_data *surface, 98 bool void_present, bool ceil, RenderStep renderStep); 99 virtual void render_node_side( 100 clipping_window_data *window, vertical_surface_data *surface, 101 bool void_present, RenderStep renderStep); 102 103 // LP change: add "other side of media" flag, to indicate that the sprite will be rendered 104 // on the opposite side of the liquid surface from the viewpoint, instead of the same side. 105 virtual void render_node_object( 106 render_object_data *object, bool other_side_of_media, RenderStep renderStep); 107 108 // LP changes for better long-distance support 109 110 short xy_clip_horizontal_polygon(flagged_world_point2d *vertices, short vertex_count, 111 long_vector2d *line, uint16 flag); 112 113 void xy_clip_flagged_world_points(flagged_world_point2d *p0, flagged_world_point2d *p1, 114 flagged_world_point2d *clipped, long_vector2d *line); 115 116 short z_clip_horizontal_polygon(flagged_world_point2d *vertices, short vertex_count, 117 long_vector2d *line, world_distance height, uint16 flag); 118 119 void z_clip_flagged_world_points(flagged_world_point2d *p0, flagged_world_point2d *p1, 120 world_distance height, flagged_world_point2d *clipped, long_vector2d *line); 121 122 short xz_clip_vertical_polygon(flagged_world_point3d *vertices, short vertex_count, 123 long_vector2d *line, uint16 flag); 124 125 void xz_clip_flagged_world_points(flagged_world_point3d *p0, flagged_world_point3d *p1, 126 flagged_world_point3d *clipped, long_vector2d *line); 127 128 short xy_clip_line(flagged_world_point2d *posts, short vertex_count, 129 long_vector2d *line, uint16 flag); 130 131 public: 132 133 // Pointers to view and sorted polygons 134 view_data *view; 135 RenderSortPolyClass *RSPtr; 136 RasterizerClass *RasPtr; 137 138 virtual void render_tree(); 139 renders_viewer_sprites_in_tree()140 virtual bool renders_viewer_sprites_in_tree() { return false; } 141 142 // Inits everything 143 RenderRasterizerClass(); 144 }; 145 146 147 #endif 148