Exemple #1
0
corner_pin_node_t::matrix3_type corner_pin_node_t::do_calc_transform_matrix_at_frame( float frame, int subsample) const
{
    Imath::Box2i src_area( input_as<image_node_t>()->format());
	src_area.max.x++;
	src_area.max.y++;

    boost::array<Imath::V2d, 4> src_pts;
    src_pts[0].x = src_area.min.x;
    src_pts[0].y = src_area.min.y;
    src_pts[1].x = src_area.max.x;
    src_pts[1].y = src_area.min.y;
    src_pts[2].x = src_area.max.x;
    src_pts[2].y = src_area.max.y;
    src_pts[3].x = src_area.min.x;
    src_pts[3].y = src_area.max.y;

    boost::array<Imath::V2d, 4> dst_pts;
    get_corners_at_frame( dst_pts, frame, 1.0f / subsample);

    if( quad_is_convex( dst_pts))
	{
		boost::optional<matrix3_type> m( quadToQuadMatrix( src_pts, dst_pts));

		if( m)
		    return m.get();
	}
	
	return matrix3_type( 0, 0, 0,
						0, 0, 0,
						0, 0, 0);
}
Exemple #2
0
boost::optional<Imath::M33d> corner_pin_node_t::do_calc_transform_matrix_at_time( float time, int subsample) const
{
    Imath::Box2i src_area( input()->domain());

    boost::array<Imath::V2d, 4> src_pts;
    src_pts[0].x = src_area.min.x;
    src_pts[0].y = src_area.min.y;
    src_pts[1].x = src_area.max.x;
    src_pts[1].y = src_area.min.y;
    src_pts[2].x = src_area.max.x;
    src_pts[2].y = src_area.max.y;
    src_pts[3].x = src_area.min.x;
    src_pts[3].y = src_area.max.y;

    boost::array<Imath::V2d, 4> dst_pts;
    get_corners_at_time( dst_pts, time);

    boost::optional<Imath::M33d> m;

    if( quad_is_convex( dst_pts))
        m = quadToQuadMatrix( src_pts, dst_pts);

    return m;
}