Beispiel #1
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);
}
Beispiel #2
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);
}