void move_camera () { float x, y, z; // float head_pos[3]; float follow_speed; actor *me = get_our_actor (); if(!me){ return; } x = (float)me->x_pos+0.25f; y = (float)me->y_pos+0.25f; // cal_get_actor_bone_local_position(me, get_actor_bone_id(me, head_bone), NULL, head_pos); /* Schmurk: I've commented this out because I don't see why the position of * the camera should be different from the head position in ext cam and fpv */ /* if (first_person){ */ /* z = (ext_cam?-1.7f:-2.1f) + height_map[me->y_tile_pos*tile_map_size_x*6+me->x_tile_pos]*0.2f + head_pos[2]; */ /* } else if (ext_cam){ */ /* z = -1.6f + height_map[me->y_tile_pos*tile_map_size_x*6+me->x_tile_pos]*0.2f + head_pos[2]; */ if (first_person || ext_cam) { // the camera position corresponds to the head position z = get_tile_height(me->x_tile_pos, me->y_tile_pos); // z += (head_pos[2]+0.1)*get_actor_scale(me); //attachment_props *att_props = get_attachment_props_if_held(me); //z += (me->sitting ? 0.7 : 1.5) * get_actor_scale(me); if (me->attached_actor>=0) z+=me->z_pos + me->attachment_shift[Z]+2.0*get_actor_scale(me); else z += (me->sitting ? 0.7 : 1.5) * get_actor_scale(me); } else { z = get_tile_height(me->x_tile_pos, me->y_tile_pos) + sitting; } if(first_person||ext_cam){ follow_speed = 150.0f; } else { follow_speed = 300.0f; } if(reset_camera_at_next_update){ camera_x = -x; camera_y = -y; camera_z = -z; camera_x_duration=0; camera_y_duration=0; camera_z_duration=0; reset_camera_at_next_update = 0; set_all_intersect_update_needed(main_bbox_tree); } else { //move near the actor, but smoothly camera_x_speed=(x+camera_x)/follow_speed; camera_x_duration=follow_speed; camera_y_speed=(y+camera_y)/follow_speed; camera_y_duration=follow_speed; camera_z_speed=(z+camera_z)/follow_speed; camera_z_duration=follow_speed; } if (first_person){ // glTranslatef(head_pos[0], head_pos[1], 0.0); } else { 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); }
void draw_floatingmessage(floating_message *message, float healthbar_z) { float cut; double f, width, y, x, z; double model[16],proj[16]; int view[4]; if(!message)return; cut=message->active_time/4000.0f; f = ((float)(message->active_time-(cur_time-message->first_time)))/message->active_time; glColor4f(message->color[0], message->color[1], message->color[2], f > cut ? 1.0f : (f / cut)); width = (float)get_string_width((unsigned char*)message->message) * INGAME_FONT_X_LEN * name_zoom * 8.0; //Figure out where the point just above the actor's head is in the viewport glGetDoublev(GL_MODELVIEW_MATRIX, model); glGetDoublev(GL_PROJECTION_MATRIX, proj); glGetIntegerv(GL_VIEWPORT, view); if (first_person) { x=window_width/2.0; y=window_height/2.0-40.0; } else { gluProject(0.0, 0.0, healthbar_z * get_actor_scale(your_actor), model, proj, view, &x, &y, &z); y += 50*name_zoom; // size of the actor name/bar } switch(message->direction){ case FLOATINGMESSAGE_EAST: x+=-width/2.0f-(f*window_width*0.1f); y+=window_height*0.1; break; case FLOATINGMESSAGE_SOUTH: x+=-width/2.0f; y+=f*window_height*0.1; break; case FLOATINGMESSAGE_WEST: x+=-width/2.0f+(f*window_width*0.1f); y+=window_height*0.1; break; case FLOATINGMESSAGE_MIDDLE: x+=-width/2.0f; y+=f*window_height*0.05f; break; case FLOATINGMESSAGE_NORTH: default: x+=-width/2.0f; y+=(1.0-f)*window_height*0.1; break; } glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(view[0],view[2]+view[0],view[1],view[3]+view[1],0.0f,-1.0f); draw_ortho_ingame_string(x, y, 0, (unsigned char*)message->message, 1, INGAME_FONT_X_LEN*8.0, INGAME_FONT_Y_LEN*8.0); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); }