#include #include #include #include "global.h" #include "draw_scene.h" #include "weather.h" #include "elwindows.h" GLuint paper1_text; char have_display = 0; float camera_x=0; float camera_y=0; float camera_z=0; float old_camera_x=0; float old_camera_y=0; float old_camera_z=0; float c_delta= 0.1f; float rx=-60; float ry=0; float rz=45; float terrain_scale=2.0f; float zoom_level=3.0f; float name_zoom=1.0f; float fine_camera_rotation_speed; float normal_camera_rotation_speed; float camera_rotation_speed; int camera_rotation_frames; float camera_tilt_speed; int camera_tilt_frames; double camera_x_speed; int camera_x_frames; double camera_y_speed; int camera_y_frames; double camera_z_speed; int camera_z_frames; int camera_zoom_dir; int camera_zoom_frames=0; float new_zoom_level=3.0f; float camera_distance = 2.5f; float scene_mouse_x; float scene_mouse_y; int last_texture=-2; int font_text; int cons_text; int icons_text; int login_text; int ground_detail_text; float clouds_movement_u=-8; float clouds_movement_v=-3; Uint32 last_clear_clouds=0; GLenum base_unit=GL_TEXTURE0_ARB,detail_unit=GL_TEXTURE1_ARB,shadow_unit=GL_TEXTURE2_ARB,extra_unit=GL_TEXTURE3_ARB,normal_map_unit=GL_TEXTURE4_ARB; Uint32 draw_delay = 0; void draw_scene() { CHECK_GL_ERRORS(); //clear the clouds cache too... if(last_clear_clouds+10000= 0) // Hack { if (get_show_window (quickbar_win) && windows_list.window[quickbar_win].cur_x < window_width - hud_x && window_height - windows_list.window[quickbar_win].cur_y > hud_y) hide_window (quickbar_win); } } glLoadIdentity (); // Reset The Matrix Enter2DMode (); display_windows (1); // Have to draw the dragged item *after* all windows glColor3f(1.0f,1.0f,1.0f); if (item_dragged != -1) drag_item (item_dragged, 0, 0); else if (use_item != -1 && current_cursor == CURSOR_USE_WITEM) drag_item (use_item, 0, 1); else if (storage_item_dragged != -1) drag_item (storage_item_dragged, 1, 0); Leave2DMode (); if(elwin_mouse >= 0) { if (current_cursor != elwin_mouse) change_cursor(elwin_mouse); elwin_mouse = -1; } SDL_GL_SwapBuffers(); CHECK_GL_ERRORS(); if (draw_delay > 0) { SDL_Delay (draw_delay); draw_delay = 0; } } void get_tmp_actor_data() { int i; LOCK_ACTORS_LISTS(); for(i=0;itmp.x_pos=actors_list[i]->x_pos; actors_list[i]->tmp.y_pos=actors_list[i]->y_pos; actors_list[i]->tmp.z_pos=actors_list[i]->z_pos; actors_list[i]->tmp.x_tile_pos=actors_list[i]->x_tile_pos; actors_list[i]->tmp.y_tile_pos=actors_list[i]->y_tile_pos; actors_list[i]->tmp.x_rot=actors_list[i]->x_rot; actors_list[i]->tmp.y_rot=actors_list[i]->y_rot; actors_list[i]->tmp.z_rot=actors_list[i]->z_rot; actors_list[i]->tmp.have_tmp=1; } } UNLOCK_ACTORS_LISTS(); } void move_camera () { float x, y, z; static int lagged=1; actor * me=pf_get_our_actor(); if(!me || !me->tmp.have_tmp){ lagged=1; return; } x=me->tmp.x_pos+0.25f; y=me->tmp.y_pos+0.25f; z=-2.2f+height_map[me->tmp.y_tile_pos*tile_map_size_x*6+me->tmp.x_tile_pos]*0.2f+sitting; if(lagged){ camera_x-=(x-(-camera_x)); camera_y-=(y-(-camera_y)); camera_z-=(z-(-camera_z)); camera_x_frames=0; camera_y_frames=0; camera_z_frames=0; lagged=0; #ifdef NEW_FRUSTUM set_all_intersect_update_needed(main_bbox_tree); #else regenerate_near_objects= regenerate_near_2d_objects=1; #endif } else { //move near the actor, but smoothly camera_x_speed=(x-(-camera_x))/16.0; camera_x_frames=16; camera_y_speed=(y-(-camera_y))/16.0; camera_y_frames=16; camera_z_speed=(z-(-camera_z))/16.0; camera_z_frames=16; } //check to see if we are out of the map // lachesis: disabled. Not necessary anymore and breaks usability of some maps. /* if(camera_x>-7.5f)camera_x=-7.5f; if(camera_y>-7.5f)camera_y=-7.5f; if(camera_x<-(tile_map_size_x*3-7.9))camera_x=(float)-(tile_map_size_x*3-7.9); if(camera_y<-(tile_map_size_x*3-7.9))camera_y=(float)-(tile_map_size_x*3-7.9); // */ glTranslatef(0.0f, 0.0f, -zoom_level*camera_distance); glRotatef(rx, 1.0f, 0.0f, 0.0f); glRotatef(rz, 0.0f, 0.0f, 1.0f); glTranslatef(camera_x,camera_y, camera_z); // printf("pos=(%f, %f, %f)\n", camera_x, camera_y, camera_z); #ifndef NEW_SOUND //test only update_position(); #endif //NEW_SOUND } void update_camera() { #ifdef NEW_FRUSTUM int adjust_view= 0; #endif if(camera_rotation_frames) { rz+=camera_rotation_speed; if(rz > 360) { rz -= 360; } else if (rz < 0) { rz += 360; } camera_rotation_frames--; #ifdef NEW_FRUSTUM adjust_view++; #else regenerate_near_objects= regenerate_near_2d_objects=1; #endif } if(camera_x_frames) { if(camera_x_speed>0.005 || camera_x_speed<-0.005){ camera_x-=camera_x_speed; #ifdef NEW_FRUSTUM if(fabs(camera_x-old_camera_x) >= c_delta){ adjust_view++; } #else regenerate_near_objects= regenerate_near_2d_objects=1; #endif } camera_x_frames--; } if(camera_y_frames) { if(camera_y_speed>0.0005 || camera_y_speed<-0.005){ camera_y-=camera_y_speed; #ifdef NEW_FRUSTUM if(fabs(camera_y-old_camera_y) >= c_delta){ adjust_view++; } #else regenerate_near_objects= regenerate_near_2d_objects=1; #endif } camera_y_frames--; } if(camera_z_frames) { if(camera_z_speed>0.0005 || camera_z_speed<-0.005){ camera_z-=camera_z_speed; #ifdef PARANOID_CAMERA #ifdef NEW_FRUSTUM if(fabs(camera_z-old_camera_z) >= c_delta){ adjust_view++; } #endif #endif } camera_z_frames--; } if(camera_tilt_frames) { if(camera_tilt_speed<0) { if(rx>-60)rx+=camera_tilt_speed; if(rx<-60) { rx=-60; camera_tilt_frames=0; } else camera_tilt_frames--; } else { if(rx<-45)rx+=camera_tilt_speed; if(rx>-45) { rx=-45; camera_tilt_frames=0; } else camera_tilt_frames--; } } if(camera_zoom_frames) { if(camera_zoom_dir == 1) { if(new_zoom_level<3.75f){ new_zoom_level+=0.05f; camera_zoom_frames--; #ifdef NEW_FRUSTUM adjust_view++; #else regenerate_near_objects= regenerate_near_2d_objects=1; #endif } else camera_zoom_frames = 0; } else { if(new_zoom_level>1.00f){ new_zoom_level-=0.05f; camera_zoom_frames--; #ifdef NEW_FRUSTUM adjust_view++; #else regenerate_near_objects= regenerate_near_2d_objects=1; #endif } else camera_zoom_frames = 0; } } #ifdef NEW_FRUSTUM if(adjust_view){ set_all_intersect_update_needed(main_bbox_tree); old_camera_x= camera_x; old_camera_y= camera_y; old_camera_z= camera_z; } #endif if(zoom_level<1.00f) { new_zoom_level=zoom_level=1.00f; resize_root_window(); } } int update_have_display(window_info * win) { // if the calling window is shown, we have a display, else check all 3d windows have_display = (win->displayed || get_show_window(game_root_win) || get_show_window(newchar_root_win)); return 0; }