void animate_comanche_eo (object_3d_instance *inst3d) { object_3d_sub_object_search_data search_heading; ASSERT (inst3d); // // TADS // search_heading.search_depth = 0; search_heading.search_object = inst3d; search_heading.sub_object_index = OBJECT_3D_SUB_OBJECT_RAH66_TADS_HEADING; if (find_object_3d_sub_object (&search_heading) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search_heading.result_sub_object->relative_heading = eo_azimuth; } // // PNVS // search_heading.search_depth = 0; search_heading.search_object = inst3d; search_heading.sub_object_index = OBJECT_3D_SUB_OBJECT_RAH66_PNVS_HEADING; if (find_object_3d_sub_object (&search_heading) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search_heading.result_sub_object->relative_heading = -pilot_head_heading; } }
void animate_havoc_external_wipers (object_3d_instance *inst3d) { object_3d_sub_object_search_data search; //////////////////////////////////////// // // pilot's wipers // //////////////////////////////////////// search.search_depth = 0; search.search_object = inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_WIPER_ARM_PILOT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = wiper_position * (rad (65.3756) / MAX_WIPER_POSITION); } search.search_depth = 0; search.search_object = inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_WIPER_BLADE_PILOT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = (wiper_position * (rad (-74.7756) / MAX_WIPER_POSITION)) + rad (4.7); } //////////////////////////////////////// // // co-pilot's wipers // //////////////////////////////////////// search.search_depth = 0; search.search_object = inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_WIPER_ARM_COPILOT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = wiper_position * (rad (90.0) / MAX_WIPER_POSITION); } search.search_depth = 0; search.search_object = inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_WIPER_BLADE_COPILOT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = (wiper_position * (rad (-100.0) / MAX_WIPER_POSITION)) + rad (5.0); } }
int get_3d_object_updateable_flag ( int object ) { if ( object_3d_updateable_flag[object] == -1 ) { object_3d_instance *object_instance; object_3d_sub_object_search_data search; object_3d_updateable_flag[object] = FALSE; object_instance = construct_3d_object ( object ); search.search_object = object_instance; search.search_depth = 0; search.sub_object_index = OBJECT_3D_SUB_OBJECT_UPDATEABLE_OBJECT; if ( find_object_3d_sub_object ( &search ) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND ) { object_3d_updateable_flag[object] = TRUE; } else { search.search_object = object_instance; search.search_depth = 0; search.sub_object_index = OBJECT_3D_SUB_OBJECT_RADAR; if ( find_object_3d_sub_object ( &search ) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND ) { object_3d_updateable_flag[object] = TRUE; } } destruct_3d_object ( object_instance ); } return ( object_3d_updateable_flag[object] ); }
void animate_ah64a_eo (object_3d_instance *inst3d) { object_3d_sub_object_search_data search_heading, search_pitch; ASSERT (inst3d); // // TADS // search_heading.search_depth = 0; search_heading.search_object = inst3d; search_heading.sub_object_index = OBJECT_3D_SUB_OBJECT_AH64D_TADS_HEADING; if (find_object_3d_sub_object (&search_heading) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search_heading.result_sub_object->relative_heading = eo_azimuth; search_pitch.search_depth = 0; search_pitch.sub_object_index = OBJECT_3D_SUB_OBJECT_AH64D_TADS_PITCH; if (find_object_3d_sub_object_from_sub_object (&search_heading, &search_pitch) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search_pitch.result_sub_object->relative_pitch = -eo_elevation; } } // // PNVS // search_heading.search_depth = 0; search_heading.search_object = inst3d; search_heading.sub_object_index = OBJECT_3D_SUB_OBJECT_AH64D_PNVS_HEADING; if (find_object_3d_sub_object (&search_heading) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search_heading.result_sub_object->relative_heading = -pilot_head_heading; } }
void get_comanche_eo_relative_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); inst3d->vp.x = 0.0; inst3d->vp.y = 0.0; inst3d->vp.z = 0.0; 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_COMANCHE_EO_CAMERA; 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_COMANCHE_EO_CAMERA missing from Comanche"); } memcpy (&vp->attitude, &inst3d->vp.attitude, sizeof (matrix3x3)); // // fix up the instance position (just in case) // get_local_entity_vec3d (source, VEC3D_TYPE_POSITION, &inst3d->vp.position); }
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)); }
object_3d_sub_instance* find_sub_object(object_3d_instance* parent_object, unsigned sub_obj_id) { object_3d_sub_object_search_data search; const char* name = (sub_obj_id < OBJECT_3D_SUB_OBJECT_LAST) ? object_3d_subobject_names[sub_obj_id] : NULL; search.search_depth = 0; search.search_object = parent_object; search.sub_object_index = sub_obj_id; if (find_object_3d_sub_object(&search) != SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) if (name) debug_fatal ("Failed to locate sub object: %s", name); else debug_fatal ("Failed to locate sub object: %d (illegal id)", sub_obj_id); return search.result_sub_object; }
int find_object_3d_sub_objects ( object_3d_instance *search_object, const object_3d_sub_object_search_batch *search, int number_of_sub_objects ) { object_3d_sub_object_search_data search_data; search_data.search_object = search_object; search_data.search_depth = 0; for ( ; number_of_sub_objects--; search++ ) { search_data.sub_object_index = search->sub_object_index; if ( find_object_3d_sub_object ( &search_data ) != SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND ) { return FALSE; } *search->result_sub_object = search_data.result_sub_object; } return TRUE; }
static void draw_local_3d_object (entity *en, float range) { helicopter *raw; int internal_view; raw = get_local_entity_data (en); // // the player's gunship is visible from the menus - where the in_cockpit flag is invalid // if (en == get_gunship_entity ()) { internal_view = ((in_cockpit) && (get_in_flight_game_mode () == IN_FLIGHT_GAME_MODE_SIMULATOR)); } else { internal_view = FALSE; } //////////////////////////////////////// // // SORT COMANCHE AND HOKUM INSTANCES // // It is necessary to switch parts on and off for all Comanche and Hokum instances // because the player can change gunship so the instances need to be fixed up. // //////////////////////////////////////// { int draw_virtual_cockpit_parts, draw_canopy_doors, draw_loading_doors, ejected; object_3d_sub_object_search_data search; if (raw->ac.object_3d_shape == OBJECT_3D_RAH66) { //////////////////////////////////////// // // Comanche // //////////////////////////////////////// // // draw 'canopy' doors on player object and 'loading' doors on AI object // draw_virtual_cockpit_parts = FALSE; draw_canopy_doors = FALSE; draw_loading_doors = FALSE; if (en == get_gunship_entity ()) { draw_canopy_doors = TRUE; if (internal_view) { draw_virtual_cockpit_parts = TRUE; } } else { draw_loading_doors = TRUE; } // // fuselage // search.search_depth = 0; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_RAH66_FUSELAGE; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = !draw_virtual_cockpit_parts; } // // canopy/loading doors // search.search_depth = 0; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_CANOPY_DOORS; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_canopy_doors; } search.search_depth = 1; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_CANOPY_DOORS; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_canopy_doors; } search.search_depth = 0; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_LOADING_DOOR; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_loading_doors; } search.search_depth = 1; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_LOADING_DOOR; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_loading_doors; } } else if (raw->ac.object_3d_shape == OBJECT_3D_KA_52) { //////////////////////////////////////// // // Hokum // //////////////////////////////////////// // // draw 'canopy' doors on player object and 'loading' doors on AI object // ejected = get_local_entity_int_value (en, INT_TYPE_EJECTED); draw_virtual_cockpit_parts = FALSE; draw_canopy_doors = FALSE; draw_loading_doors = FALSE; if (en == get_gunship_entity ()) { if (!ejected) { draw_canopy_doors = TRUE; } if (internal_view) { draw_virtual_cockpit_parts = TRUE; } } else { if (!ejected) { draw_loading_doors = TRUE; } } // // stub wings // search.search_depth = 0; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_KA52_WINGS; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_virtual_cockpit_parts; } // // fuselage // search.search_depth = 0; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_KA52_FUSELAGE; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = !draw_virtual_cockpit_parts; } // // canopy/loading doors // search.search_depth = 0; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_CANOPY_DOORS; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_canopy_doors; } search.search_depth = 1; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_CANOPY_DOORS; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_canopy_doors; } search.search_depth = 0; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_LOADING_DOOR; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_loading_doors; } search.search_depth = 1; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_LOADING_DOOR; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_loading_doors; } // // ejector seats & crew // search.search_depth = 0; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_KA52_EJECTOR_SEAT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = !ejected; } search.search_depth = 1; search.search_object = raw->ac.inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_KA52_EJECTOR_SEAT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = !ejected; } } } //////////////////////////////////////// if (en == get_gunship_entity ()) { // // update viewpoint // raw->ac.inst3d->vp.position = raw->ac.mob.position; memcpy (&raw->ac.inst3d->vp.attitude, &raw->ac.mob.attitude, sizeof (matrix3x3)); // // animate // if (!internal_view) { if (raw->main_rotor_damaged) { animate_damaged_helicopter_main_rotors (en, TRUE); } else { animate_helicopter_main_rotors (en, TRUE, FALSE); } } animate_helicopter_tail_rotor (en); animate_helicopter_wipers (en); animate_helicopter_eo (en); animate_aircraft_loading_doors (en); animate_aircraft_cargo_doors (en); animate_aircraft_undercarriage (en); animate_aircraft_weapon_system_ready (en); animate_aircraft_shadow (en); animate_aircraft_rudder (en); raw->ac.inst3d->object_internal_lighting = object_internal_lighting_valid (en); raw->ac.inst3d->object_sprite_lights = (raw->ac.inst3d->object_internal_lighting && sprite_light_valid (en)); // // draw // if (!internal_view) { if (!in_flight_invisible_object) { animate_and_draw_entity_muzzle_flash_effect (en); insert_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_OBJECT, raw->ac.inst3d); } } else { if (get_comanche_hokum_gunship ()) { if (get_global_draw_cockpit_graphics ()) { if (!get_global_glass_cockpit ()) { if ( (get_view_mode () == VIEW_MODE_VIRTUAL_COCKPIT_CREW) || (get_global_cockpit_detail_level () == COCKPIT_DETAIL_LEVEL_HIGH) ) { animate_and_draw_entity_muzzle_flash_effect (en); raw->ac.inst3d->vp.position = virtual_cockpit_inst3d->vp.position; memcpy (&raw->ac.inst3d->vp.attitude, &virtual_cockpit_inst3d->vp.attitude, sizeof (matrix3x3)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &raw->ac.inst3d->vp.position, raw->ac.inst3d); } } } } } } else { // // update viewpoint // raw->ac.inst3d->vp.position = raw->ac.mob.position; memcpy (&raw->ac.inst3d->vp.attitude, &raw->ac.mob.attitude, sizeof (matrix3x3)); // // animate // if (get_local_entity_int_value (en, INT_TYPE_ALIVE)) { animate_helicopter_main_rotors (en, FALSE, FALSE); } else { animate_damaged_helicopter_main_rotors (en, FALSE); } animate_helicopter_tail_rotor (en); animate_aircraft_loading_doors (en); animate_aircraft_cargo_doors (en); animate_aircraft_undercarriage (en); animate_aircraft_weapon_system_ready (en); animate_aircraft_shadow (en); animate_and_draw_entity_muzzle_flash_effect (en); raw->ac.inst3d->object_internal_lighting = object_internal_lighting_valid (en); raw->ac.inst3d->object_sprite_lights = (raw->ac.inst3d->object_internal_lighting && sprite_light_valid (en)); // // draw // insert_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_OBJECT, raw->ac.inst3d); } //////////////////////////////////////// // // draw comanche and hokum shadows // //////////////////////////////////////// if (raw->ac.object_3d_shape == OBJECT_3D_RAH66) { object_3d_instance *shadow_object; shadow_object = construct_temporary_3d_object (OBJECT_3D_RAH66_FUSELAGE, FALSE); shadow_object->vp = raw->ac.inst3d->vp; insert_object_shadow_into_3d_scene (shadow_object); } else if (raw->ac.object_3d_shape == OBJECT_3D_KA_52) { object_3d_instance *shadow_object; shadow_object = construct_temporary_3d_object (OBJECT_3D_KA_52_FUSELAGE, FALSE); shadow_object->vp = raw->ac.inst3d->vp; insert_object_shadow_into_3d_scene (shadow_object); } //////////////////////////////////////// #if DEBUG_MODULE if (en == get_external_view_entity ()) { draw_mobile_entity_debug_info (en); } #endif }
int set_initial_rotation_angle_of_routed_vehicle_wheels (object_3d_instance *inst3d) { object_3d_sub_object_search_data search; int depth; float ang; // // vary wheel start positions (ok to use a random number as this is for visual effect only) // ASSERT (inst3d); // // fixed wheels // depth = 0; while (TRUE) { search.search_depth = depth; search.search_object = inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_FIXED_WHEEL; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { ang = sfrand1() * PI; search.result_sub_object->relative_pitch = ang; } else { break; } depth++; } // // steerable wheels // depth = 0; while (TRUE) { search.search_depth = depth; search.search_object = inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_STEERABLE_WHEEL; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { ang = sfrand1() * PI; search.result_sub_object->relative_pitch = ang; } else { break; } depth++; } return TRUE; }
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 animate_hokum_virtual_cockpit_canopy_doors (void) { int ejected; float aiming_state; object_3d_instance *inst3d; object_3d_sub_object_search_data search; ASSERT (virtual_cockpit_inst3d); if (canopy_door_state == CANOPY_DOOR_STATE_UNINITIALISED) { canopy_door_state = get_canopy_doors_aiming_state (); } aiming_state = get_canopy_doors_aiming_state (); if (aiming_state > canopy_door_state) { canopy_door_state += get_delta_time () * 0.5; if (canopy_door_state > CANOPY_DOOR_STATE_OPEN) { canopy_door_state = CANOPY_DOOR_STATE_OPEN; } } else if (aiming_state < canopy_door_state) { canopy_door_state -= get_delta_time () * 0.5; if (canopy_door_state < CANOPY_DOOR_STATE_CLOSED) { canopy_door_state = CANOPY_DOOR_STATE_CLOSED; } } animate_keyframed_sub_object_type (virtual_cockpit_inst3d, OBJECT_3D_SUB_OBJECT_CANOPY_DOORS, canopy_door_state); // // keep external 3D model in sync // inst3d = get_local_entity_ptr_value (get_gunship_entity (), PTR_TYPE_INSTANCE_3D_OBJECT); ASSERT (inst3d); animate_keyframed_sub_object_type (inst3d, OBJECT_3D_SUB_OBJECT_CANOPY_DOORS, canopy_door_state); // // ejected // ejected = get_local_entity_int_value (get_gunship_entity (), INT_TYPE_EJECTED); search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_CANOPY_DOORS; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = !ejected; } search.search_depth = 1; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_CANOPY_DOORS; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = !ejected; } }
void update_kiowa_virtual_cockpit (void) { int depth, draw_glass_cockpit, draw_controls, draw_crew, draw_pilot_cockpit, draw_co_pilot_cockpit; object_3d_sub_object_search_data search; //////////////////////////////////////// // // sort out what to draw // //////////////////////////////////////// switch (get_view_mode ()) { case VIEW_MODE_VIRTUAL_COCKPIT_CREW: case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY: { draw_glass_cockpit = FALSE; break; } default: { draw_glass_cockpit = get_global_glass_cockpit (); break; } } draw_controls = !draw_glass_cockpit; if (get_view_mode () == VIEW_MODE_VIRTUAL_COCKPIT_CREW) { draw_pilot_cockpit = TRUE; draw_co_pilot_cockpit = TRUE; } else { if (get_crew_role () == CREW_ROLE_PILOT) { draw_pilot_cockpit = TRUE; draw_co_pilot_cockpit = FALSE; } else { draw_pilot_cockpit = FALSE; draw_co_pilot_cockpit = TRUE; } } // // select 3D instance // if (draw_glass_cockpit) { if (virtual_cockpit_inst3d != virtual_cockpit_inst3d_detail_level_glass_inst3d) { virtual_cockpit_inst3d_detail_level_glass_inst3d->vp = virtual_cockpit_inst3d->vp; virtual_cockpit_inst3d = virtual_cockpit_inst3d_detail_level_glass_inst3d; } } else { if (virtual_cockpit_inst3d != virtual_cockpit_inst3d_detail_level_normal_inst3d) { virtual_cockpit_inst3d_detail_level_normal_inst3d->vp = virtual_cockpit_inst3d->vp; virtual_cockpit_inst3d = virtual_cockpit_inst3d_detail_level_normal_inst3d; } } // // draw cockpits // depth = 0; for (;;) { search.search_depth = depth; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_VISIBLE_TO_PILOT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_pilot_cockpit; } else { break; } depth++; } depth = 0; for (;;) { search.search_depth = depth; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_VISIBLE_TO_WSO; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_co_pilot_cockpit; } else { break; } depth++; } // // draw crew // //VJ 050206: wideview improvement show other pilot when in wideview draw_crew = !(get_global_wide_cockpit () && wide_cockpit_nr == WIDEVIEW_KIOWA_PILOT); search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COMANCHE_PILOT_VISIBLE; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_crew; } //VJ 050206: wideview improvement show other pilot when in wideview draw_crew = !(get_global_wide_cockpit () && wide_cockpit_nr == WIDEVIEW_KIOWA_COPILOT); search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COMANCHE_WSO_VISIBLE; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_crew; } // // draw controls // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_PILOT_JOYSTICK; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_controls; } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_PILOT_COLLECTIVE; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_controls; } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_WSO_JOYSTICK; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_controls; } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_WSO_COLLECTIVE; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_controls; } //////////////////////////////////////// // // update animations // //////////////////////////////////////// // // crew animation // update_kiowa_crew_animation (); // // canopy doors // animate_kiowa_virtual_cockpit_canopy_doors (); //////////////////////////////////////// // // sort static hands // //////////////////////////////////////// if (!draw_crew) { search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_PILOT_HAND_STATIC; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = FALSE; } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_WSO_HAND_STATIC; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = FALSE; } } }
void draw_kiowa_virtual_cockpit (void) { int draw_main_rotors; float theta; object_3d_instance *inst3d; object_3d_sub_object_search_data search; switch (get_view_mode ()) { case VIEW_MODE_VIRTUAL_COCKPIT_CREW: case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY: { break; } default: { if (!get_global_draw_cockpit_graphics ()) { return; } break; } } // // lamps // draw_kiowa_virtual_cockpit_lamps (); // // crew animation // set_kiowa_crew_head_positions (); // // animate main rotors // if (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_MAIN_ROTOR_DAMAGED)) { animate_damaged_helicopter_main_rotors (get_gunship_entity (), TRUE); } else { animate_helicopter_main_rotors (get_gunship_entity (), TRUE, FALSE); } inst3d = (object_3d_instance *) get_local_entity_ptr_value (get_gunship_entity (), PTR_TYPE_INSTANCE_3D_OBJECT); theta = get_rotation_angle_of_helicopter_main_rotors (inst3d); set_rotation_angle_of_helicopter_main_rotors (virtual_cockpit_inst3d, theta); animate_helicopter_virtual_cockpit_main_rotors (get_gunship_entity (), virtual_cockpit_inst3d); draw_main_rotors = TRUE; if (get_global_glass_cockpit ()) { draw_main_rotors = FALSE; } else { if (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CREW) { if (get_helicopter_main_rotors_blurred (get_gunship_entity ())) { if (!get_global_blurred_main_rotors_visible_from_cockpit ()) { draw_main_rotors = FALSE; } } } } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_MAIN_ROTOR_SHAFT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_main_rotors; } // // draw 3D scene // set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_env); recalculate_3d_environment_settings (main_3d_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { // // light direction is in world coordinates // light_3d_source *display_backlight, *cockpit_light; vec3d direction; matrix3x3 m1, m2; //VJ 050131 update on wideview mod, much better movement if (get_global_wide_cockpit () && ( get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY && get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY && get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY && get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY ) ) { get_kiowa_crew_viewpoint (); virtual_cockpit_inst3d->vp.x += wide_cockpit_position[wide_cockpit_nr].c.x; virtual_cockpit_inst3d->vp.y += wide_cockpit_position[wide_cockpit_nr].c.y; virtual_cockpit_inst3d->vp.z += wide_cockpit_position[wide_cockpit_nr].c.z; //ataribaby 27/12/2008 //virtual_cockpit_inst3d->vp.x += bound(current_flight_dynamics->model_acceleration_vector.x * ONE_OVER_G, -3.0, 3.0) * 0.025 * command_line_g_force_head_movment_modifier; //virtual_cockpit_inst3d->vp.y += bound(current_flight_dynamics->g_force.value - 1.0, -1.5, 5.0) * 0.025 * command_line_g_force_head_movment_modifier; if (wide_cockpit_nr == WIDEVIEW_KIOWA_PILOT) pilot_head_pitch_datum = rad ( wide_cockpit_position[wide_cockpit_nr].c.p ); if (wide_cockpit_nr == WIDEVIEW_KIOWA_COPILOT) co_pilot_head_pitch_datum = rad ( wide_cockpit_position[wide_cockpit_nr].c.p ); set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); } //ataribaby 27/12/2008 new head g-force movement and vibration from main rotor if (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY && get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY && get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY && get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY) { if (get_time_acceleration() != TIME_ACCELERATION_PAUSE) { random_vibration_x = (frand1() * (current_flight_dynamics->main_rotor_rpm.value * 0.00002)) * command_line_g_force_head_movment_modifier; random_vibration_y = (frand1() * (current_flight_dynamics->main_rotor_rpm.value * 0.00002)) * command_line_g_force_head_movment_modifier; } x_head_g_movement = move_by_rate(x_head_g_movement, random_vibration_x + (bound(current_flight_dynamics->model_acceleration_vector.x * ONE_OVER_G, -3.0, 3.0) * 0.025 * command_line_g_force_head_movment_modifier), 0.05); y_head_g_movement = move_by_rate(y_head_g_movement, random_vibration_y + (bound(current_flight_dynamics->g_force.value - 1.0, -1.5, 5.0) * 0.025 * command_line_g_force_head_movment_modifier), 0.05); virtual_cockpit_inst3d->vp.x -= x_head_g_movement; //if (!current_flight_dynamics->auto_hover) // arneh - auto hover has some weird dynamics which cause lots of g-forces, so disable head movement when auto hover is enabled virtual_cockpit_inst3d->vp.y -= y_head_g_movement; } { // // ADI // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ADI; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { float heading, pitch, roll; get_kiowa_virtual_cockpit_adi_angles (virtual_cockpit_inst3d->vp.attitude, &heading, &pitch, &roll); search.result_sub_object->relative_heading = -heading; search.result_sub_object->relative_pitch = pitch; search.result_sub_object->relative_roll = -roll; } // // ADI slip // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ADI_SIDE_SLIP; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = get_kiowa_virtual_cockpit_adi_slip_indicator_needle_value (); } // // airspeed // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_AIRSPEED; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = get_kiowa_virtual_cockpit_airspeed_indicator_needle_value (); } // // altimeter // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ALTIMETER; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = get_kiowa_virtual_cockpit_barometric_altimeter_needle_value (); } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_COMPASS_HEADING_NULL; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_heading = -current_flight_dynamics->heading.value; } // // clock // { float hours, minutes, seconds; // // only read clock values if drawing virtual cockpit needles to prevent speeding up clock debug values // get_kiowa_virtual_cockpit_clock_hand_values (&hours, &minutes, &seconds); // // hour hand // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_CLOCK_HOUR_HAND; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = hours; } // // minute hand // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_CLOCK_MINUTE_HAND; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = minutes; } // // second hand // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_CLOCK_SECOND_HAND; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = seconds; } } } if (get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE) == DAY_SEGMENT_TYPE_DAY) { //////////////////////////////////////// // // DAY LIGHTING // //////////////////////////////////////// if (night_vision_system_active && (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CREW)) { // // active night vision system // get_3d_transformation_matrix (m1, rad (0.0), rad (135.0), rad (0.0)); multiply_matrix3x3_matrix3x3 (m2, m1, virtual_cockpit_inst3d->vp.attitude); direction.x = m2[2][0]; direction.y = m2[2][1]; direction.z = m2[2][2]; cockpit_light = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.0000, 0.5000, 0.0000); insert_light_3d_source_into_3d_scene (cockpit_light); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); end_3d_scene (); remove_light_3d_source_from_3d_scene (cockpit_light); destroy_light_3d_source (cockpit_light); } else { // // inactive night vision system // insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); print_edit_wide_cockpit (); end_3d_scene (); } } else { //////////////////////////////////////// // // NIGHT LIGHTING // //////////////////////////////////////// direction.x = virtual_cockpit_inst3d->vp.zv.x; direction.y = virtual_cockpit_inst3d->vp.zv.y; direction.z = virtual_cockpit_inst3d->vp.zv.z; display_backlight = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.0627, 0.2039, 0.0392); if (night_vision_system_active && (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CREW)) { // // active night vision system // get_3d_transformation_matrix (m1, rad (0.0), rad (135.0), rad (0.0)); multiply_matrix3x3_matrix3x3 (m2, m1, virtual_cockpit_inst3d->vp.attitude); direction.x = m2[2][0]; direction.y = m2[2][1]; direction.z = m2[2][2]; cockpit_light = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.0000, 0.5000, 0.0000); } else { // // inactive night vision system // direction.x = virtual_cockpit_inst3d->vp.yv.x; direction.y = virtual_cockpit_inst3d->vp.yv.y; direction.z = virtual_cockpit_inst3d->vp.yv.z; cockpit_light = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.0666, 0.1098, 0.6431); } insert_light_3d_source_into_3d_scene (display_backlight); insert_light_3d_source_into_3d_scene (cockpit_light); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); print_edit_wide_cockpit (); end_3d_scene (); remove_light_3d_source_from_3d_scene (display_backlight); remove_light_3d_source_from_3d_scene (cockpit_light); destroy_light_3d_source (display_backlight); destroy_light_3d_source (cockpit_light); } } move_edit_wide_cockpit (); #if RECOGNITION_GUIDE set_3d_view_distances (main_3d_env, 10000.0, 100.0, 1.0, 0.0); #else set_3d_view_distances (main_3d_env, 10000.0, 1.0, 1.0, 0.0); #endif realise_3d_clip_extents (main_3d_env); }
void draw_default_external_virtual_cockpit_3d (unsigned int flags) { viewpoint vp; object_3d_sub_object_search_data search; float theta; object_3d_instance *inst3d; //////////////////////////////////////// // // virtual cockpit viewpoint is placed at the main object origin // //////////////////////////////////////// //NO wideview for 3d cockpit //#ifndef DEBUG_WIDEVIEW set_global_wide_cockpit(FALSE); edit_wide_cockpit = FALSE; //#endif vp.x = 0.0; vp.y = 0.0; vp.z = 0.0; get_local_entity_attitude_matrix (get_gunship_entity (), vp.attitude); //////////////////////////////////////// // // draw 3D scene without lighting // //////////////////////////////////////// if (flags & (VIRTUAL_COCKPIT_MAIN_ROTOR | VIRTUAL_COCKPIT_STOWED_WIPER | VIRTUAL_COCKPIT_MOVING_WIPER)) { set_3d_active_environment (main_3d_env); set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_env); recalculate_3d_environment_settings (main_3d_env); clear_zbuffer_screen (); /* vp.x += dx; vp.y += dy; vp.z += dz; vp.x = wide_cockpit_position[wide_cockpit_nr].c.x; vp.y = wide_cockpit_position[wide_cockpit_nr].c.y; vp.z = wide_cockpit_position[wide_cockpit_nr].c.z; */ vp.x = BASE_DX; vp.y = BASE_DY - 0.164; vp.z = BASE_DZ; if (begin_3d_scene ()) { // // main rotor // if (flags & VIRTUAL_COCKPIT_MAIN_ROTOR) { if (!(get_helicopter_main_rotors_blurred (get_gunship_entity ()) && (!get_global_blurred_main_rotors_visible_from_cockpit ()))) { if (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_MAIN_ROTOR_DAMAGED)) { animate_damaged_helicopter_main_rotors (get_gunship_entity (), TRUE); } else { animate_helicopter_main_rotors (get_gunship_entity (), TRUE, FALSE); } inst3d = (object_3d_instance *) get_local_entity_ptr_value (get_gunship_entity (), PTR_TYPE_INSTANCE_3D_OBJECT); theta = get_rotation_angle_of_helicopter_main_rotors (inst3d); set_rotation_angle_of_helicopter_main_rotors (virtual_cockpit_main_rotor_inst3d, theta); animate_helicopter_virtual_cockpit_main_rotors (get_gunship_entity (), virtual_cockpit_main_rotor_inst3d); memcpy (&virtual_cockpit_main_rotor_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_main_rotor_inst3d->vp.position, virtual_cockpit_main_rotor_inst3d); } } // // wiper // if (wiper_mode == WIPER_MODE_STOWED) { if (flags & VIRTUAL_COCKPIT_STOWED_WIPER) { draw_default_virtual_cockpit_wiper (&vp); } } else { if (flags & VIRTUAL_COCKPIT_MOVING_WIPER) { draw_default_virtual_cockpit_wiper (&vp); } } draw_3d_scene (); end_3d_scene (); } } //////////////////////////////////////// // // draw 3D scene with lighting // //////////////////////////////////////// if (flags & (VIRTUAL_COCKPIT_COMPASS | VIRTUAL_COCKPIT_ADI | VIRTUAL_COCKPIT_LARGE_ADI)) { set_cockpit_lighting (vp.attitude); set_3d_active_environment (main_3d_single_light_env); set_3d_view_distances (main_3d_single_light_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_single_light_env); clear_zbuffer_screen (); vp.x = BASE_DX; vp.y = BASE_DY; vp.z = BASE_DZ-0.1; /* vp.x = BASE_DX+dx; vp.y = BASE_DY+dy; vp.z = BASE_DZ+dz; vp.x = wide_cockpit_position[wide_cockpit_nr].c.x; vp.y = wide_cockpit_position[wide_cockpit_nr].c.y; vp.z = wide_cockpit_position[wide_cockpit_nr].c.z; */ //VJ# if (begin_3d_scene ()) { // // compass // if (flags & VIRTUAL_COCKPIT_COMPASS) { search.search_depth = 0; search.search_object = virtual_cockpit_compass_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_COMPASS_HEADING_NULL; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_heading = -current_flight_dynamics->heading.value; } memcpy (&virtual_cockpit_compass_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_compass_inst3d->vp.position, virtual_cockpit_compass_inst3d); } // // ADI // /* vp.x = wide_cockpit_position[wide_cockpit_nr].c.x; vp.y = wide_cockpit_position[wide_cockpit_nr].c.y; vp.z = wide_cockpit_position[wide_cockpit_nr].c.z; vp.x += 0.0; vp.y += 0.22; vp.z += 0.18; */ if (flags & VIRTUAL_COCKPIT_ADI) { search.search_depth = 0; search.search_object = virtual_cockpit_adi_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ADI; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { float heading, pitch, roll; get_default_virtual_cockpit_adi_angles (vp.attitude, &heading, &pitch, &roll); search.result_sub_object->relative_heading = -heading; search.result_sub_object->relative_pitch = pitch; search.result_sub_object->relative_roll = -roll; } memcpy (&virtual_cockpit_adi_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_adi_inst3d->vp.position, virtual_cockpit_adi_inst3d); } // // large ADI // if (flags & VIRTUAL_COCKPIT_LARGE_ADI) { search.search_depth = 0; search.search_object = virtual_cockpit_large_adi_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ADI; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { float heading, pitch, roll; get_default_virtual_cockpit_adi_angles (vp.attitude, &heading, &pitch, &roll); search.result_sub_object->relative_heading = -heading; search.result_sub_object->relative_pitch = pitch; search.result_sub_object->relative_roll = -roll; } memcpy (&virtual_cockpit_large_adi_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_large_adi_inst3d->vp.position, virtual_cockpit_large_adi_inst3d); } draw_3d_scene (); end_3d_scene (); } } //////////////////////////////////////// // // rain effect // //////////////////////////////////////// if (flags & VIRTUAL_COCKPIT_RAIN_EFFECT) { if (rain_mode != RAIN_MODE_DRY) { set_3d_active_environment (main_3d_env); set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_env); recalculate_3d_environment_settings (main_3d_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { draw_default_virtual_cockpit_rain_effect (&vp); draw_3d_scene (); end_3d_scene (); } } } //////////////////////////////////////// // // tidy up // //////////////////////////////////////// #if RECOGNITION_GUIDE set_3d_view_distances (main_3d_env, 10000.0, 100.0, 1.0, 0.0); #else set_3d_view_distances (main_3d_env, 10000.0, 1.0, 1.0, 0.0); #endif realise_3d_clip_extents (main_3d_env); }
void draw_blackhawk_internal_virtual_cockpit (unsigned int flags) { viewpoint vp; object_3d_sub_object_search_data search; object_3d_instance *virtual_cockpit_inst3d; //////////////////////////////////////// // // virtual cockpit viewpoint is placed at the main object origin // //////////////////////////////////////// if (get_view_mode () == VIEW_MODE_COCKPIT_PANEL_SPECIAL_APACHE_LHS_MFD) { get_display_viewpoint (VIEW_MODE_COCKPIT_PANEL_SPECIAL_APACHE_LHS_MFD, &vp); } else if (get_view_mode () == VIEW_MODE_COCKPIT_PANEL_SPECIAL_APACHE_RHS_MFD) { get_display_viewpoint (VIEW_MODE_COCKPIT_PANEL_SPECIAL_APACHE_RHS_MFD, &vp); } else { vp.x = 0.0; vp.y = 0.0; vp.z = 0.0; //VJ wideview mod, date: 18-mar-03 if (get_global_wide_cockpit ()) { vp.y = wide_cockpit_position[wide_cockpit_nr].c.y; vp.z = wide_cockpit_position[wide_cockpit_nr].c.z; //VJ 050207 included head pitch in fixed view setting pilot_head_pitch_datum = rad ( wide_cockpit_position[wide_cockpit_nr].c.p ); if (edit_wide_cockpit) pilot_head_pitch = pilot_head_pitch_datum; } get_local_entity_attitude_matrix (get_gunship_entity (), vp.attitude); } //////////////////////////////////////// // // render displays onto textures (before draw 3D scenes) // //////////////////////////////////////// if (flags & VIRTUAL_COCKPIT_UPFRONT_DISPLAY) { draw_blackhawk_upfront_display_on_texture (); } if (flags & VIRTUAL_COCKPIT_LHS_MFD_DISPLAY) { draw_blackhawk_mfd_on_texture (MFD_LOCATION_LHS); } if (flags & VIRTUAL_COCKPIT_RHS_MFD_DISPLAY) { draw_blackhawk_mfd_on_texture (MFD_LOCATION_RHS); } //////////////////////////////////////// // // draw 3D scene with lighting // //////////////////////////////////////// if (flags & (VIRTUAL_COCKPIT_COCKPIT)) { set_cockpit_white_lighting (vp.attitude); set_3d_active_environment (main_3d_single_light_env); //VJ 050108 wideview x coord used to clip apache cockpit if (get_global_wide_cockpit ()) clipx = wide_cockpit_position[wide_cockpit_nr].c.x; else clipx = 0; set_3d_view_distances (main_3d_single_light_env, 10.0+clipx, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_single_light_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { // // virtual cockpit // if (flags & VIRTUAL_COCKPIT_COCKPIT) { switch (get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE)) { //////////////////////////////////////// case DAY_SEGMENT_TYPE_DAWN: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_level2_inst3d; break; } //////////////////////////////////////// case DAY_SEGMENT_TYPE_DAY: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_level1_inst3d; break; } //////////////////////////////////////// case DAY_SEGMENT_TYPE_DUSK: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_level2_inst3d; break; } //////////////////////////////////////// case DAY_SEGMENT_TYPE_NIGHT: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_level3_inst3d; break; } } #if DEMO_VERSION virtual_cockpit_inst3d = virtual_cockpit_level1_inst3d; #endif memcpy (&virtual_cockpit_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); } draw_3d_scene (); print_edit_wide_cockpit (); end_3d_scene (); } } //////////////////////////////////////// // // draw 3D scene with lighting // //////////////////////////////////////// if (flags & (VIRTUAL_COCKPIT_INSTRUMENT_NEEDLES | VIRTUAL_COCKPIT_INSTRUMENT_LARGE_NEEDLES)) { set_cockpit_lighting (vp.attitude); set_3d_active_environment (main_3d_single_light_env); set_3d_view_distances (main_3d_single_light_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_single_light_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { // // instrument needles // if (flags & VIRTUAL_COCKPIT_INSTRUMENT_NEEDLES) { // // ADI slip // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ADI_SIDE_SLIP; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = get_blackhawk_virtual_cockpit_adi_slip_indicator_needle_value (); } // // airspeed // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_AIRSPEED; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_virtual_cockpit_needles_on_fixed_cockpits; search.result_sub_object->relative_roll = get_blackhawk_virtual_cockpit_airspeed_indicator_needle_value (); } // // altimeter // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ALTIMETER; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_virtual_cockpit_needles_on_fixed_cockpits; search.result_sub_object->relative_roll = get_blackhawk_virtual_cockpit_barometric_altimeter_needle_value (); } // // clock // { float hours, minutes, seconds; // // only read clock values if drawing virtual cockpit needles to prevent speeding up clock debug values // if (draw_virtual_cockpit_needles_on_fixed_cockpits) { get_blackhawk_virtual_cockpit_clock_hand_values (&hours, &minutes, &seconds); } else { hours = 0.0; minutes = 0.0; seconds = 0.0; } // // hour hand // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_CLOCK_HOUR_HAND; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_virtual_cockpit_needles_on_fixed_cockpits; search.result_sub_object->relative_roll = hours; } // // minute hand // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_CLOCK_MINUTE_HAND; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_virtual_cockpit_needles_on_fixed_cockpits; search.result_sub_object->relative_roll = minutes; } // // second hand // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_CLOCK_SECOND_HAND; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_virtual_cockpit_needles_on_fixed_cockpits; search.result_sub_object->relative_roll = seconds; } } //VJ wideview mod, date: 18-mar-03 if (get_global_wide_cockpit ()) { vp.z = wide_cockpit_position[wide_cockpit_nr].c.z + 0.03; vp.y = wide_cockpit_position[wide_cockpit_nr].c.y + 0.01; } memcpy (&virtual_cockpit_instrument_needles_inst3d->vp, &vp, sizeof (viewpoint)); if (get_global_wide_cockpit ()) { vp.y = wide_cockpit_position[wide_cockpit_nr].c.y; vp.z = wide_cockpit_position[wide_cockpit_nr].c.z; } insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_instrument_needles_inst3d->vp.position, virtual_cockpit_instrument_needles_inst3d); } // // instrument large needles // if (flags & VIRTUAL_COCKPIT_INSTRUMENT_LARGE_NEEDLES) { // // ADI slip // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_large_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ADI_SIDE_SLIP; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = get_blackhawk_virtual_cockpit_adi_slip_indicator_needle_value (); } // // airspeed // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_large_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_AIRSPEED; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = get_blackhawk_virtual_cockpit_airspeed_indicator_needle_value (); } memcpy (&virtual_cockpit_instrument_large_needles_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_instrument_large_needles_inst3d->vp.position, virtual_cockpit_instrument_large_needles_inst3d); } draw_3d_scene (); end_3d_scene (); } } //////////////////////////////////////// // // draw 3D scene without lighting // //////////////////////////////////////// if ( (flags & VIRTUAL_COCKPIT_DISPLAY_VIEW) && (flags & VIRTUAL_COCKPIT_LHS_MFD_DISPLAY) && (flags & VIRTUAL_COCKPIT_RHS_MFD_DISPLAY) ) { set_3d_active_environment (main_3d_env); set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_env); recalculate_3d_environment_settings (main_3d_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { // // lhs mfd // memcpy (&virtual_cockpit_display_view_mfd_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_display_view_mfd_inst3d->vp.position, virtual_cockpit_display_view_mfd_inst3d); // // rhs mfd // memcpy (&virtual_cockpit_display_view_mfd_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_display_view_mfd_inst3d->vp.position, virtual_cockpit_display_view_mfd_inst3d); draw_3d_scene (); end_3d_scene (); } } else { if (flags & (VIRTUAL_COCKPIT_UPFRONT_DISPLAY | VIRTUAL_COCKPIT_LHS_MFD_DISPLAY | VIRTUAL_COCKPIT_RHS_MFD_DISPLAY)) { set_3d_active_environment (main_3d_env); set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_env); recalculate_3d_environment_settings (main_3d_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { // // up-front display // if (flags & VIRTUAL_COCKPIT_UPFRONT_DISPLAY) { memcpy (&virtual_cockpit_upfront_display_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_upfront_display_inst3d->vp.position, virtual_cockpit_upfront_display_inst3d); } //VJ wideview mod, date: 18-mar-03, 050123 if (get_global_wide_cockpit ()) { vp.y = wide_cockpit_position[wide_cockpit_nr].c.y + 0.008; vp.z = wide_cockpit_position[wide_cockpit_nr].c.z + 0.005; } // // lhs mfd // if (flags & VIRTUAL_COCKPIT_LHS_MFD_DISPLAY) { memcpy (&virtual_cockpit_lhs_mfd_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_lhs_mfd_inst3d->vp.position, virtual_cockpit_lhs_mfd_inst3d); } // // rhs mfd // if (flags & VIRTUAL_COCKPIT_RHS_MFD_DISPLAY) { memcpy (&virtual_cockpit_rhs_mfd_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_rhs_mfd_inst3d->vp.position, virtual_cockpit_rhs_mfd_inst3d); } //VJ wideview mod, date: 18-mar-03, 050123 if (get_global_wide_cockpit ()) { vp.y = wide_cockpit_position[wide_cockpit_nr].c.y; vp.z = wide_cockpit_position[wide_cockpit_nr].c.z; } draw_3d_scene (); end_3d_scene (); } } } //////////////////////////////////////// // // draw 3D scene with lighting // //////////////////////////////////////// // // draw fillet to mask TADS display // if ( (d3d_can_render_to_texture) && //always draw fillet not only with tads //(get_blackhawk_tads_display_visible ()) && (flags & (VIRTUAL_COCKPIT_COCKPIT)) && (flags & (VIRTUAL_COCKPIT_LHS_MFD_DISPLAY)) && (flags & (VIRTUAL_COCKPIT_RHS_MFD_DISPLAY)) ) { set_cockpit_white_lighting (vp.attitude); set_3d_active_environment (main_3d_single_light_env); set_3d_view_distances (main_3d_single_light_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_single_light_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { switch (get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE)) { //////////////////////////////////////// case DAY_SEGMENT_TYPE_DAWN: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_fillet_level2_inst3d; break; } //////////////////////////////////////// case DAY_SEGMENT_TYPE_DAY: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_fillet_level1_inst3d; break; } //////////////////////////////////////// case DAY_SEGMENT_TYPE_DUSK: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_fillet_level2_inst3d; break; } //////////////////////////////////////// case DAY_SEGMENT_TYPE_NIGHT: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_fillet_level3_inst3d; break; } } #if DEMO_VERSION virtual_cockpit_inst3d = virtual_cockpit_fillet_level1_inst3d; #endif memcpy (&virtual_cockpit_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); end_3d_scene (); } } //VJ wideview mod, date: 18-mar-03 move_edit_wide_cockpit (); //////////////////////////////////////// // // tidy up // //////////////////////////////////////// #if RECOGNITION_GUIDE set_3d_view_distances (main_3d_env, 10000.0, 100.0, 1.0, 0.0); #else set_3d_view_distances (main_3d_env, 10000.0, 1.0, 1.0, 0.0); #endif realise_3d_clip_extents (main_3d_env); }
void draw_blackhawk_external_virtual_cockpit (unsigned int flags, unsigned char *wiper_rle_graphic) { viewpoint vp; object_3d_sub_object_search_data search; float theta; object_3d_instance *inst3d; //////////////////////////////////////// // // virtual cockpit viewpoint is placed at the main object origin // //////////////////////////////////////// if (get_view_mode () == VIEW_MODE_COCKPIT_PANEL_SPECIAL_APACHE_LHS_MFD) { get_display_viewpoint (VIEW_MODE_COCKPIT_PANEL_SPECIAL_APACHE_LHS_MFD, &vp); } else if (get_view_mode () == VIEW_MODE_COCKPIT_PANEL_SPECIAL_APACHE_RHS_MFD) { get_display_viewpoint (VIEW_MODE_COCKPIT_PANEL_SPECIAL_APACHE_RHS_MFD, &vp); } else { vp.x = 0.0; vp.y = 0.0; vp.z = 0.0; if (get_global_wide_cockpit ()) { vp.y = wide_cockpit_position[wide_cockpit_nr].c.y; vp.z = wide_cockpit_position[wide_cockpit_nr].c.z; } get_local_entity_attitude_matrix (get_gunship_entity (), vp.attitude); } //////////////////////////////////////// // // draw 3D scene without lighting // //////////////////////////////////////// if (flags & (VIRTUAL_COCKPIT_MAIN_ROTOR | VIRTUAL_COCKPIT_STOWED_WIPER | VIRTUAL_COCKPIT_MOVING_WIPER)) { set_3d_active_environment (main_3d_env); //VJ 050108 wideview x coord used to clip apache cockpit set_3d_view_distances (main_3d_env, 10.0 + clipx, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_env); recalculate_3d_environment_settings (main_3d_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { // // main rotor // if (flags & VIRTUAL_COCKPIT_MAIN_ROTOR) { if (!(get_helicopter_main_rotors_blurred (get_gunship_entity ()) && (!get_global_blurred_main_rotors_visible_from_cockpit ()))) { if (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_MAIN_ROTOR_DAMAGED)) { animate_damaged_helicopter_main_rotors (get_gunship_entity (), TRUE); } else { animate_helicopter_main_rotors (get_gunship_entity (), TRUE, FALSE); } inst3d = (object_3d_instance *) get_local_entity_ptr_value (get_gunship_entity (), PTR_TYPE_INSTANCE_3D_OBJECT); theta = get_rotation_angle_of_helicopter_main_rotors (inst3d); set_rotation_angle_of_helicopter_main_rotors (virtual_cockpit_main_rotor_inst3d, theta); animate_helicopter_virtual_cockpit_main_rotors (get_gunship_entity (), virtual_cockpit_main_rotor_inst3d); memcpy (&virtual_cockpit_main_rotor_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_main_rotor_inst3d->vp.position, virtual_cockpit_main_rotor_inst3d); } } // // wiper // if (wiper_mode == WIPER_MODE_STOWED) { if (flags & VIRTUAL_COCKPIT_STOWED_WIPER) { draw_blackhawk_virtual_cockpit_wiper (&vp); } } else { if (flags & VIRTUAL_COCKPIT_MOVING_WIPER) { draw_blackhawk_virtual_cockpit_wiper (&vp); } } draw_3d_scene (); end_3d_scene (); } } //////////////////////////////////////// // // draw 3D scene with lighting // //////////////////////////////////////// if (flags & (VIRTUAL_COCKPIT_COMPASS | VIRTUAL_COCKPIT_ADI | VIRTUAL_COCKPIT_LARGE_ADI)) { set_cockpit_lighting (vp.attitude); set_3d_active_environment (main_3d_single_light_env); set_3d_view_distances (main_3d_single_light_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_single_light_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { // // compass // if (flags & VIRTUAL_COCKPIT_COMPASS) { search.search_depth = 0; search.search_object = virtual_cockpit_compass_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_COMPASS_HEADING_NULL; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_heading = -current_flight_dynamics->heading.value; } //VJ wideview mod, date: 18-mar-03 if (get_global_wide_cockpit ()) vp.y = wide_cockpit_position[wide_cockpit_nr].c.y + 0.01; memcpy (&virtual_cockpit_compass_inst3d->vp, &vp, sizeof (viewpoint)); //VJ wideview mod, date: 18-mar-03 if (get_global_wide_cockpit ()) vp.y = wide_cockpit_position[wide_cockpit_nr].c.y; insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_compass_inst3d->vp.position, virtual_cockpit_compass_inst3d); } // // ADI // if (flags & VIRTUAL_COCKPIT_ADI) { search.search_depth = 0; search.search_object = virtual_cockpit_adi_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ADI; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { float heading, pitch, roll; get_blackhawk_virtual_cockpit_adi_angles (vp.attitude, &heading, &pitch, &roll); search.result_sub_object->relative_heading = -heading; search.result_sub_object->relative_pitch = pitch; search.result_sub_object->relative_roll = -roll; } //VJ wideview mod, date: 18-mar-03 if (get_global_wide_cockpit ()) vp.y = wide_cockpit_position[wide_cockpit_nr].c.y+0.02; memcpy (&virtual_cockpit_adi_inst3d->vp, &vp, sizeof (viewpoint)); //VJ wideview mod, date: 18-mar-03 if (get_global_wide_cockpit ()) vp.y = wide_cockpit_position[wide_cockpit_nr].c.y; insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_adi_inst3d->vp.position, virtual_cockpit_adi_inst3d); } // // large ADI // if (flags & VIRTUAL_COCKPIT_LARGE_ADI) { search.search_depth = 0; search.search_object = virtual_cockpit_large_adi_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ADI; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { float heading, pitch, roll; get_blackhawk_virtual_cockpit_adi_angles (vp.attitude, &heading, &pitch, &roll); search.result_sub_object->relative_heading = -heading; search.result_sub_object->relative_pitch = pitch; search.result_sub_object->relative_roll = -roll; } memcpy (&virtual_cockpit_large_adi_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_large_adi_inst3d->vp.position, virtual_cockpit_large_adi_inst3d); } draw_3d_scene (); end_3d_scene (); } } //////////////////////////////////////// // // rendered wiper // //////////////////////////////////////// if (flags & VIRTUAL_COCKPIT_RENDERED_WIPER) { if (wiper_mode == WIPER_MODE_STOWED) { ASSERT (wiper_rle_graphic); if (lock_screen (active_screen)) { blit_rle_graphic (wiper_rle_graphic, ix_640_480, iy_640_480); unlock_screen (active_screen); } } } //////////////////////////////////////// // // rain effect // //////////////////////////////////////// if (flags & VIRTUAL_COCKPIT_RAIN_EFFECT) { if (rain_mode != RAIN_MODE_DRY) { set_3d_active_environment (main_3d_env); set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_env); recalculate_3d_environment_settings (main_3d_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { draw_blackhawk_virtual_cockpit_rain_effect (&vp); draw_3d_scene (); end_3d_scene (); } } } //////////////////////////////////////// // // tidy up // //////////////////////////////////////// #if RECOGNITION_GUIDE set_3d_view_distances (main_3d_env, 10000.0, 100.0, 1.0, 0.0); #else set_3d_view_distances (main_3d_env, 10000.0, 1.0, 1.0, 0.0); #endif realise_3d_clip_extents (main_3d_env); }
void draw_havoc_virtual_cockpit_wiper (viewpoint *vp, int large_hud) { object_3d_instance *wiper_arm_inst3d, *wiper_rod_inst3d; object_3d_sub_object_search_data search; ASSERT (vp); if (large_hud) { wiper_arm_inst3d = virtual_cockpit_large_hud_wiper_arm_inst3d; wiper_rod_inst3d = virtual_cockpit_large_hud_wiper_rod_inst3d; } else { wiper_arm_inst3d = virtual_cockpit_wiper_arm_inst3d; wiper_rod_inst3d = virtual_cockpit_wiper_rod_inst3d; } // // rotate wiper arm // search.search_depth = 0; search.search_object = wiper_arm_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_HAVOC_VIRTUAL_COCKPIT_WIPER_ARM; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = wiper_position * (rad (65.3756) / MAX_WIPER_POSITION); } // // rotate wiper blade // search.search_depth = 0; search.search_object = wiper_arm_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_HAVOC_VIRTUAL_COCKPIT_WIPER_BLADE; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = (wiper_position * (rad (-74.7756) / MAX_WIPER_POSITION)) + rad (4.7); } // // rotate wiper rod // search.search_depth = 0; search.search_object = wiper_rod_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_HAVOC_VIRTUAL_COCKPIT_WIPER_ROD; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = wiper_position * (rad (65.3756) / MAX_WIPER_POSITION); } // // draw wiper arm and blade // memcpy (&wiper_arm_inst3d->vp, vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &wiper_arm_inst3d->vp.position, wiper_arm_inst3d); // // draw wiper rod // memcpy (&wiper_rod_inst3d->vp, vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &wiper_rod_inst3d->vp.position, wiper_rod_inst3d); }
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"); } }
void draw_hokum_virtual_cockpit (void) { int draw_main_rotors; float theta; object_3d_instance *inst3d; object_3d_sub_object_search_data search; switch (get_view_mode ()) { case VIEW_MODE_VIRTUAL_COCKPIT_CREW: case VIEW_MODE_VIRTUAL_COCKPIT_HUD: case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY: { break; } default: { if (!get_global_draw_cockpit_graphics ()) { draw_external_hokum_hud (); return; } break; } } // // lamps and instruments // draw_hokum_virtual_cockpit_lamps (); draw_hokum_virtual_cockpit_instruments (); // // crew animation // set_hokum_crew_head_positions (); // // animate main rotors // if (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_MAIN_ROTOR_DAMAGED)) { animate_damaged_helicopter_main_rotors (get_gunship_entity (), TRUE); } else { animate_helicopter_main_rotors (get_gunship_entity (), TRUE, FALSE); } inst3d = get_local_entity_ptr_value (get_gunship_entity (), PTR_TYPE_INSTANCE_3D_OBJECT); theta = get_rotation_angle_of_helicopter_main_rotors (inst3d); set_rotation_angle_of_helicopter_main_rotors (virtual_cockpit_inst3d, theta); animate_helicopter_virtual_cockpit_main_rotors (get_gunship_entity (), virtual_cockpit_inst3d); draw_main_rotors = TRUE; if (get_global_glass_cockpit ()) { draw_main_rotors = FALSE; } else { if (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CREW) { if (get_helicopter_main_rotors_blurred (get_gunship_entity ())) { if (!get_global_blurred_main_rotors_visible_from_cockpit ()) { draw_main_rotors = FALSE; } } } } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_MAIN_ROTOR_SHAFT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_main_rotors; } search.search_depth = 1; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_MAIN_ROTOR_SHAFT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_main_rotors; } // // animate electro-optics // animate_hokum_virtual_cockpit_eo (virtual_cockpit_inst3d); // // animate wipers // animate_hokum_wipers (virtual_cockpit_inst3d); // // draw 3D scene // set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_env); recalculate_3d_environment_settings (main_3d_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { // // light direction is in world coordinates // light_3d_source *display_backlight, *cockpit_light; vec3d direction; matrix3x3 m1, m2; if (get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE) == DAY_SEGMENT_TYPE_DAY) { //////////////////////////////////////// // // DAY LIGHTING // //////////////////////////////////////// if (night_vision_system_active && (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CREW)) { // // active night vision system // get_3d_transformation_matrix (m1, rad (0.0), rad (135.0), rad (0.0)); multiply_matrix3x3_matrix3x3 (m2, m1, virtual_cockpit_inst3d->vp.attitude); direction.x = m2[2][0]; direction.y = m2[2][1]; direction.z = m2[2][2]; cockpit_light = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.5000, 0.4000, 0.0000); insert_light_3d_source_into_3d_scene (cockpit_light); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); end_3d_scene (); remove_light_3d_source_from_3d_scene (cockpit_light); destroy_light_3d_source (cockpit_light); } else { // // inactive night vision system // insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); end_3d_scene (); } } else { //////////////////////////////////////// // // NIGHT LIGHTING // //////////////////////////////////////// direction.x = virtual_cockpit_inst3d->vp.zv.x; direction.y = virtual_cockpit_inst3d->vp.zv.y; direction.z = virtual_cockpit_inst3d->vp.zv.z; display_backlight = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.2500, 0.0980, 0.0000); if (night_vision_system_active && (get_view_mode () != VIEW_MODE_VIRTUAL_COCKPIT_CREW)) { // // active night vision system // get_3d_transformation_matrix (m1, rad (0.0), rad (135.0), rad (0.0)); multiply_matrix3x3_matrix3x3 (m2, m1, virtual_cockpit_inst3d->vp.attitude); direction.x = m2[2][0]; direction.y = m2[2][1]; direction.z = m2[2][2]; cockpit_light = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.5000, 0.4000, 0.0000); } else { // // inactive night vision system // direction.x = virtual_cockpit_inst3d->vp.yv.x; direction.y = virtual_cockpit_inst3d->vp.yv.y; direction.z = virtual_cockpit_inst3d->vp.yv.z; cockpit_light = create_light_3d_source (LIGHT_3D_TYPE_DIRECTIONAL, FALSE, &direction, 0, 0.0666, 0.1098, 0.6431); } insert_light_3d_source_into_3d_scene (display_backlight); insert_light_3d_source_into_3d_scene (cockpit_light); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); end_3d_scene (); remove_light_3d_source_from_3d_scene (display_backlight); remove_light_3d_source_from_3d_scene (cockpit_light); destroy_light_3d_source (display_backlight); destroy_light_3d_source (cockpit_light); } } #if RECOGNITION_GUIDE set_3d_view_distances (main_3d_env, 10000.0, 100.0, 1.0, 0.0); #else set_3d_view_distances (main_3d_env, 10000.0, 1.0, 1.0, 0.0); #endif realise_3d_clip_extents (main_3d_env); }
void update_hokum_virtual_cockpit (void) { int draw_glass_cockpit, draw_controls, draw_crew, draw_seats; cockpit_detail_levels cockpit_detail_level; object_3d_sub_object_search_data search; //////////////////////////////////////// // // sort out what to draw // //////////////////////////////////////// switch (get_view_mode ()) { case VIEW_MODE_VIRTUAL_COCKPIT_CREW: { cockpit_detail_level = COCKPIT_DETAIL_LEVEL_HIGH; draw_glass_cockpit = FALSE; draw_controls = TRUE; break; } case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY: case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY: { cockpit_detail_level = COCKPIT_DETAIL_LEVEL_HIGH; draw_glass_cockpit = FALSE; draw_controls = FALSE; break; } default: { cockpit_detail_level = get_global_cockpit_detail_level (); draw_glass_cockpit = get_global_glass_cockpit (); draw_controls = !draw_glass_cockpit; break; } } // // select 3D instance // if (draw_glass_cockpit) { if (virtual_cockpit_inst3d != virtual_cockpit_inst3d_detail_level_glass_inst3d) { virtual_cockpit_inst3d_detail_level_glass_inst3d->vp = virtual_cockpit_inst3d->vp; virtual_cockpit_inst3d = virtual_cockpit_inst3d_detail_level_glass_inst3d; } draw_crew = FALSE; } else { switch (cockpit_detail_level) { //////////////////////////////////////// case COCKPIT_DETAIL_LEVEL_LOW: //////////////////////////////////////// { if (virtual_cockpit_inst3d != virtual_cockpit_inst3d_detail_level_low_inst3d) { virtual_cockpit_inst3d_detail_level_low_inst3d->vp = virtual_cockpit_inst3d->vp; virtual_cockpit_inst3d = virtual_cockpit_inst3d_detail_level_low_inst3d; } draw_crew = FALSE; break; } //////////////////////////////////////// case COCKPIT_DETAIL_LEVEL_MEDIUM: //////////////////////////////////////// { if (virtual_cockpit_inst3d != virtual_cockpit_inst3d_detail_level_medium_inst3d) { virtual_cockpit_inst3d_detail_level_medium_inst3d->vp = virtual_cockpit_inst3d->vp; virtual_cockpit_inst3d = virtual_cockpit_inst3d_detail_level_medium_inst3d; } draw_crew = TRUE; break; } //////////////////////////////////////// case COCKPIT_DETAIL_LEVEL_HIGH: //////////////////////////////////////// { if (virtual_cockpit_inst3d != virtual_cockpit_inst3d_detail_level_high_inst3d) { virtual_cockpit_inst3d_detail_level_high_inst3d->vp = virtual_cockpit_inst3d->vp; virtual_cockpit_inst3d = virtual_cockpit_inst3d_detail_level_high_inst3d; } draw_crew = TRUE; break; } } } // // HUD view // if (get_view_mode () == VIEW_MODE_VIRTUAL_COCKPIT_HUD) { draw_crew = FALSE; } // // ejected // draw_seats = TRUE; if (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_EJECTED)) { if (get_view_mode () == VIEW_MODE_VIRTUAL_COCKPIT_CREW) { draw_controls = FALSE; } else { draw_crew = FALSE; draw_seats = FALSE; } } // // draw crew // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_PILOT_POSITION; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_crew; } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_WSO_POSITION; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_crew; } // // draw seats // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_KA52_EJECTOR_SEAT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_seats; } search.search_depth = 1; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_KA52_EJECTOR_SEAT; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_seats; } // // draw controls // search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_PILOT_JOYSTICK; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_controls; } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_PILOT_COLLECTIVE; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_controls; } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_PILOT_PEDAL; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_controls; } search.search_depth = 1; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_PILOT_PEDAL; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_controls; } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_WSO_JOYSTICK; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_controls; } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_WSO_COLLECTIVE; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_controls; } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_WSO_PEDAL; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_controls; } search.search_depth = 1; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_WSO_PEDAL; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_controls; } //////////////////////////////////////// // // update animations // //////////////////////////////////////// // // crew animation // update_hokum_crew_animation (); // // canopy doors // animate_hokum_virtual_cockpit_canopy_doors (); //////////////////////////////////////// // // sort static hands // //////////////////////////////////////// if (!draw_crew) { search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_PILOT_HAND_STATIC; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = FALSE; } search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_COCKPIT_WSO_HAND_STATIC; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = FALSE; } } }
void set_comanche_stub_wing_visibility (entity *en) { weapon_package_status *package_status; weapon_config_types config_type; object_3d_sub_object_search_data search; object_3d_instance *inst3d; int depth, package, stub_wings_required; ASSERT (en); if (get_local_entity_int_value (en, INT_TYPE_ENTITY_SUB_TYPE) != ENTITY_SUB_TYPE_AIRCRAFT_RAH66_COMANCHE) { return; } // // search packages for stub wings (include empty and damaged weapons) // stub_wings_required = FALSE; package_status = (weapon_package_status *) get_local_entity_ptr_value (en, PTR_TYPE_WEAPON_PACKAGE_STATUS_ARRAY); if (package_status) { config_type = (weapon_config_types) get_local_entity_int_value (en, INT_TYPE_WEAPON_CONFIG_TYPE); ASSERT (weapon_config_type_valid (config_type)); for (package = 0; package < NUM_WEAPON_PACKAGES; package++) { if (weapon_config_database[config_type][package].sub_type == ENTITY_SUB_TYPE_WEAPON_NO_WEAPON) { break; } if ( (weapon_config_database[config_type][package].heading_depth == COMANCHE_LHS_STUB_WING) || (weapon_config_database[config_type][package].heading_depth == COMANCHE_RHS_STUB_WING) ) { stub_wings_required = TRUE; break; } } } // // set visibility status // inst3d = (object_3d_instance *) get_local_entity_ptr_value (en, PTR_TYPE_INSTANCE_3D_OBJECT); ASSERT (inst3d); depth = 0; while (TRUE) { search.search_object = inst3d; search.search_depth = depth; search.sub_object_index = OBJECT_3D_SUB_OBJECT_STUBWINGS; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = stub_wings_required; } else { break; } depth++; } }
void draw_default_internal_virtual_cockpit_3d (unsigned int flags) { viewpoint vp; object_3d_sub_object_search_data search; object_3d_instance *virtual_cockpit_inst3d; //#ifndef DEBUG_WIDEVIEW set_global_wide_cockpit(FALSE); edit_wide_cockpit = FALSE; //#endif //////////////////////////////////////// // // virtual cockpit viewpoint is placed at the main object origin // //////////////////////////////////////// vp.x = 0.0; vp.y = 0.0; vp.z = 0.0; get_local_entity_attitude_matrix (get_gunship_entity (), vp.attitude); //////////////////////////////////////// // // render displays onto textures (before draw 3D scenes) // //////////////////////////////////////// if (flags & VIRTUAL_COCKPIT_UPFRONT_DISPLAY) { draw_default_upfront_display_on_texture (); } if (flags & VIRTUAL_COCKPIT_LHS_MFD_DISPLAY) { draw_default_mfd_on_texture (MFD_LOCATION_LHS); } if (flags & VIRTUAL_COCKPIT_RHS_MFD_DISPLAY) { draw_default_mfd_on_texture (MFD_LOCATION_RHS); } //////////////////////////////////////// // // draw 3D scene with lighting // //////////////////////////////////////// if (flags & (VIRTUAL_COCKPIT_COCKPIT)) { set_cockpit_white_lighting (vp.attitude); set_3d_active_environment (main_3d_single_light_env); set_3d_view_distances (main_3d_single_light_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_single_light_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { // // virtual cockpit // if (flags & VIRTUAL_COCKPIT_COCKPIT) { switch (get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE)) { //////////////////////////////////////// case DAY_SEGMENT_TYPE_DAWN: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_level2_inst3d; break; } //////////////////////////////////////// case DAY_SEGMENT_TYPE_DAY: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_level1_inst3d; break; } //////////////////////////////////////// case DAY_SEGMENT_TYPE_DUSK: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_level2_inst3d; break; } //////////////////////////////////////// case DAY_SEGMENT_TYPE_NIGHT: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_level3_inst3d; break; } } #if DEMO_VERSION virtual_cockpit_inst3d = virtual_cockpit_level1_inst3d; #endif //VJ 28 is the subobject number of the pilot get_default_crew_viewpoint (28, virtual_cockpit_inst3d); virtual_cockpit_inst3d->vp.x += BASE_DX; virtual_cockpit_inst3d->vp.y += BASE_DY; virtual_cockpit_inst3d->vp.z += BASE_DZ; if (get_global_wide_cockpit ()) { virtual_cockpit_inst3d->vp.x += wide_cockpit_position[wide_cockpit_nr].c.x; virtual_cockpit_inst3d->vp.y += wide_cockpit_position[wide_cockpit_nr].c.y; virtual_cockpit_inst3d->vp.z += wide_cockpit_position[wide_cockpit_nr].c.z; //VJ 050207 included head pitch in fixed view setting pilot_head_pitch_datum = rad ( wide_cockpit_position[wide_cockpit_nr].c.p ); } //use subnr to eliminate each sub_object one by one, in edit_wide_view press the end key // virtual_cockpit_inst3d->sub_objects[subnr].visible_object = FALSE; //rotor virtual_cockpit_inst3d->sub_objects[1].visible_object = FALSE; //pilots (28 is back, 29 is front) virtual_cockpit_inst3d->sub_objects[28].visible_object = FALSE; virtual_cockpit_inst3d->sub_objects[29].visible_object = FALSE; //wipers virtual_cockpit_inst3d->sub_objects[37].visible_object = FALSE; // don't do this because it mersses up change smade to virtual_cockpit_inst3d // memcpy (&virtual_cockpit_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); } //C:\gms\Razorworks\eech-new\modules\3d\3dobjbuf.c draw_3d_scene (); print_edit_wide_cockpit (); end_3d_scene (); } } //////////////////////////////////////// // // draw 3D scene with lighting // //////////////////////////////////////// if (flags & (VIRTUAL_COCKPIT_INSTRUMENT_NEEDLES | VIRTUAL_COCKPIT_INSTRUMENT_LARGE_NEEDLES)) { set_cockpit_lighting (vp.attitude); set_3d_active_environment (main_3d_single_light_env); set_3d_view_distances (main_3d_single_light_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_single_light_env); //VJ# /* vp.x = wide_cockpit_position[wide_cockpit_nr].c.x; vp.y = wide_cockpit_position[wide_cockpit_nr].c.y; vp.z = wide_cockpit_position[wide_cockpit_nr].c.z; vp.x += dx; vp.y += dy; vp.z += dz; */ vp.x = BASE_DX; vp.y = BASE_DY - 0.0800; vp.z = BASE_DZ; clear_zbuffer_screen (); if (begin_3d_scene ()) { // // instrument needles // if (flags & VIRTUAL_COCKPIT_INSTRUMENT_NEEDLES) { // // ADI slip // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ADI_SIDE_SLIP; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = get_default_virtual_cockpit_adi_slip_indicator_needle_value (); } // // airspeed // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_AIRSPEED; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_virtual_cockpit_needles_on_fixed_cockpits; search.result_sub_object->relative_roll = get_default_virtual_cockpit_airspeed_indicator_needle_value (); } // // altimeter // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ALTIMETER; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_virtual_cockpit_needles_on_fixed_cockpits; search.result_sub_object->relative_roll = get_default_virtual_cockpit_barometric_altimeter_needle_value (); } // // clock // { float hours, minutes, seconds; // // only read clock values if drawing virtual cockpit needles to prevent speeding up clock debug values // if (draw_virtual_cockpit_needles_on_fixed_cockpits) { get_default_virtual_cockpit_clock_hand_values (&hours, &minutes, &seconds); } else { hours = 0.0; minutes = 0.0; seconds = 0.0; } // // hour hand // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_CLOCK_HOUR_HAND; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_virtual_cockpit_needles_on_fixed_cockpits; search.result_sub_object->relative_roll = hours; } // // minute hand // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_CLOCK_MINUTE_HAND; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_virtual_cockpit_needles_on_fixed_cockpits; search.result_sub_object->relative_roll = minutes; } // // second hand // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_CLOCK_SECOND_HAND; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->visible_object = draw_virtual_cockpit_needles_on_fixed_cockpits; search.result_sub_object->relative_roll = seconds; } } memcpy (&virtual_cockpit_instrument_needles_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_instrument_needles_inst3d->vp.position, virtual_cockpit_instrument_needles_inst3d); } // // instrument large needles // if (flags & VIRTUAL_COCKPIT_INSTRUMENT_LARGE_NEEDLES) { // // ADI slip // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_large_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_ADI_SIDE_SLIP; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = get_default_virtual_cockpit_adi_slip_indicator_needle_value (); } // // airspeed // search.search_depth = 0; search.search_object = virtual_cockpit_instrument_large_needles_inst3d; search.sub_object_index = OBJECT_3D_SUB_OBJECT_APACHE_VIRTUAL_COCKPIT_AIRSPEED; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { search.result_sub_object->relative_roll = get_default_virtual_cockpit_airspeed_indicator_needle_value (); } memcpy (&virtual_cockpit_instrument_large_needles_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_instrument_large_needles_inst3d->vp.position, virtual_cockpit_instrument_large_needles_inst3d); } draw_3d_scene (); end_3d_scene (); } } //////////////////////////////////////// // // draw 3D scene without lighting // //////////////////////////////////////// if ( (flags & VIRTUAL_COCKPIT_DISPLAY_VIEW) && (flags & VIRTUAL_COCKPIT_LHS_MFD_DISPLAY) && (flags & VIRTUAL_COCKPIT_RHS_MFD_DISPLAY) ) { set_3d_active_environment (main_3d_env); set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_env); recalculate_3d_environment_settings (main_3d_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { // // lhs mfd // memcpy (&virtual_cockpit_display_view_mfd_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_display_view_mfd_inst3d->vp.position, virtual_cockpit_display_view_mfd_inst3d); // // rhs mfd // memcpy (&virtual_cockpit_display_view_mfd_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_display_view_mfd_inst3d->vp.position, virtual_cockpit_display_view_mfd_inst3d); draw_3d_scene (); end_3d_scene (); } } else { if (flags & (VIRTUAL_COCKPIT_UPFRONT_DISPLAY | VIRTUAL_COCKPIT_LHS_MFD_DISPLAY | VIRTUAL_COCKPIT_RHS_MFD_DISPLAY)) { set_3d_active_environment (main_3d_env); set_3d_view_distances (main_3d_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_env); recalculate_3d_environment_settings (main_3d_env); clear_zbuffer_screen (); // vp.x = wide_cockpit_position[wide_cockpit_nr].c.x; // vp.y = wide_cockpit_position[wide_cockpit_nr].c.y; // vp.z = wide_cockpit_position[wide_cockpit_nr].c.z; if (begin_3d_scene ()) { // // up-front display // vp.y = BASE_DY - 0.0800 - _DY; if (flags & VIRTUAL_COCKPIT_UPFRONT_DISPLAY) { vp.y -= 0.01; memcpy (&virtual_cockpit_upfront_display_inst3d->vp, &vp, sizeof (viewpoint)); vp.y += 0.01; // virtual_cockpit_upfront_display_inst3d->vp.position.y = dy; insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_upfront_display_inst3d->vp.position, virtual_cockpit_upfront_display_inst3d); } // // lhs mfd // if (flags & VIRTUAL_COCKPIT_LHS_MFD_DISPLAY) { memcpy (&virtual_cockpit_lhs_mfd_inst3d->vp, &vp, sizeof (viewpoint)); //virtual_cockpit_lhs_mfd_inst3d->vp.position.x += dx; insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_lhs_mfd_inst3d->vp.position, virtual_cockpit_lhs_mfd_inst3d); } // // rhs mfd // if (flags & VIRTUAL_COCKPIT_RHS_MFD_DISPLAY) { memcpy (&virtual_cockpit_rhs_mfd_inst3d->vp, &vp, sizeof (viewpoint)); //virtual_cockpit_rhs_mfd_inst3d->vp.position.x -= dx; insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_rhs_mfd_inst3d->vp.position, virtual_cockpit_rhs_mfd_inst3d); } draw_3d_scene (); end_3d_scene (); } } } //////////////////////////////////////// // // draw 3D scene with lighting // //////////////////////////////////////// // // draw fillet to mask TADS display // if ( (d3d_can_render_to_texture) && (flags & (VIRTUAL_COCKPIT_COCKPIT)) && (flags & (VIRTUAL_COCKPIT_LHS_MFD_DISPLAY)) && (flags & (VIRTUAL_COCKPIT_RHS_MFD_DISPLAY)) ) { set_cockpit_white_lighting (vp.attitude); set_3d_active_environment (main_3d_single_light_env); set_3d_view_distances (main_3d_single_light_env, 10.0, 0.1, 1.0, 0.0); realise_3d_clip_extents (main_3d_single_light_env); clear_zbuffer_screen (); if (begin_3d_scene ()) { switch (get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE)) { //////////////////////////////////////// case DAY_SEGMENT_TYPE_DAWN: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_fillet_level2_inst3d; break; } //////////////////////////////////////// case DAY_SEGMENT_TYPE_DAY: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_fillet_level1_inst3d; break; } //////////////////////////////////////// case DAY_SEGMENT_TYPE_DUSK: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_fillet_level2_inst3d; break; } //////////////////////////////////////// case DAY_SEGMENT_TYPE_NIGHT: //////////////////////////////////////// { virtual_cockpit_inst3d = virtual_cockpit_fillet_level3_inst3d; break; } } #if DEMO_VERSION virtual_cockpit_inst3d = virtual_cockpit_fillet_level1_inst3d; #endif //VJ# vp.x = BASE_DX; vp.y = BASE_DY - 0.086 - _DY; vp.z = BASE_DZ-0.010; memcpy (&virtual_cockpit_inst3d->vp, &vp, sizeof (viewpoint)); insert_relative_object_into_3d_scene (OBJECT_3D_DRAW_TYPE_ZBUFFERED_OBJECT, &virtual_cockpit_inst3d->vp.position, virtual_cockpit_inst3d); draw_3d_scene (); end_3d_scene (); } } //draw_default_indicator_lamps_3d (); //draw_default_lamp_on_texture (); //VJ wideview mod, date: 18-mar-03 #if DEBUG_WIDEVIEW if (edit_wide_cockpit) { if (check_key(DIK_NUMPAD7)) { system_sleep(20); dy+= 0.002; } if (check_key(DIK_NUMPAD9)) { system_sleep(20); dy-= 0.002; } if (check_key(DIK_NUMPADSLASH)) { system_sleep(20); dx+= 0.002; } if (check_key(DIK_NUMPADSTAR)) { system_sleep(20); dx-= 0.002; } if (check_key(DIK_NUMPADMINUS)) { system_sleep(20); dz+= 0.002; } if (check_key(DIK_NUMPADPLUS)) { system_sleep(20); dz-= 0.002; } if (check_key(DIK_END)) { system_sleep (100); subnr++; } if (check_key(DIK_NUMPAD0)) { dx = 0; dy = 0; dz = 0; } } #endif move_edit_wide_cockpit (); //////////////////////////////////////// // // tidy up // //////////////////////////////////////// #if RECOGNITION_GUIDE set_3d_view_distances (main_3d_env, 10000.0, 100.0, 1.0, 0.0); #else set_3d_view_distances (main_3d_env, 10000.0, 1.0, 1.0, 0.0); #endif realise_3d_clip_extents (main_3d_env); }
regeneration_building_types get_object_3d_regeneration_type ( object_3d_index_numbers object, int *landing_sub_type ) { ASSERT ( object > OBJECT_3D_INVALID_OBJECT_INDEX ); ASSERT ( object < OBJECT_3D_LAST ); *landing_sub_type = NUM_ENTITY_SUB_TYPE_LANDINGS; if ( regeneration_object_database[object].regeneration_sub_type == NUM_ENTITY_SUB_TYPE_REGENS ) { object_3d_instance *object_instance; object_3d_sub_object_search_data search; object_instance = construct_3d_object ( object ); search.search_object = object_instance; search.search_depth = 0; search.sub_object_index = OBJECT_3D_SUB_OBJECT_REGEN_FIXED_WING; if ( find_object_3d_sub_object ( &search ) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND ) { regeneration_object_database[object].regeneration_sub_type = ENTITY_SUB_TYPE_REGEN_FIXED_WING; *landing_sub_type = ENTITY_SUB_TYPE_LANDING_FIXED_WING; } search.search_object = object_instance; search.search_depth = 0; search.sub_object_index = OBJECT_3D_SUB_OBJECT_REGEN_HELICOPTER; if ( find_object_3d_sub_object ( &search ) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND ) { regeneration_object_database[object].regeneration_sub_type = ENTITY_SUB_TYPE_REGEN_HELICOPTER; *landing_sub_type = ENTITY_SUB_TYPE_LANDING_HELICOPTER; } search.search_object = object_instance; search.search_depth = 0; search.sub_object_index = OBJECT_3D_SUB_OBJECT_REGEN_ROUTED_VEHICLE; if ( find_object_3d_sub_object ( &search ) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND ) { regeneration_object_database[object].regeneration_sub_type = ENTITY_SUB_TYPE_REGEN_GROUND; *landing_sub_type = ENTITY_SUB_TYPE_LANDING_GROUND; } search.search_object = object_instance; search.search_depth = 0; search.sub_object_index = OBJECT_3D_SUB_OBJECT_REGEN_PERSON; if ( find_object_3d_sub_object ( &search ) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND ) { regeneration_object_database[object].regeneration_sub_type = ENTITY_SUB_TYPE_REGEN_PEOPLE; *landing_sub_type = ENTITY_SUB_TYPE_LANDING_PEOPLE; } /* search.object = object_instance; search.search_depth = 0; search.sub_object_index = OBJECT_3D_SUB_OBJECT_REGEN_SHIP_VEHICLE; if ( find_object_3d_sub_object ( &search ) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND ) { regeneration_object_database[object].regeneration_sub_type = ENTITY_SUB_TYPE_REGEN_SHIP_VEHICLE; *landing_sub_type = ENTITY_SUB_TYPE_LANDING_SEA; } */ destruct_3d_object ( object_instance ); if ( regeneration_object_database[object].regeneration_sub_type == NUM_ENTITY_SUB_TYPE_REGENS ) { regeneration_object_database[object].regeneration_sub_type = ENTITY_SUB_TYPE_REGEN_NONE; } } switch ( regeneration_object_database[object].regeneration_sub_type ) { case ENTITY_SUB_TYPE_REGEN_FIXED_WING: { *landing_sub_type = ENTITY_SUB_TYPE_LANDING_FIXED_WING; break; } case ENTITY_SUB_TYPE_REGEN_HELICOPTER: { *landing_sub_type = ENTITY_SUB_TYPE_LANDING_HELICOPTER; break; } case ENTITY_SUB_TYPE_REGEN_GROUND: { *landing_sub_type = ENTITY_SUB_TYPE_LANDING_GROUND; break; } case ENTITY_SUB_TYPE_REGEN_PEOPLE: { *landing_sub_type = ENTITY_SUB_TYPE_LANDING_PEOPLE; break; } case ENTITY_SUB_TYPE_REGEN_NONE: { *landing_sub_type = NUM_ENTITY_SUB_TYPE_LANDINGS; break; } default: { debug_fatal ( "REGEN: unknown regen type" ); } } return ( regeneration_object_database[object].regeneration_sub_type ); }
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; }
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)); }