void render_unclipped_3d_terrain_tree_gouraud_textured_diffuse_lit_polygon ( object_3d_face *this_face, struct OBJECT_3D_INFO *object_base ) { texture_map *texture; int count; object_transformed_2d_point *vert, *transformed_points; LPD3DTLVERTEX destination_vertices; object_3d_short_textured_point *texture_list; point_3d_plain_reference *gouraud_list; texture = &system_textures[current_object_3d_surface->texture_index]; transformed_points = transformed_3d_2d_points + object_base->points_base; texture_list = NULL; //current_object_3d_texture_list; gouraud_list = NULL; //current_object_3d_gouraud_list; // // Should draw a gouraud shaded polygon // set_d3d_gouraud_shaded_textured_renderstate ( texture ); // set_d3d_int_state ( D3DRENDERSTATE_TEXTUREMAG, current_object_3d_texture_filter ); // set_d3d_int_state ( D3DRENDERSTATE_TEXTUREMIN, current_object_3d_texture_mipmap ); // set_d3d_int_state ( D3DRENDERSTATE_TEXTUREADDRESS, current_object_3d_texture_address ); destination_vertices = get_d3d_vertices_points_address ( this_face->number_of_points ); for ( count = 0; count < this_face->number_of_points; count++ ) { int ir, ig, ib; float r, g, b; real_colour colour; vert = NULL; //transformed_points + current_object_3d_point_list[count].point; *( ( int * ) &destination_vertices[count].sx ) = *( ( int * ) &vert->i ); *( ( int * ) &destination_vertices[count].sy ) = *( ( int * ) &vert->j ); destination_vertices[count].sz = vert->q; destination_vertices[count].rhw = vert->q; destination_vertices[count].tu = ( ( float ) texture_list->u ) / OBJECT_3D_TEXTURE_UV_SCALE; destination_vertices[count].tv = ( ( float ) texture_list->v ) / OBJECT_3D_TEXTURE_UV_SCALE; r = current_object_3d_transformed_normals[gouraud_list->point].r; g = current_object_3d_transformed_normals[gouraud_list->point].g; b = current_object_3d_transformed_normals[gouraud_list->point].b; convert_float_to_int ( ( r * current_tree_colour_red ), &ir ); convert_float_to_int ( ( g * current_tree_colour_green ), &ig ); convert_float_to_int ( ( b * current_tree_colour_blue ), &ib ); colour.red = ir; colour.green = ig; colour.blue = ib; colour.alpha = current_tree_colour_alpha; destination_vertices[count].color = colour.colour; destination_vertices[count].specular = d3d_fog_intensity; gouraud_list++; texture_list++; } draw_fan_primitive ( this_face->number_of_points, destination_vertices ); }
void draw_temporary_translucent_polygons ( void ) { int vertex_index, count; // // No need to set the default blending mode, as each buffered polygon will set it itself // vertex_index = 0; set_d3d_int_state ( D3DRENDERSTATE_SHADEMODE, D3DSHADE_GOURAUD ); // // Flush any buffered vertex buffers // finalise_primitives (); for ( count = 0; count < number_of_temporary_polygons; count++ ) { LPD3DTLVERTEX vertices; set_d3d_int_state ( D3DRENDERSTATE_SRCBLEND, temporary_polygons[count].source_alpha_blend ); set_d3d_int_state ( D3DRENDERSTATE_DESTBLEND, temporary_polygons[count].destination_alpha_blend ); if ( temporary_polygons[count].texture ) { set_d3d_texture ( 0, load_hardware_texture_map ( temporary_polygons[count].texture ) ); set_d3d_texture_stage_state ( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); set_d3d_texture_stage_state ( 0, D3DTSS_ADDRESSU, temporary_polygons[count].texture_u_address ); set_d3d_texture_stage_state ( 0, D3DTSS_ADDRESSV, temporary_polygons[count].texture_v_address ); set_d3d_texture_stage_state ( 0, D3DTSS_MAGFILTER, temporary_polygons[count].texture_mag ); set_d3d_texture_stage_state ( 0, D3DTSS_MINFILTER, temporary_polygons[count].texture_mag ); set_d3d_texture_stage_state ( 0, D3DTSS_MIPFILTER, temporary_polygons[count].texture_min ); } else { set_d3d_texture_stage_state ( 0, D3DTSS_COLOROP, D3DTOP_DISABLE ); set_d3d_texture ( 0, NULL ); } if ( temporary_polygons[count].number_of_vertices > 2 ) { vertices = get_d3d_vertices_points_address ( temporary_polygons[count].number_of_vertices ); memcpy ( vertices, &temporary_vertices[vertex_index], sizeof ( D3DTLVERTEX ) * temporary_polygons[count].number_of_vertices ); draw_fan_primitive ( temporary_polygons[count].number_of_vertices, vertices ); } else { vertices = get_d3d_line_vertices_points_address (); memcpy ( vertices, &temporary_vertices[vertex_index], sizeof ( D3DTLVERTEX ) * 2 ); draw_line_primitive ( vertices ); } vertex_index += temporary_polygons[count].number_of_vertices; } }
void render_unclipped_3d_terrain_tree_textured_diffuse_lit_polygon ( object_3d_face *this_face, struct OBJECT_3D_INFO *object_base ) { texture_map *texture; real_colour colour; int ired, igreen, iblue, count; float red, green, blue; object_transformed_2d_point *vert, *transformed_points; LPD3DTLVERTEX destination_vertices; object_3d_short_textured_point *texture_list; texture = &system_textures[current_object_3d_surface->texture_index]; // // Look up the colour of the face normal // red = current_object_3d_transformed_normals[current_object_3d_face_normal_list->point].r; green = current_object_3d_transformed_normals[current_object_3d_face_normal_list->point].g; blue = current_object_3d_transformed_normals[current_object_3d_face_normal_list->point].b; red *= current_tree_colour_red; green *= current_tree_colour_green; blue *= current_tree_colour_blue; convert_float_to_int ( red, &ired ); convert_float_to_int ( green, &igreen ); convert_float_to_int ( blue, &iblue ); colour.red = ired; colour.green = igreen; colour.blue = iblue; colour.alpha = current_tree_colour_alpha; // set_d3d_int_state ( D3DRENDERSTATE_TEXTUREMAG, current_object_3d_texture_filter ); // set_d3d_int_state ( D3DRENDERSTATE_TEXTUREMIN, current_object_3d_texture_mipmap ); // set_d3d_int_state ( D3DRENDERSTATE_TEXTUREADDRESS, current_object_3d_texture_address ); // // Should draw a flat shaded polygon // set_d3d_flat_shaded_textured_renderstate ( texture ); transformed_points = transformed_3d_2d_points + object_base->points_base; destination_vertices = get_d3d_vertices_points_address ( this_face->number_of_points ); texture_list = NULL; //current_object_3d_texture_list; for ( count = 0; count < this_face->number_of_points; count++ ) { vert = NULL; //transformed_points + current_object_3d_point_list[count].point; *( ( int * ) &destination_vertices[count].sx ) = *( ( int * ) &vert->i ); *( ( int * ) &destination_vertices[count].sy ) = *( ( int * ) &vert->j ); destination_vertices[count].sz = vert->q; destination_vertices[count].rhw = vert->q; destination_vertices[count].tu = ( ( float ) texture_list->u ) / OBJECT_3D_TEXTURE_UV_SCALE; destination_vertices[count].tv = ( ( float ) texture_list->v ) / OBJECT_3D_TEXTURE_UV_SCALE; destination_vertices[count].color = colour.colour; destination_vertices[count].specular = d3d_fog_intensity; texture_list++; } draw_fan_primitive ( this_face->number_of_points, destination_vertices ); }