Draws an overlay polygon over the existing polygon
| 2070 | |
| 2071 | // Draws an overlay polygon over the existing polygon |
| 2072 | void d3d_DrawMultiTexturePolygon(g3Point **p, int nv, int handle, int map_type) { |
| 2073 | HRESULT ddrval; |
| 2074 | |
| 2075 | int alpha = Alpha_multiplier * d3d_Alpha_factor; |
| 2076 | float one_over_square_res = 1.0 / GameLightmaps[Overlay_map].square_res; |
| 2077 | float one_over_cur_far_z = 1.0 / D3D_state.cur_far_z; |
| 2078 | |
| 2079 | float xscalar = (float)GameLightmaps[Overlay_map].width * one_over_square_res; |
| 2080 | float yscalar = (float)GameLightmaps[Overlay_map].height * one_over_square_res; |
| 2081 | |
| 2082 | float lmdiff = (1.0 / GameLightmaps[Overlay_map].square_res) / 2.0; |
| 2083 | |
| 2084 | for (int i = 0; i < nv; i++) { |
| 2085 | int r, g, b; |
| 2086 | |
| 2087 | g3Point *pnt = p[i]; |
| 2088 | MultiTextureVertex *tvert = &MTVerts[i]; |
| 2089 | |
| 2090 | tvert->x = pnt->p3_sx + D3D_state.clip_x1; |
| 2091 | tvert->y = pnt->p3_sy + D3D_state.clip_y1; |
| 2092 | tvert->z = std::max(0, 1.0 - (1.0 / (pnt->p3_z + (Z_bias + d3d_WBias)))); |
| 2093 | tvert->w = 1.0 / (pnt->p3_z + Z_bias + d3d_WBias); |
| 2094 | |
| 2095 | tvert->u1 = pnt->p3_u + UV_diff; |
| 2096 | tvert->v1 = pnt->p3_v + UV_diff; |
| 2097 | |
| 2098 | tvert->u2 = (pnt->p3_u2 * xscalar) + lmdiff; |
| 2099 | tvert->v2 = (pnt->p3_v2 * yscalar) + lmdiff; |
| 2100 | |
| 2101 | if (D3D_state.cur_alpha_type & ATF_VERTEX) |
| 2102 | alpha = (pnt->p3_a * (float)Alpha_multiplier * d3d_Alpha_factor); |
| 2103 | |
| 2104 | if (D3D_state.cur_fog_state) { |
| 2105 | |
| 2106 | float fog; |
| 2107 | DWORD fogval; |
| 2108 | |
| 2109 | if (pnt->p3_z < D3D_state.cur_fog_start) |
| 2110 | fogval = 255; |
| 2111 | else if (pnt->p3_z > D3D_state.cur_fog_end) |
| 2112 | fogval = 0; |
| 2113 | else { |
| 2114 | float val = pnt->p3_z - D3D_state.cur_fog_start; |
| 2115 | fog = val / d3d_FogDiff; |
| 2116 | fogval = ((1 - fog) * 255.0); |
| 2117 | } |
| 2118 | |
| 2119 | tvert->specular = (fogval << 24); |
| 2120 | } |
| 2121 | |
| 2122 | if (D3D_state.cur_light_state != LS_NONE) { |
| 2123 | // Do lighting based on intesity (MONO) or colored (RGB) |
| 2124 | if (D3D_state.cur_color_model == CM_MONO) { |
| 2125 | r = pnt->p3_l * 255.0; |
| 2126 | g = pnt->p3_l * 255.0; |
| 2127 | b = pnt->p3_l * 255.0; |
| 2128 | } else { |
| 2129 | if (D3D_state.cur_light_state == LS_FLAT_GOURAUD) { |
no test coverage detected