| 444 | extern float GetTerrainDynamicScalar(vector *pos, int seg); |
| 445 | extern void GetRoomDynamicScalar(vector *pos, room *rp, float *r, float *g, float *b); |
| 446 | void RenderCockpit() { |
| 447 | object *player_obj = &Objects[Players[Player_num].objnum]; |
| 448 | physics_info *player_phys = &player_obj->mtype.phys_info; |
| 449 | vector view_pos, light_vec; |
| 450 | matrix view_tmat; |
| 451 | float view_z, view_y, view_x, keyframe; |
| 452 | float light_scalar_r, light_scalar_g, light_scalar_b; |
| 453 | float normalized_time[MAX_SUBOBJECTS]; |
| 454 | bool gauge_reset = false; |
| 455 | // draw cockpit depending on current state |
| 456 | if (Cockpit_info.state == COCKPIT_STATE_DORMANT || Cockpit_info.model_num == -1) |
| 457 | return; |
| 458 | // position cockpit correctly. |
| 459 | bsp_info *viewer_subobj = CockpitGetMonitorSubmodel(SOF_VIEWER); |
| 460 | if (!viewer_subobj) { |
| 461 | mprintf(0, "Cockpit missing viewer!\n"); |
| 462 | return; |
| 463 | } |
| 464 | view_z = |
| 465 | viewer_subobj->offset.z - Cockpit_info.buffet_vec.z * Cockpit_info.buffet_amp * Cockpit_info.buffet_wave * 1.1f; |
| 466 | view_y = viewer_subobj->offset.y + Cockpit_info.buffet_vec.y * Cockpit_info.buffet_amp * Cockpit_info.buffet_wave; |
| 467 | view_x = viewer_subobj->offset.x + Cockpit_info.buffet_vec.x * Cockpit_info.buffet_amp * Cockpit_info.buffet_wave; |
| 468 | //@@ if (player_phys->rotthrust.x !=0.0f || player_phys->rotthrust.y != 0.0f) { |
| 469 | //@@ gauge_reset = true; |
| 470 | //@@ view_x += (player_phys->rotthrust.y*COCKPIT_SHIFT_DELTA/player_phys->full_rotthrust); |
| 471 | //@@ view_y -= (player_phys->rotthrust.x*COCKPIT_SHIFT_DELTA/player_phys->full_rotthrust); |
| 472 | //@@ } |
| 473 | // create new orientation, so the cockpit should be facing the viewer |
| 474 | view_tmat = Viewer_object->orient; |
| 475 | view_pos = (view_tmat.fvec * view_z) + (view_tmat.uvec * view_y) + (view_tmat.rvec * view_x) + Viewer_object->pos; |
| 476 | view_tmat.fvec = -view_tmat.fvec; |
| 477 | view_tmat.rvec = -view_tmat.rvec; |
| 478 | // lighting. |
| 479 | light_vec = -Viewer_object->orient.uvec; |
| 480 | if (OBJECT_OUTSIDE(player_obj)) { |
| 481 | float light_scalar = GetTerrainDynamicScalar(&player_obj->pos, CELLNUM(player_obj->roomnum)); |
| 482 | light_scalar_r = light_scalar; |
| 483 | light_scalar_g = light_scalar; |
| 484 | light_scalar_b = light_scalar; |
| 485 | } else { |
| 486 | GetRoomDynamicScalar(&player_obj->pos, &Rooms[player_obj->roomnum], &light_scalar_r, &light_scalar_g, |
| 487 | &light_scalar_b); |
| 488 | } |
| 489 | if (light_scalar_r < 0.1f) |
| 490 | light_scalar_r = 0.1f; |
| 491 | if (light_scalar_g < 0.1f) |
| 492 | light_scalar_g = 0.1f; |
| 493 | if (light_scalar_b < 0.1f) |
| 494 | light_scalar_b = 0.1f; |
| 495 | // Samir, I moved this from the DrawPolygonModel call below -JL |
| 496 | light_scalar_r *= .8f; |
| 497 | light_scalar_g *= .8f; |
| 498 | light_scalar_b *= .8f; |
| 499 | |
| 500 | if (player_obj->effect_info) { |
| 501 | light_scalar_r = std::min(1.0f, light_scalar_r + (player_obj->effect_info->dynamic_red)); |
| 502 | light_scalar_g = std::min(1.0f, light_scalar_g + (player_obj->effect_info->dynamic_green)); |
| 503 | light_scalar_b = std::min(1.0f, light_scalar_b + (player_obj->effect_info->dynamic_blue)); |
no test coverage detected