Пример #1
0
void restore_kiowa_virtual_cockpit_main_rotors (void)
{
	float
		theta;

	object_3d_instance
		*inst3d;

	ASSERT (get_gunship_entity ());

	ASSERT (virtual_cockpit_inst3d_detail_level_normal_inst3d);
	ASSERT (virtual_cockpit_inst3d_detail_level_glass_inst3d);

	inst3d = (object_3d_instance *) get_local_entity_ptr_value (get_gunship_entity (), PTR_TYPE_INSTANCE_3D_OBJECT);

	ASSERT (inst3d);

	theta = get_rotation_angle_of_helicopter_main_rotors (inst3d);

	set_rotation_angle_of_helicopter_main_rotors (virtual_cockpit_inst3d_detail_level_normal_inst3d, theta);
	set_rotation_angle_of_helicopter_main_rotors (virtual_cockpit_inst3d_detail_level_glass_inst3d, theta);

	animate_helicopter_virtual_cockpit_main_rotors (get_gunship_entity (), virtual_cockpit_inst3d_detail_level_normal_inst3d);
	animate_helicopter_virtual_cockpit_main_rotors (get_gunship_entity (), virtual_cockpit_inst3d_detail_level_glass_inst3d);

	restore_helicopter_main_rotor_inst3d (virtual_cockpit_inst3d_detail_level_normal_inst3d);
	restore_helicopter_main_rotor_inst3d (virtual_cockpit_inst3d_detail_level_glass_inst3d);
}
Пример #2
0
void update_weapon_load_shared_mem ()
{
	weapon_package_status
		*package_status;

	unsigned next_free = 0;

	if (!gPtrSharedMemory || !get_gunship_entity())
		return;

	package_status = (weapon_package_status *) get_local_entity_ptr_value(get_gunship_entity(), PTR_TYPE_WEAPON_PACKAGE_STATUS_ARRAY);

	if (package_status)
	{
		int package;
		weapon_config_types config_type = (weapon_config_types) get_local_entity_int_value (get_gunship_entity(), INT_TYPE_WEAPON_CONFIG_TYPE);

		for (package = 0; package < MAX_WEAPON_LOAD_DATA; package++)
		{
			entity_sub_types weapon_type;
			int number;

			weapon_type = weapon_config_database[config_type][package].sub_type;
			number = package_status[package].number;

			gPtrSharedMemory->weapon_load[next_free].weapon_type = weapon_type;
			gPtrSharedMemory->weapon_load[next_free].weapon_count = number;
			next_free++;
		}
	}
	else
		memset(gPtrSharedMemory->weapon_load, 0, sizeof(gPtrSharedMemory->weapon_load));
}
Пример #3
0
static void update_recognition_guide_camera (camera *raw, object_3d_camera_index_numbers index)
{
	entity
		*en;

	object_3d_instance
		*inst3d;

	viewpoint
		vp;

	//
	// pre-amble
	//

	ASSERT (raw);

	ASSERT (raw->external_view_entity);

	en = raw->external_view_entity;

	//
	// get camera position and attitude
	//

	inst3d = (object_3d_instance *) get_local_entity_ptr_value (en, PTR_TYPE_INSTANCE_3D_OBJECT);

	ASSERT (inst3d);

	set_3d_exclusive_instance ( inst3d );

	get_local_entity_vec3d (en, VEC3D_TYPE_POSITION, &inst3d->vp.position);

	get_local_entity_attitude_matrix (en, inst3d->vp.attitude);

	get_object_3d_camera_position (inst3d, index, 0, 0.0, &vp);

	raw->position = vp.position;

	memcpy (raw->attitude, vp.attitude, sizeof (matrix3x3));

	//
	// keep point above ground (unless point off map)
	//

	if (point_inside_map_area (&raw->position))
	{
		raw->position.y = max (raw->position.y, get_3d_terrain_point_data (raw->position.x, raw->position.z, &raw->terrain_info) + 0.5f);
	}

	//
	// motion vector
	//

	get_local_entity_vec3d (en, VEC3D_TYPE_MOTION_VECTOR, &raw->motion_vector);
}
Пример #4
0
void initialise_attack_guide (entity *en)
{
	entity
		*task,
		*aggressor,
		*target;

	ASSERT (en);

	task = get_local_entity_parent (en, LIST_TYPE_GUIDE);

	ASSERT (task);

	ASSERT (get_local_entity_int_value (task, INT_TYPE_ENTITY_SUB_TYPE) == ENTITY_SUB_TYPE_TASK_ENGAGE);

	aggressor = get_local_entity_ptr_value (en, PTR_TYPE_TASK_LEADER);

	ASSERT (aggressor);

	target = get_local_entity_parent (task, LIST_TYPE_TASK_DEPENDENT);

	ASSERT (target);

	if (!get_local_entity_int_value (aggressor, INT_TYPE_IDENTIFY_AIRCRAFT))
	{
		//
		// Surface-Air & Surface-Surface
		//

		entity_sub_types
			best_weapon;

		//
		// find best weapon for target
		//

		best_weapon = get_best_weapon_for_target (aggressor, target, BEST_WEAPON_CRITERIA_ALL);
	
		set_client_server_entity_int_value (aggressor, INT_TYPE_SELECTED_WEAPON, best_weapon);

		return;
	}

	//
	// Air-Air & Air-Surface
	//

	if (get_local_entity_int_value (target, INT_TYPE_AIRBORNE_AIRCRAFT))
	{			
		initialise_air_to_air_attack_guide (en, aggressor, target);
	}
	else
	{
		initialise_air_to_ground_attack_guide (en, aggressor, target);
	}
}
Пример #5
0
void get_local_entity_weapon_load(entity* en, weapon_count weapon_load[], unsigned max_num_weapons)
{
    weapon_package_status
    *package_status;

    unsigned next_free = 0;

    ASSERT(en);
    ASSERT(weapon_load);
    ASSERT(max_num_weapons > 0);

    package_status = (weapon_package_status *) get_local_entity_ptr_value(en, PTR_TYPE_WEAPON_PACKAGE_STATUS_ARRAY);

    if (package_status)
    {
        int package;
        weapon_config_types config_type = (weapon_config_types) get_local_entity_int_value (en, INT_TYPE_WEAPON_CONFIG_TYPE);

        for (package = 0; package < NUM_WEAPON_PACKAGES; package++)
        {
            entity_sub_types weapon_type;
            int number;

            if (weapon_config_database[config_type][package].sub_type == ENTITY_SUB_TYPE_WEAPON_NO_WEAPON)
                break;

            if (!package_status[package].damaged)
            {
                unsigned i;

                weapon_type = weapon_config_database[config_type][package].sub_type;
                number = package_status[package].number;

                for (i=0; i < next_free; i++)
                {
                    if (weapon_load[i].weapon_type == weapon_type)
                    {
                        weapon_load[i].count += number;
                        break;
                    }
                }

                if (i == next_free && next_free <= max_num_weapons-1 && weapon_type != ENTITY_SUB_TYPE_WEAPON_NO_WEAPON)  // weapon not in array already
                {
                    next_free++;
                    weapon_load[i].weapon_type = weapon_type;
                    weapon_load[i].count = number;
                }
            }
        }
    }

    weapon_load[next_free].weapon_type = ENTITY_SUB_TYPE_WEAPON_NO_WEAPON;
}
Пример #6
0
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);
}
Пример #7
0
static vec3d *get_local_vec3d_ptr (entity *en, vec3d_types type)
{
	group
		*raw;

	vec3d
		*v;

	raw = (group *) get_local_entity_data (en);

	switch (type)
	{
		////////////////////////////////////////
		case VEC3D_TYPE_POSITION:
		////////////////////////////////////////
		{
			entity
				*member;

			member = (entity *) get_local_entity_ptr_value (en, PTR_TYPE_GROUP_LEADER);

			if (member)
			{
				v = get_local_entity_vec3d_ptr (member, type);
			}
			else
			{
				v = NULL;
			}

			break;
		}
		////////////////////////////////////////
		case VEC3D_TYPE_LAST_KNOWN_POSITION:
		////////////////////////////////////////
		{
			v = &raw->last_known_position;

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal_invalid_vec3d_type (en, type);

			break;
		}
	}

	return (v);
}
Пример #8
0
int get_comanche_stub_wings_attached (entity *en)
{
    weapon_package_status
    *package_status;

    weapon_config_types
    config_type;

    int
    package;

    ASSERT (en);

    if (get_local_entity_int_value (en, INT_TYPE_ENTITY_SUB_TYPE) != ENTITY_SUB_TYPE_AIRCRAFT_RAH66_COMANCHE)
    {
        return (FALSE);
    }

    //
    // search packages for stub wings (include empty and damaged weapons)
    //

    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)
            )
            {
                return (TRUE);
            }
        }
    }

    return (FALSE);
}
Пример #9
0
void set_local_entity_weapon_damage (entity *en, int heading_depth, entity_sub_types weapon_sub_type, int damage)
{
    int
    package;

    weapon_package_status
    *package_status;

    weapon_config_types
    config_type;

    ASSERT (en);

    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);

        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_sub_type == ENTITY_SUB_TYPE_WEAPON_NO_WEAPON)
            {
                if (weapon_config_database[config_type][package].heading_depth == heading_depth)
                {
                    package_status[package].damaged = damage;

                    break;
                }
            }
            else
            {
                if (weapon_config_database[config_type][package].sub_type == weapon_sub_type)
                {
                    if (weapon_config_database[config_type][package].heading_depth == heading_depth)
                    {
                        package_status[package].damaged = damage;

                        break;
                    }
                }
            }
        }
    }
}
Пример #10
0
static int response_to_articulate_undercarriage (entity_messages message, entity *receiver, entity *sender, va_list pargs)
{
	vec3d
		*position;

	object_3d_instance
		*inst3d;

	sound_sample_indices
		sample_index;

	#if DEBUG_MODULE

	//debug_log_entity_message (message, receiver, sender, pargs);

	#endif

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	inst3d = (object_3d_instance *) get_local_entity_ptr_value (receiver, PTR_TYPE_INSTANCE_3D_OBJECT);

	if (inst3d)
	{
		if (object_contains_sub_object_type (inst3d, OBJECT_3D_SUB_OBJECT_UNDERCARRIAGE, 0, NULL))
		{
			position = get_local_entity_vec3d_ptr (receiver, VEC3D_TYPE_POSITION);

			sample_index = SOUND_SAMPLE_INDEX_UNDERCARRIAGE;

			create_client_server_sound_effect_entity
			(
				receiver,
				ENTITY_SIDE_NEUTRAL,
				ENTITY_SUB_TYPE_EFFECT_SOUND_MISC,
				SOUND_CHANNEL_SOUND_EFFECT,
				SOUND_LOCALITY_ALL,
				NULL, 											// position
				1.0,												// amplification
				1.0,												// Werewolf pitch
				TRUE,												// valid sound effect
				FALSE,											// looping
				1,													// sample count
				&sample_index									// sample index list
			);
		}
	}

	return (TRUE);
}
Пример #11
0
static int recognition_guide_camera_valid (camera *raw, object_3d_camera_index_numbers index)
{
	object_3d_instance
		*inst3d;

	ASSERT (raw);

	ASSERT (raw->external_view_entity);

	inst3d = (object_3d_instance *) get_local_entity_ptr_value (raw->external_view_entity, PTR_TYPE_INSTANCE_3D_OBJECT);

	ASSERT (inst3d);

	return (get_number_of_3d_object_cameras (inst3d, index) > 0);
}
Пример #12
0
int attack_guide_find_best_weapon (entity *en)
{
	entity
		*target,
		*aggressor;
		
	entity_sub_types
		best_weapon;

	//
	// check weapon
	//

	aggressor = get_local_entity_ptr_value (en, PTR_TYPE_TASK_LEADER);

	ASSERT (aggressor);

	target = get_local_entity_parent (aggressor, LIST_TYPE_TARGET);

	ASSERT (target);

	best_weapon = get_best_weapon_for_target (aggressor, target, BEST_WEAPON_RANGE_CHECK);

	if (best_weapon == ENTITY_SUB_TYPE_WEAPON_NO_WEAPON)
	{
		//
		// No suitable weapon at current range
		//
		
		best_weapon = get_best_weapon_for_target (aggressor, target, BEST_WEAPON_CRITERIA_MINIMAL);

		if (best_weapon == ENTITY_SUB_TYPE_WEAPON_NO_WEAPON)
		{
			//
			// Entity is not capable of destroying the target - abort the attack 
			//

			delete_group_member_from_engage_guide (aggressor, en, TRUE);

			return FALSE;
		}
	}

	set_client_server_entity_int_value (aggressor, INT_TYPE_SELECTED_WEAPON, best_weapon);

	return TRUE;
}
Пример #13
0
void deactivate_weapon_payload_markers (entity *en)
{
	object_3d_instance
		*inst3d;

	ASSERT (en);

	inst3d = get_local_entity_ptr_value (en, PTR_TYPE_INSTANCE_3D_OBJECT);

	ASSERT (inst3d);

	//
	// hardpoint markers
	//

	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_PAYLOAD_MARKER_1_ON, FALSE);
	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_PAYLOAD_MARKER_2_ON, FALSE);
	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_PAYLOAD_MARKER_3_ON, FALSE);
	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_PAYLOAD_MARKER_4_ON, FALSE);

	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_PAYLOAD_MARKER_1_OFF, FALSE);
	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_PAYLOAD_MARKER_2_OFF, FALSE);
	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_PAYLOAD_MARKER_3_OFF, FALSE);
	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_PAYLOAD_MARKER_4_OFF, FALSE);

	//
	// fuel gauge
	//

	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_FUEL_GAUGE_OUTLINE, FALSE);

	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_FUEL_GAUGE_ON, FALSE);

	//
	// damage gauge
	//

	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_DAMAGE_GAUGE_OUTLINE, FALSE);

	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_DAMAGE_GAUGE_ON, FALSE);

	//
	// lights
	//

	set_sub_object_type_visible_status (inst3d, OBJECT_3D_SUB_OBJECT_PAYLOAD_LIGHTS, FALSE);
}
Пример #14
0
int get_local_entity_weapon_count (entity *en, entity_sub_types weapon_sub_type)
{
    int
    weapon_count,
    package;

    weapon_package_status
    *package_status;

    weapon_config_types
    config_type;

    ASSERT (en);

    ASSERT (entity_sub_type_weapon_valid (weapon_sub_type));

    weapon_count = 0;

    if (weapon_sub_type != ENTITY_SUB_TYPE_WEAPON_NO_WEAPON)
    {
        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);

            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].sub_type == weapon_sub_type)
                {
                    if (!package_status[package].damaged)
                    {
                        weapon_count += package_status[package].number;
                    }
                }
            }
        }
    }

    return (weapon_count);
}
Пример #15
0
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));
}
Пример #16
0
float get_local_entity_weapon_load_weight (entity *en)
{
    float
    weapon_load_weight,
    weapon_weight,
    package_weight;

    weapon_package_status
    *package_status;

    weapon_config_types
    config_type;

    int
    package;

    ASSERT (en);

    weapon_load_weight = 0.0;

    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);

        for (package = 0; package < NUM_WEAPON_PACKAGES; package++)
        {
            if (weapon_config_database[config_type][package].sub_type == ENTITY_SUB_TYPE_WEAPON_NO_WEAPON)
            {
                break;
            }

            weapon_weight = weapon_database[weapon_config_database[config_type][package].sub_type].weight;

            package_weight = weapon_weight * package_status[package].number;

            weapon_load_weight += package_weight;
        }
    }

    return (weapon_load_weight);
}
Пример #17
0
void damage_hokum_virtual_cockpit_main_rotors (int seed)
{
	float
		theta;

	object_3d_instance
		*inst3d;

	ASSERT (get_gunship_entity ());

	ASSERT (virtual_cockpit_inst3d_detail_level_high_inst3d);
	ASSERT (virtual_cockpit_inst3d_detail_level_medium_inst3d);
	ASSERT (virtual_cockpit_inst3d_detail_level_low_inst3d);
	ASSERT (virtual_cockpit_inst3d_detail_level_glass_inst3d);

	inst3d = get_local_entity_ptr_value (get_gunship_entity (), PTR_TYPE_INSTANCE_3D_OBJECT);

	ASSERT (inst3d);

	theta = get_rotation_angle_of_helicopter_main_rotors (inst3d);

	set_rotation_angle_of_helicopter_main_rotors (virtual_cockpit_inst3d_detail_level_high_inst3d, theta);
	set_rotation_angle_of_helicopter_main_rotors (virtual_cockpit_inst3d_detail_level_medium_inst3d, theta);
	set_rotation_angle_of_helicopter_main_rotors (virtual_cockpit_inst3d_detail_level_low_inst3d, theta);
	set_rotation_angle_of_helicopter_main_rotors (virtual_cockpit_inst3d_detail_level_glass_inst3d, theta);

	animate_helicopter_virtual_cockpit_main_rotors (get_gunship_entity (), virtual_cockpit_inst3d_detail_level_high_inst3d);
	animate_helicopter_virtual_cockpit_main_rotors (get_gunship_entity (), virtual_cockpit_inst3d_detail_level_medium_inst3d);
	animate_helicopter_virtual_cockpit_main_rotors (get_gunship_entity (), virtual_cockpit_inst3d_detail_level_low_inst3d);
	animate_helicopter_virtual_cockpit_main_rotors (get_gunship_entity (), virtual_cockpit_inst3d_detail_level_glass_inst3d);

	damage_helicopter_main_rotor_inst3d (virtual_cockpit_inst3d_detail_level_high_inst3d, seed);
	damage_helicopter_main_rotor_inst3d (virtual_cockpit_inst3d_detail_level_medium_inst3d, seed);
	damage_helicopter_main_rotor_inst3d (virtual_cockpit_inst3d_detail_level_low_inst3d, seed);
	damage_helicopter_main_rotor_inst3d (virtual_cockpit_inst3d_detail_level_glass_inst3d, seed);
}
Пример #18
0
void damage_blackhawk_virtual_cockpit_main_rotors (int seed)
{
	float
		theta;

	object_3d_instance
		*inst3d;

	ASSERT (get_gunship_entity ());

	ASSERT (virtual_cockpit_main_rotor_inst3d);

	inst3d = (object_3d_instance *) get_local_entity_ptr_value (get_gunship_entity (), PTR_TYPE_INSTANCE_3D_OBJECT);

	ASSERT (inst3d);

	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);

	damage_helicopter_main_rotor_inst3d (virtual_cockpit_main_rotor_inst3d, seed);
}
Пример #19
0
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);
}
Пример #20
0
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++;
    }
}
Пример #21
0
int get_local_entity_weapon_hardpoint_info
(
    entity *en,
    int heading_depth,
    entity_sub_types given_weapon_sub_type,
    entity_sub_types *weapon_sub_type,
    int *number,
    int *damaged
)
{
    int
    package,
    result;

    weapon_package_status
    *package_status;

    weapon_config_types
    config_type;

    ASSERT (en);

    ASSERT (weapon_sub_type);

    ASSERT (number);

    ASSERT (damaged);

    *weapon_sub_type = ENTITY_SUB_TYPE_WEAPON_NO_WEAPON;

    *number = 0;

    *damaged = FALSE;

    result = 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);

        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 (given_weapon_sub_type == ENTITY_SUB_TYPE_WEAPON_NO_WEAPON)
            {
                if (weapon_config_database[config_type][package].heading_depth == heading_depth)
                {
                    *weapon_sub_type = weapon_config_database[config_type][package].sub_type;

                    *number = package_status[package].number;

                    *damaged = package_status[package].damaged;

                    result = TRUE;

                    break;
                }
            }
            else
            {
                if (weapon_config_database[config_type][package].sub_type == given_weapon_sub_type)
                {
                    if (weapon_config_database[config_type][package].heading_depth == heading_depth)
                    {
                        *weapon_sub_type = weapon_config_database[config_type][package].sub_type;

                        *number = package_status[package].number;

                        *damaged = package_status[package].damaged;

                        result = TRUE;

                        break;
                    }
                }
            }
        }
    }

    return (result);
}
Пример #22
0
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;
	}
}
Пример #23
0
void update_vector_altitude_dynamics (void)
{

	static float
		last_ground_height = 0;

	matrix3x3
		attitude;

	float
		heading,
		pitch,
		roll,
		ground_height,
		centre_of_gravity_to_ground_distance;

	vec3d
		position,
		*face_normal;

	centre_of_gravity_to_ground_distance = get_local_entity_float_value (get_gunship_entity (), FLOAT_TYPE_CENTRE_OF_GRAVITY_TO_GROUND_DISTANCE);

	get_local_entity_attitude_matrix (get_gunship_entity (), attitude);

	ground_height = get_local_entity_float_value (get_gunship_entity (), FLOAT_TYPE_TERRAIN_ELEVATION);

	//
	// debug
	//

	if ((ground_height < -1000) || (ground_height > 32000))
	{

		debug_log ("!!!!!!!!!!!!!! GROUND HEIGHT %f", ground_height);

		ground_height = last_ground_height;
	}

	//
	// end
	//

	last_ground_height = ground_height;

	current_flight_dynamics->altitude.value = current_flight_dynamics->position.y;

	current_flight_dynamics->altitude.min = ground_height;

	switch (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_OPERATIONAL_STATE))
	{

		case OPERATIONAL_STATE_LANDED:
		{

			if (current_flight_dynamics->world_velocity_y.value > 0.0)
			{
		
				#if DEBUG_DYNAMICS
		
				debug_log ("VECTOR DYN: takeoff !");
		
				#endif
		
				set_local_entity_int_value (get_gunship_entity (), INT_TYPE_OPERATIONAL_STATE, OPERATIONAL_STATE_NAVIGATING);
		
				delete_local_entity_from_parents_child_list (get_gunship_entity (), LIST_TYPE_CURRENT_WAYPOINT);
		
				transmit_entity_comms_message (ENTITY_COMMS_MOBILE_TAKEOFF, get_gunship_entity ());
			}
			else
			{

				entity
					*wp;

				vec3d
					wp_pos;

				wp = get_local_entity_parent (get_gunship_entity (), LIST_TYPE_CURRENT_WAYPOINT);

				if (wp)
				{

					get_local_waypoint_formation_position (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_FORMATION_POSITION), wp, &wp_pos);

					ground_height = wp_pos.y;
				}
	
				current_flight_dynamics->world_velocity_y.value = max (current_flight_dynamics->world_velocity_y.value, 0.0);

				current_flight_dynamics->velocity_y.value = max (current_flight_dynamics->velocity_y.value, 0.0);
				
				memset (&current_flight_dynamics->world_motion_vector, 0, sizeof (vec3d));
			
				current_flight_dynamics->velocity_x.value = bound (current_flight_dynamics->velocity_x.value, knots_to_metres_per_second (-10), knots_to_metres_per_second (50));
				current_flight_dynamics->velocity_y.value = 0;
				current_flight_dynamics->velocity_z.value = bound (current_flight_dynamics->velocity_z.value, knots_to_metres_per_second (-10), knots_to_metres_per_second (50));
			
				current_flight_dynamics->position.y = ground_height + centre_of_gravity_to_ground_distance;
			
				current_flight_dynamics->altitude.value = ground_height + centre_of_gravity_to_ground_distance;
				
				heading = get_heading_from_attitude_matrix (attitude);
			
				//get_3d_terrain_face_normal (&n, current_flight_dynamics->position.x, current_flight_dynamics->position.z);
				face_normal = get_local_entity_ptr_value (get_gunship_entity (), PTR_TYPE_TERRAIN_FACE_NORMAL);
			
				get_3d_transformation_matrix_from_face_normal_and_heading (attitude, face_normal, heading);
				
				pitch = get_pitch_from_attitude_matrix (attitude);
			
				pitch += rad (aircraft_database [ENTITY_SUB_TYPE_AIRCRAFT_AH64D_APACHE_LONGBOW].fuselage_angle);
			
				roll = get_roll_from_attitude_matrix (attitude);
			
				get_3d_transformation_matrix (attitude, heading, pitch, roll);

				position.x = current_flight_dynamics->position.x;
				position.y = current_flight_dynamics->position.y;
				position.z = current_flight_dynamics->position.z;
			
				set_local_entity_vec3d (get_gunship_entity (), VEC3D_TYPE_POSITION, &position);
			
				set_local_entity_attitude_matrix (get_gunship_entity (), attitude);
			}

			break;
		}

		default:
		{
	
			if (current_flight_dynamics->world_velocity_y.value < 0.0)
			{
	
				if (current_flight_dynamics->altitude.value < current_flight_dynamics->altitude.min + centre_of_gravity_to_ground_distance)
				{
			
					if (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_OPERATIONAL_STATE) != OPERATIONAL_STATE_LANDED)
					{
			
						//
						// need to find what wp the user is trying to land on ....
						//
			
						//entity
							//*wp;
				
						#if DEBUG_DYNAMICS
				
						debug_log ("VECTOR DYN: landed !");
				
						#endif
				
						set_local_entity_int_value (get_gunship_entity (), INT_TYPE_OPERATIONAL_STATE, OPERATIONAL_STATE_LANDED);
			
						//transmit_entity_comms_message (ENTITY_COMMS_MOBILE_LAND, get_gunship_entity (), wp);
					}
				}
			}
		
			break;
		}
	}

	current_flight_dynamics->altitude.value = bound (
														current_flight_dynamics->altitude.value,
														current_flight_dynamics->altitude.min,
														current_flight_dynamics->altitude.max);
}
Пример #24
0
static int get_local_int_value (entity *en, int_types type)
{
	vehicle
		*raw;

	int
		value;

	raw = (vehicle *) get_local_entity_data (en);

	switch (type)
	{
		////////////////////////////////////////
		case INT_TYPE_COLLISION_TEST_MOBILE:
		////////////////////////////////////////
		{
			value = TRUE;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_CPG_IDENTIFIED:
		////////////////////////////////////////
		{
			value = raw->cpg_identified;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_DAMAGE_LEVEL:
		////////////////////////////////////////
		{
			value = raw->damage_level;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_DEFAULT_3D_SHAPE:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].default_3d_shape;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_DEFAULT_WEAPON_CONFIG_TYPE:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].default_weapon_config_type;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_DEFAULT_WEAPON_TYPE:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].default_weapon_type;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_DESTROYED_3D_SHAPE:
		////////////////////////////////////////
		{
			value = get_3d_object_destroyed_object_index (raw->object_3d_shape);

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_ENGAGE_ENEMY:
		////////////////////////////////////////
		{
			entity
				*group;
				
			value = FALSE;

			switch (raw->operational_state)
			{
				case OPERATIONAL_STATE_LANDED:
				{
					if (get_local_entity_parent (en, LIST_TYPE_TAKEOFF_QUEUE))
					{
						//
						// Don't engage if waiting to takeoff...
						//
						
						break;
					}

					// deliberate fall-through...
				}
				case OPERATIONAL_STATE_NAVIGATING:
				case OPERATIONAL_STATE_STOPPED:
				{
					group = get_local_entity_parent (en, LIST_TYPE_MEMBER);

					if (group)
					{
						value = get_local_entity_int_value (group, INT_TYPE_ENGAGE_ENEMY);
					}

					break;
				}
			}

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_EXPLOSIVE_POWER:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].explosive_power;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_EXPLOSIVE_QUALITY:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].explosive_quality;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_FORCE:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].force;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_FORCE_INFO_CATAGORY:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].force_info_catagory;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_FORMATION_POSITION:
		////////////////////////////////////////
		{
			value = raw->formation_position;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_GROUP_LEADER:
		////////////////////////////////////////
		{
			if ((get_local_entity_parent (en, LIST_TYPE_MEMBER)) && (get_local_entity_child_pred (en, LIST_TYPE_MEMBER) == NULL))
			{
				value = TRUE;
			}
			else
			{
				value = FALSE;
			}

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_GROUP_MEMBER_ID:
		////////////////////////////////////////
		{
			value = raw->group_member_number + 1;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_GROUP_MEMBER_NUMBER:
		////////////////////////////////////////
		{
			value = raw->group_member_number;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_GROUP_MEMBER_STATE:
		////////////////////////////////////////
		{
			entity
				*task;

			//
			// Check Task
			//
			
			task = get_local_entity_current_task (en);

			if (task)
			{
				if (get_local_entity_int_value (task, INT_TYPE_ENTITY_SUB_TYPE) == ENTITY_SUB_TYPE_TASK_ENGAGE)
				{
					value = GROUP_MEMBER_STATE_ATTACKING;
				}
				else
				{
					value = GROUP_MEMBER_STATE_NAVIGATING;
				}
			}
			else
			{
				value = GROUP_MEMBER_STATE_IDLE;
			}

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_GUNSHIP_RADAR_LOS_CLEAR:
		////////////////////////////////////////
		{
			value = raw->gunship_radar_los_clear;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_IDENTIFY_VEHICLE:
		////////////////////////////////////////
		{
			value = TRUE;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_ID_NUMBER:
		////////////////////////////////////////
		{
			value = raw->id_number;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_ID_NUMBER_SIGNIFICANT_DIGITS:
		////////////////////////////////////////
		{
			value = raw->id_number_significant_digits;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_INITIAL_DAMAGE_LEVEL:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].initial_damage_level;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_LANDED:
		////////////////////////////////////////
		{

			switch (raw->operational_state)
			{

				case OPERATIONAL_STATE_LANDED:
				//case OPERATIONAL_STATE_REPAIRING:
				//case OPERATIONAL_STATE_REARMING:
				//case OPERATIONAL_STATE_REFUELING:
				{

					value = TRUE;

					break;
				}

				case OPERATIONAL_STATE_STOPPED:
				case OPERATIONAL_STATE_UNKNOWN:
				case OPERATIONAL_STATE_WAITING:
				case OPERATIONAL_STATE_ASLEEP:
				case OPERATIONAL_STATE_DEAD:
				case OPERATIONAL_STATE_DYING:
				case OPERATIONAL_STATE_LANDING:
				case OPERATIONAL_STATE_LANDING_HOLDING:
				case OPERATIONAL_STATE_NAVIGATING:
				case OPERATIONAL_STATE_TAKEOFF:
				case OPERATIONAL_STATE_TAKEOFF_HOLDING:
				case OPERATIONAL_STATE_TAXIING:
				{

					value = FALSE;

					break;
				}

				default:
				{

					debug_fatal ("VH_INT: unknown operational state");
				}
			}

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_LIGHTS_ON:
		////////////////////////////////////////
		{
			value = raw->lights_on;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_LOS_TO_TARGET:
		////////////////////////////////////////
		{
			value = raw->los_to_target;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_MAP_ICON:
		////////////////////////////////////////
		{
			value = vehicle_database [raw->mob.sub_type].map_icon;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_MAX_WEAPON_CONFIG_TYPE:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].max_weapon_config_type;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_MIN_WEAPON_CONFIG_TYPE:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].min_weapon_config_type;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_MOBILE_MOVING:
		////////////////////////////////////////
		{

			switch (raw->operational_state)
			{

				case OPERATIONAL_STATE_ASLEEP:
				case OPERATIONAL_STATE_DEAD:
				case OPERATIONAL_STATE_LANDED:
				case OPERATIONAL_STATE_STOPPED:
				case OPERATIONAL_STATE_UNKNOWN:
				case OPERATIONAL_STATE_WAITING:
				{

					value = FALSE;

					break;
				}

				case OPERATIONAL_STATE_DYING:
				case OPERATIONAL_STATE_LANDING:
				case OPERATIONAL_STATE_LANDING_HOLDING:
				case OPERATIONAL_STATE_NAVIGATING:
				case OPERATIONAL_STATE_TAKEOFF:
				case OPERATIONAL_STATE_TAKEOFF_HOLDING:
				case OPERATIONAL_STATE_TAXIING:
				{

					value = TRUE;

					break;
				}

				default:
				{

					debug_fatal ("VH_INT: unknown operational state");
				}
			}

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_OBJECT_3D_SHAPE:
		////////////////////////////////////////
		{
			value = raw->object_3d_shape;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_OFFENSIVE_CAPABILITY:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].offensive_capability;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_OPERATIONAL_STATE:
		////////////////////////////////////////
		{
			value = raw->operational_state;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_POINTS_VALUE:
		////////////////////////////////////////
		{
			value = vehicle_database [raw->mob.sub_type].points_value;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_RADAR_ON:
		////////////////////////////////////////
		{
			//
			// vehicles must have radar and a target for the radar to be on
			//

			value = FALSE;

			if (vehicle_database[raw->mob.sub_type].threat_type != THREAT_TYPE_INVALID)
			{
				if (raw->mob.target_link.parent != NULL)
				{
					value = TRUE;
				}
			}

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_SELECTED_WEAPON:
		////////////////////////////////////////
		{
			value = raw->selected_weapon;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_SELECTED_WEAPON_SYSTEM_READY:
		////////////////////////////////////////
		{
			value = raw->selected_weapon_system_ready;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_TARGET_PRIORITY_TYPE:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].target_priority_type;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_TARGET_SYMBOL_TYPE:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].target_symbol_type;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_TARGET_TYPE:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].target_type;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_TASK_LEADER:
		////////////////////////////////////////
		{
			entity
				*guide;

			value = FALSE;

			guide = get_local_entity_parent (en, LIST_TYPE_FOLLOWER);

			if (guide)
			{
				if (get_local_entity_ptr_value (guide, PTR_TYPE_TASK_LEADER) == en)
				{
					value = TRUE;
				}
			}

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_TASK_TARGET_TYPE:
		////////////////////////////////////////
		{
			value = (TASK_TARGET_TYPE_ANY | TASK_TARGET_TYPE_MOBILE | TASK_TARGET_TYPE_VEHICLE);

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_THREAT_TYPE:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].threat_type;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_TRACK_ENTITY_ON_MAP:
		////////////////////////////////////////
		{
			value = TRUE;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_VIEW_CATEGORY:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].view_category;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_VIEW_TYPE:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].view_type;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_VIEWABLE:
		////////////////////////////////////////
		{
			value = raw->view_link.parent != NULL;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_WARHEAD_EFFECTIVE_CLASS:
		////////////////////////////////////////
		{
			value = vehicle_database[raw->mob.sub_type].warhead_effective_class;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_WEAPON_AND_TARGET_VECTORS_VALID:
		////////////////////////////////////////
		{
			value = raw->weapon_and_target_vectors_valid;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_WEAPON_CONFIG_TYPE:
		////////////////////////////////////////
		{
			value = raw->weapon_config_type;

			break;
		}
		////////////////////////////////////////
		case INT_TYPE_WEAPON_SYSTEM_READY:
		////////////////////////////////////////
		{
			////////////////////////////////////////
			//
			// WARNING! This only returns a valid value for vehicles that have weapon
			//          systems to be made ready in the current weapons configuration.
			//
			////////////////////////////////////////

			if (get_local_entity_float_value (en, FLOAT_TYPE_WEAPON_SYSTEM_READY_STATE) == VEHICLE_WEAPON_SYSTEM_READY_OPEN_FLOAT_VALUE)
			{
				value = TRUE;
			}
			else
			{
				value = FALSE;
			}

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal_invalid_int_type (en, type);

			break;
		}
	}

	return (value);
}
Пример #25
0
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);
}
Пример #26
0
void reset_cinematic_camera (camera *raw)
{
	entity
		*en;

	object_3d_instance
		*inst3d;

	int
		num_moving_cameras,
		num_static_cameras,
		attempts;

	//
	// pre-amble
	//

	ASSERT (raw);

	ASSERT (raw->external_view_entity);

	en = raw->external_view_entity;

	inst3d = get_local_entity_ptr_value (en, PTR_TYPE_INSTANCE_3D_OBJECT);

	//
	// select 3D camera
	//

	raw->cinematic_camera_index = OBJECT_3D_INVALID_CAMERA_INDEX;

	if (inst3d)
	{
		num_moving_cameras = get_number_of_3d_object_cameras (inst3d, OBJECT_3D_CAMERA_SCENIC_MOVING);

		num_static_cameras = get_number_of_3d_object_cameras (inst3d, OBJECT_3D_CAMERA_SCENIC_STATIC);

		if ((num_moving_cameras > 0) && (num_static_cameras > 0))
		{
			if (frand1 () < 0.333)
			{
				raw->cinematic_camera_index = OBJECT_3D_CAMERA_SCENIC_MOVING;
			}
			else
			{
				raw->cinematic_camera_index = OBJECT_3D_CAMERA_SCENIC_STATIC;
			}
		}
		else if (num_moving_cameras > 0)
		{
			raw->cinematic_camera_index = OBJECT_3D_CAMERA_SCENIC_MOVING;
		}
		else if (num_static_cameras > 0)
		{
			raw->cinematic_camera_index = OBJECT_3D_CAMERA_SCENIC_STATIC;
		}
	}

	switch (raw->cinematic_camera_index)
	{
		////////////////////////////////////////
		case OBJECT_3D_INVALID_CAMERA_INDEX:
		////////////////////////////////////////
		{
			raw->cinematic_camera_depth = 0;

			raw->cinematic_camera_lifetime = (frand1 () * 2.0) + 2.0;

			raw->cinematic_camera_heading = rad (45.0) * ((float) (rand16 () % 8));

			raw->cinematic_camera_pitch = rad (-45.0) * ((float) (rand16 () % 2));

			#if DEBUG_MODULE

			debug_log
			(
				"CINEMATIC CAMERA is INVALID (object = %s, moving cameras = %d, static cameras = %d, depth = %d, lifetime = %.2f, heading = %.2f, pitch = %.2f)",
				get_local_entity_string (en, STRING_TYPE_FULL_NAME),
				num_moving_cameras,
				num_static_cameras,
		  		raw->cinematic_camera_depth,
				raw->cinematic_camera_lifetime,
				deg (raw->cinematic_camera_heading),
				deg (raw->cinematic_camera_pitch)
			);

			#endif

			break;
		}
		////////////////////////////////////////
		case OBJECT_3D_CAMERA_SCENIC_MOVING:
		////////////////////////////////////////
		{
			//
			// try and prevent using the same moving camera twice in succession
			//

			if (num_moving_cameras > 1)
			{
				attempts = 10;

				while (attempts--)
				{
					raw->cinematic_camera_depth = rand16 () % num_moving_cameras;

					if (raw->cinematic_camera_depth != raw->cinematic_camera_previous_moving_depth)
					{
						break;
					}
				}
			}
			else
			{
				raw->cinematic_camera_depth = 0;
			}

			raw->cinematic_camera_previous_moving_depth = raw->cinematic_camera_depth;

			raw->cinematic_camera_lifetime = get_object_3d_camera_lifetime (inst3d, raw->cinematic_camera_index, raw->cinematic_camera_depth);

			#if DEBUG_MODULE

			debug_log
			(
				"CINEMATIC CAMERA is MOVING (object = %s, moving cameras = %d, static cameras = %d, depth = %d, lifetime = %.2f)",
				get_local_entity_string (en, STRING_TYPE_FULL_NAME),
				num_moving_cameras,
				num_static_cameras,
		  		raw->cinematic_camera_depth,
				raw->cinematic_camera_lifetime
			);

			#endif

			ASSERT (raw->cinematic_camera_lifetime > 0.0);

			break;
		}
		////////////////////////////////////////
		case OBJECT_3D_CAMERA_SCENIC_STATIC:
		////////////////////////////////////////
		{
			//
			// try and prevent using the same static camera twice in succession
			//

			if (num_static_cameras > 1)
			{
				attempts = 10;

				while (attempts--)
				{
					raw->cinematic_camera_depth = rand16 () % num_static_cameras;

					if (raw->cinematic_camera_depth != raw->cinematic_camera_previous_static_depth)
					{
						break;
					}
				}
			}
			else
			{
				raw->cinematic_camera_depth = 0;
			}

			raw->cinematic_camera_previous_static_depth = raw->cinematic_camera_depth;

			raw->cinematic_camera_lifetime = (frand1 () * 2.0) + 2.0;

			#if DEBUG_MODULE

			debug_log
			(
				"CINEMATIC CAMERA is STATIC (object = %s, moving cameras = %d, static cameras = %d, depth = %d, lifetime = %.2f)",
				get_local_entity_string (en, STRING_TYPE_FULL_NAME),
				num_moving_cameras,
				num_static_cameras,
		  		raw->cinematic_camera_depth,
				raw->cinematic_camera_lifetime
			);

			#endif
		}
	}

	raw->cinematic_camera_timer = 0.0;

	//
	// motion vector
	//

	get_local_entity_vec3d (en, VEC3D_TYPE_MOTION_VECTOR, &raw->motion_vector);
}
Пример #27
0
void update_cinematic_camera_continued (camera *raw)
{
	entity
		*en;

	object_3d_instance
		*inst3d;

	viewpoint
		vp;

	float
		normalised_timer;

	//
	// pre-amble
	//

	ASSERT (raw);

	ASSERT (raw->external_view_entity);

	en = raw->external_view_entity;

	//
	// get camera position and attitude
	//

	switch (raw->cinematic_camera_index)
	{
		////////////////////////////////////////
		case OBJECT_3D_INVALID_CAMERA_INDEX:
		////////////////////////////////////////
		{
			float
				combined_heading,
				z_min,
				z_max;

			vec3d
				rel_camera_position;

			combined_heading = get_local_entity_float_value (en, FLOAT_TYPE_HEADING);

			combined_heading += raw->cinematic_camera_heading;

			get_3d_transformation_matrix (raw->attitude, combined_heading, raw->cinematic_camera_pitch, 0.0);

			z_min = get_local_entity_float_value (en, FLOAT_TYPE_CHASE_VIEW_MIN_DISTANCE);
			z_max = get_local_entity_float_value (en, FLOAT_TYPE_CHASE_VIEW_MAX_DISTANCE);

			ASSERT (z_min < z_max);

			rel_camera_position.x = 0.0;
			rel_camera_position.y = 0.0;
			rel_camera_position.z = -(((z_max - z_min) * 0.1) + z_min);

			multiply_matrix3x3_vec3d (&rel_camera_position, raw->attitude, &rel_camera_position);

			get_local_entity_target_point (en, &raw->position);

			raw->position.x += rel_camera_position.x;
			raw->position.y += rel_camera_position.y;
			raw->position.z += rel_camera_position.z;

			break;
		}
		////////////////////////////////////////
		case OBJECT_3D_CAMERA_SCENIC_MOVING:
		////////////////////////////////////////
		{
			normalised_timer = raw->cinematic_camera_timer / raw->cinematic_camera_lifetime;

			inst3d = get_local_entity_ptr_value (en, PTR_TYPE_INSTANCE_3D_OBJECT);

			get_local_entity_vec3d (en, VEC3D_TYPE_POSITION, &inst3d->vp.position);

			get_local_entity_attitude_matrix (en, inst3d->vp.attitude);

			get_object_3d_camera_position (inst3d, raw->cinematic_camera_index, raw->cinematic_camera_depth, normalised_timer, &vp);

			raw->position = vp.position;

			memcpy (raw->attitude, vp.attitude, sizeof (matrix3x3));

			break;
		}
		////////////////////////////////////////
		case OBJECT_3D_CAMERA_SCENIC_STATIC:
		////////////////////////////////////////
		{
			normalised_timer = 0.0;

			inst3d = get_local_entity_ptr_value (en, PTR_TYPE_INSTANCE_3D_OBJECT);

			get_local_entity_vec3d (en, VEC3D_TYPE_POSITION, &inst3d->vp.position);

			get_local_entity_attitude_matrix (en, inst3d->vp.attitude);

			get_object_3d_camera_position (inst3d, raw->cinematic_camera_index, raw->cinematic_camera_depth, normalised_timer, &vp);

			raw->position = vp.position;

			memcpy (raw->attitude, vp.attitude, sizeof (matrix3x3));

			break;
		}
	}

	//
	// keep point above ground (unless point off map)
	//

	if (point_inside_map_area (&raw->position))
	{
		raw->position.y = max (raw->position.y, get_3d_terrain_point_data (raw->position.x, raw->position.z, &raw->terrain_info) + 0.5);
	}

	//
	// motion vector
	//

	get_local_entity_vec3d (en, VEC3D_TYPE_MOTION_VECTOR, &raw->motion_vector);
}
Пример #28
0
void update_cinematic_camera (camera *raw)
{
	//
	// pre-amble
	//

	ASSERT (raw);

	ASSERT (raw->external_view_entity);

	////////////////////////////////////////
	//
	// This code has been added to protect against cases where an object
	// and its destroyed version have a different number of cameras.
	//

	switch (raw->cinematic_camera_index)
	{
		case OBJECT_3D_CAMERA_SCENIC_MOVING:
		case OBJECT_3D_CAMERA_SCENIC_STATIC:
		{
			object_3d_instance
				*inst3d;

			inst3d = get_local_entity_ptr_value (raw->external_view_entity, PTR_TYPE_INSTANCE_3D_OBJECT);

			if (raw->cinematic_camera_depth >= get_number_of_3d_object_cameras (inst3d, raw->cinematic_camera_index))
			{
				#if DEBUG_MODULE

				debug_colour_log (DEBUG_COLOUR_RED, "CINEMATIC CAMERA ERROR - forced reset!!!");

				#endif

				reset_cinematic_camera (raw);
			}

			break;
		}
	}

	//
	////////////////////////////////////////

	//
	// update timer
	//

	raw->cinematic_camera_timer += get_delta_time ();

	if (raw->cinematic_camera_timer > raw->cinematic_camera_lifetime)
	{
		if (raw->auto_edit)
		{
			switch_auto_edit_entity (raw);

			if (switch_auto_edit_camera_mode (raw))
			{
				//
				// switched to a different camera
				//

				return;
			}
		}

		reset_cinematic_camera (raw);
	}

	//
	// continue update
	//

	update_cinematic_camera_continued (raw);
}
Пример #29
0
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);
}
Пример #30
0
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);
}