void get_ah64a_eo_centred_viewpoint (viewpoint *vp) { entity *source; object_3d_instance *inst3d; object_3d_sub_object_search_data search; ASSERT (vp); source = get_gunship_entity (); inst3d = (object_3d_instance *) get_local_entity_ptr_value (source, PTR_TYPE_INSTANCE_3D_OBJECT); ASSERT (inst3d); get_local_entity_vec3d (source, VEC3D_TYPE_POSITION, &inst3d->vp.position); get_local_entity_attitude_matrix (source, inst3d->vp.attitude); search.search_depth = 0; search.search_object = inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_AH64D_TADS_HEADING; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { get_3d_sub_object_world_viewpoint (search.result_sub_object, vp); } else { // // can happpen if the object is being destroyed // memcpy (&vp->position, &inst3d->vp.position, sizeof (vec3d)); debug_log ("OBJECT_3D_SUB_OBJECT_AH64D_TADS_HEADING missing from Apache"); } memcpy (&vp->attitude, &inst3d->vp.attitude, sizeof (matrix3x3)); }
void get_kiowa_crew_viewpoint (void) { object_3d_sub_object_search_data search_head, search_viewpoint; viewpoint vp; float head_pitch_datum; // // select head // if (get_local_entity_int_value (get_pilot_entity (), INT_TYPE_CREW_ROLE) == CREW_ROLE_PILOT) { search_head.sub_object_index = OBJECT_3D_SUB_OBJECT_PILOT_HEAD; search_viewpoint.sub_object_index = OBJECT_3D_SUB_OBJECT_PILOT_VIEWPOINT; head_pitch_datum = pilot_head_pitch_datum; } else { search_head.sub_object_index = OBJECT_3D_SUB_OBJECT_WSO_HEAD; search_viewpoint.sub_object_index = OBJECT_3D_SUB_OBJECT_WSO_VIEWPOINT; head_pitch_datum = co_pilot_head_pitch_datum; } // // rotate head // search_head.search_depth = 0; search_head.search_object = virtual_cockpit_inst3d; if (find_object_3d_sub_object (&search_head) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search_head.result_sub_object->relative_heading = -pilot_head_heading; search_head.result_sub_object->relative_pitch = head_pitch_datum - pilot_head_pitch; if ((command_line_TIR_6DOF == TRUE)&&(query_TIR_active() == TRUE)) // Retro 6Feb2005 search_head.result_sub_object->relative_roll = TIR_GetRoll() / 16383. * PI / 2.; // Retro 6Feb2005 else search_head.result_sub_object->relative_roll = 0.0; } else { debug_fatal ("Failed to locate crew's head in virtual cockpit"); } // // get viewpoint (avoid jitter) // search_viewpoint.search_object = virtual_cockpit_inst3d; search_viewpoint.search_depth = 0; if (find_object_3d_sub_object (&search_viewpoint) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { virtual_cockpit_inst3d->vp.x = 0.0; virtual_cockpit_inst3d->vp.y = 0.0; virtual_cockpit_inst3d->vp.z = 0.0; get_local_entity_attitude_matrix (get_gunship_entity (), virtual_cockpit_inst3d->vp.attitude); get_3d_sub_object_world_viewpoint (search_viewpoint.result_sub_object, &vp); get_local_entity_vec3d (get_gunship_entity (), VEC3D_TYPE_POSITION, &pilot_head_vp.position); pilot_head_vp.x += vp.x; pilot_head_vp.y += vp.y; pilot_head_vp.z += vp.z; if ((command_line_TIR_6DOF == TRUE)&&(query_TIR_active() == TRUE)) // Retro 6Feb2005 (whole block) { matrix3x3 invAttitude; vec3d shiftVP, shiftWorld; // First lets find out the displacement the user wants.. this is in the user's viewsystem coords !! // Now store this info in a temp vect3d.. shiftVP.x = current_custom_cockpit_viewpoint.x; shiftVP.y = current_custom_cockpit_viewpoint.y; shiftVP.z = current_custom_cockpit_viewpoint.z; // Now we need to convert our vec3d into world coords.. for this we need the inverse of the viewpoint attitude matrix.. get_inverse_matrix (invAttitude, vp.attitude); // And rotate ! Voila, the result vec3d is now in world coords.. multiply_transpose_matrix3x3_vec3d (&shiftWorld, invAttitude, &shiftVP); // Now apply that displacement.. BUT ONLY TO THE HEAD !! pilot_head_vp.x -= shiftWorld.x; pilot_head_vp.y -= shiftWorld.y; pilot_head_vp.z -= shiftWorld.z; } memcpy (pilot_head_vp.attitude, vp.attitude, sizeof (matrix3x3)); vp.x = -vp.x; vp.y = -vp.y; vp.z = -vp.z; multiply_transpose_matrix3x3_vec3d (&virtual_cockpit_inst3d->vp.position, pilot_head_vp.attitude, &vp.position); if ((command_line_TIR_6DOF == TRUE)&&(query_TIR_active() == TRUE)) // Retro 6Feb2005 (whole block) { // Now shift the viewpoint (AND the model) by the positive displacement.. puts the cockpit back were it belongs.. // but the viewpoint (the head) is in another place.. fini virtual_cockpit_inst3d->vp.x += current_custom_cockpit_viewpoint.x; virtual_cockpit_inst3d->vp.y += current_custom_cockpit_viewpoint.y; virtual_cockpit_inst3d->vp.z += current_custom_cockpit_viewpoint.z; } } else { debug_fatal ("Failed to locate crew's viewpoint in virtual cockpit"); } }
void get_kiowa_display_viewpoint (view_modes mode) { object_3d_sub_object_index_numbers index; object_3d_sub_object_search_data search; vec3d position; ASSERT (get_gunship_entity ()); ASSERT (virtual_cockpit_inst3d); switch (mode) { //////////////////////////////////////// case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY: //////////////////////////////////////// { index = OBJECT_3D_SUB_OBJECT_COCKPIT_VIEW_MFD_FL; break; } //////////////////////////////////////// case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY: //////////////////////////////////////// { index = OBJECT_3D_SUB_OBJECT_COCKPIT_VIEW_MFD_FR; break; } //////////////////////////////////////// case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY: //////////////////////////////////////// { index = OBJECT_3D_SUB_OBJECT_COCKPIT_VIEW_MFD_RL; break; } //////////////////////////////////////// case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY: //////////////////////////////////////// { index = OBJECT_3D_SUB_OBJECT_COCKPIT_VIEW_MFD_RR; break; } //////////////////////////////////////// default: //////////////////////////////////////// { debug_fatal ("Invalid view mode = %d", mode); break; } } virtual_cockpit_inst3d->vp.x = 0.0; virtual_cockpit_inst3d->vp.y = 0.0; virtual_cockpit_inst3d->vp.z = 0.0; //////////////////////////////////////// // #if DEBUG_MODULE_FINE_DISPLAY_CAMERA_POSITION_ADJUSTMENT get_identity_matrix3x3 (virtual_cockpit_inst3d->vp.attitude); #else get_local_entity_attitude_matrix (get_gunship_entity (), virtual_cockpit_inst3d->vp.attitude); #endif // //////////////////////////////////////// search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = index; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { get_3d_sub_object_world_viewpoint (search.result_sub_object, &main_vp); } else { debug_fatal ("Failed to locate display viewpoint in virtual cockpit"); } position.x = -main_vp.x; position.y = -main_vp.y; position.z = -main_vp.z; //////////////////////////////////////// // #if DEBUG_MODULE_FINE_DISPLAY_CAMERA_POSITION_ADJUSTMENT { static float z_offset = 0.0; float dx, dy, dz; if (check_key (DIK_Q)) { z_offset -= 0.0001; } if (check_key (DIK_A)) { z_offset += 0.0001; } dx = main_vp.zv.x * z_offset; dy = main_vp.zv.y * z_offset; dz = main_vp.zv.z * z_offset; position.x += dx; position.y += dy; position.z += dz; debug_filtered_log ("offset=%.6f x=%.6f y=%.6f z=%.6f", z_offset, position.x, position.y, position.z); } #endif // //////////////////////////////////////// multiply_transpose_matrix3x3_vec3d (&virtual_cockpit_inst3d->vp.position, main_vp.attitude, &position); get_local_entity_vec3d (get_gunship_entity (), VEC3D_TYPE_POSITION, &position); main_vp.x += position.x; main_vp.y += position.y; main_vp.z += position.z; }
void get_hokum_display_viewpoint (view_modes mode) { object_3d_sub_object_index_numbers index; object_3d_sub_object_search_data search; vec3d position; ASSERT (get_gunship_entity ()); ASSERT (virtual_cockpit_inst3d); switch (mode) { //////////////////////////////////////// case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY: //////////////////////////////////////// { index = OBJECT_3D_SUB_OBJECT_COCKPIT_VIEW_MFD_LHS_2; break; } //////////////////////////////////////// case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY: //////////////////////////////////////// { index = OBJECT_3D_SUB_OBJECT_COCKPIT_VIEW_MFD_LHS_1; break; } //////////////////////////////////////// case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY: //////////////////////////////////////// { index = OBJECT_3D_SUB_OBJECT_COCKPIT_VIEW_MFD_RHS_1; break; } //////////////////////////////////////// case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY: //////////////////////////////////////// { index = OBJECT_3D_SUB_OBJECT_COCKPIT_VIEW_MFD_RHS_2; break; } //////////////////////////////////////// default: //////////////////////////////////////// { debug_fatal ("Invalid view mode = %d", mode); break; } } virtual_cockpit_inst3d->vp.x = 0.0; virtual_cockpit_inst3d->vp.y = 0.0; virtual_cockpit_inst3d->vp.z = 0.0; get_local_entity_attitude_matrix (get_gunship_entity (), virtual_cockpit_inst3d->vp.attitude); search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = index; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { get_3d_sub_object_world_viewpoint (search.result_sub_object, &main_vp); } else { debug_fatal ("Failed to locate display viewpoint in virtual cockpit"); } position.x = -main_vp.x; position.y = -main_vp.y; position.z = -main_vp.z; multiply_transpose_matrix3x3_vec3d (&virtual_cockpit_inst3d->vp.position, main_vp.attitude, &position); get_local_entity_vec3d (get_gunship_entity (), VEC3D_TYPE_POSITION, &position); main_vp.x += position.x; main_vp.y += position.y; main_vp.z += position.z; }
void get_hokum_crew_viewpoint (void) { object_3d_sub_object_search_data search_head, search_viewpoint; viewpoint vp; float head_pitch_datum; // // select head // if (get_local_entity_int_value (get_pilot_entity (), INT_TYPE_CREW_ROLE) == CREW_ROLE_PILOT) { search_head.sub_object_index = OBJECT_3D_SUB_OBJECT_PILOT_HEAD; search_viewpoint.sub_object_index = OBJECT_3D_SUB_OBJECT_PILOT_VIEWPOINT; head_pitch_datum = pilot_head_pitch_datum; } else { search_head.sub_object_index = OBJECT_3D_SUB_OBJECT_WSO_HEAD; search_viewpoint.sub_object_index = OBJECT_3D_SUB_OBJECT_WSO_VIEWPOINT; head_pitch_datum = co_pilot_head_pitch_datum; } // // rotate head // search_head.search_depth = 0; search_head.search_object = virtual_cockpit_inst3d; if (find_object_3d_sub_object (&search_head) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search_head.result_sub_object->relative_heading = -pilot_head_heading; search_head.result_sub_object->relative_pitch = head_pitch_datum - pilot_head_pitch; search_head.result_sub_object->relative_roll = 0.0; } else { debug_fatal ("Failed to locate crew's head in virtual cockpit"); } // // get viewpoint (avoid jitter) // search_viewpoint.search_object = virtual_cockpit_inst3d; search_viewpoint.search_depth = 0; if (find_object_3d_sub_object (&search_viewpoint) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { virtual_cockpit_inst3d->vp.x = 0.0; virtual_cockpit_inst3d->vp.y = 0.0; virtual_cockpit_inst3d->vp.z = 0.0; get_local_entity_attitude_matrix (get_gunship_entity (), virtual_cockpit_inst3d->vp.attitude); get_3d_sub_object_world_viewpoint (search_viewpoint.result_sub_object, &vp); get_local_entity_vec3d (get_gunship_entity (), VEC3D_TYPE_POSITION, &pilot_head_vp.position); pilot_head_vp.x += vp.x; pilot_head_vp.y += vp.y; pilot_head_vp.z += vp.z; memcpy (pilot_head_vp.attitude, vp.attitude, sizeof (matrix3x3)); vp.x = -vp.x; vp.y = -vp.y; vp.z = -vp.z; multiply_transpose_matrix3x3_vec3d (&virtual_cockpit_inst3d->vp.position, pilot_head_vp.attitude, &vp.position); } else { debug_fatal ("Failed to locate crew's viewpoint in virtual cockpit"); } }
static void get_display_viewpoint (view_modes mode, viewpoint *display_viewpoint) { object_3d_sub_object_index_numbers index; object_3d_sub_object_search_data search; viewpoint vp; ASSERT (display_viewpoint); if ((!full_screen_hi_res) && (application_video_colourdepth == 16)) { display_viewpoint->x = 0.0; display_viewpoint->y = 0.0; display_viewpoint->z = 0.0; get_local_entity_attitude_matrix (get_gunship_entity (), display_viewpoint->attitude); return; } if (mode == VIEW_MODE_COCKPIT_PANEL_SPECIAL_APACHE_LHS_MFD) { index = OBJECT_3D_SUB_OBJECT_APACHE_COCKPIT_LHS_MFD_CAMERA; } else if (mode == VIEW_MODE_COCKPIT_PANEL_SPECIAL_APACHE_RHS_MFD) { index = OBJECT_3D_SUB_OBJECT_APACHE_COCKPIT_RHS_MFD_CAMERA; } else { debug_fatal ("Invalid view mode = %d", mode); } virtual_cockpit_inst3d = virtual_cockpit_level1_inst3d; search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = index; if (find_object_3d_sub_object (&search) != SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { debug_fatal ("Failed to locate display viewpoint in virtual cockpit"); } virtual_cockpit_inst3d->vp.x = 0.0; virtual_cockpit_inst3d->vp.y = 0.0; virtual_cockpit_inst3d->vp.z = 0.0; get_local_entity_attitude_matrix (get_gunship_entity (), virtual_cockpit_inst3d->vp.attitude); get_3d_sub_object_world_viewpoint (search.result_sub_object, &vp); get_local_entity_vec3d (get_gunship_entity (), VEC3D_TYPE_POSITION, &main_vp.position); main_vp.x += vp.x; main_vp.y += vp.y; main_vp.z += vp.z; memcpy (main_vp.attitude, vp.attitude, sizeof (matrix3x3)); vp.x = -vp.x; vp.y = -vp.y; vp.z = -vp.z; multiply_transpose_matrix3x3_vec3d (&virtual_cockpit_inst3d->vp.position, vp.attitude, &vp.position); memcpy (display_viewpoint, &virtual_cockpit_inst3d->vp, sizeof (viewpoint)); }