Exemplo n.º 1
0
void object_render_shadow(object *obj) {
    if(obj->cur_sprite == NULL || !obj->cast_shadow) {
        return;
    }

    // Scale of the sprite on Y axis should be less than the
    // height of the sprite because of light position
    float scale_y = 0.25f;

    // Determine X
    int flipmode = obj->sprite_state.flipmode;
    int x = obj->pos.x + obj->cur_sprite->pos.x + obj->sprite_state.o_correction.x;
    if(object_get_direction(obj) == OBJECT_FACE_LEFT) {
        x = (obj->pos.x + obj->sprite_state.o_correction.x) - obj->cur_sprite->pos.x - object_get_size(obj).x;
        flipmode ^= FLIP_HORIZONTAL;
    }

    // Determine Y
    float temp = object_h(obj) * scale_y;
    int y = 190 - temp - (object_h(obj) - temp) / 2;

    // Render shadow object twice with different offsets, so that
    // the shadows seem a bit blobbier and shadow-y
    for(int i = 0; i < 2; i++) {
        video_render_sprite_flip_scale_opacity_tint(
            obj->cur_sprite->data,
            x+i, y+i,
            BLEND_ALPHA,
            obj->pal_offset,
            flipmode,
            scale_y,
            50,
            color_create(0,0,0,255));
    }
}
Exemplo n.º 2
0
void camera::set_object_host(object *objp, int n_object_host_submodel)
{
	if(objp == NULL)
		object_host = object_h();

	object_host = object_h(objp);
	object_host_submodel = n_object_host_submodel;
	set_custom_position_function(NULL);
	set_custom_orientation_function(NULL);
	if(n_object_host_submodel > 0)
	{
		if(objp->type == OBJ_SHIP)
		{
			ship_subsys* ssp = GET_FIRST(&Ships[objp->instance].subsys_list);
			while ( ssp != END_OF_LIST( &Ships[objp->instance].subsys_list ) )
			{
				if(ssp->system_info->subobj_num == n_object_host_submodel)
				{
					if(ssp->system_info->type == SUBSYSTEM_TURRET)
					{
						set_custom_position_function(get_turret_cam_pos);
						set_custom_orientation_function(get_turret_cam_orient);
					}
				}
				ssp = GET_NEXT( ssp );
			}
		}
	}
}
Exemplo n.º 3
0
void camera::set_object_target(object *objp, int n_object_target_submodel)
{
	if(objp == NULL)
		object_target = object_h();

	object_target = object_h(objp);
	object_target_submodel = n_object_target_submodel;
}
Exemplo n.º 4
0
void camera::reset()
{
	flags = CAM_DEFAULT_FLAGS;

	object_host = object_target = object_h();
	object_host_submodel = object_target_submodel = -1;

	c_fov = VIEWER_ZOOM_DEFAULT;
	c_pos = vmd_zero_vector;
	c_ori = vmd_identity_matrix;

	func_custom_position = NULL;
	func_custom_orientation = NULL;

	fov.clear();
	fov.set(VIEWER_ZOOM_DEFAULT);

	pos_x.clear();
	pos_y.clear();
	pos_z.clear();

	for(int i = 0; i < 9; i++)
	{
		ori[i].clear();
		ori[i].set(vmd_identity_matrix.a1d[i]);
	}
}