示例#1
0
Imath::M33f Transform2DPlug::matrix( const Imath::Box2i &displayWindow, double pixelAspect ) const
{
	// We need to transform from image space (with 0x0 being the bottom left)
	// to Gadget space (where 0x0 is the top left). To do this, we need to know the
	// size of the Format.
	
	///\todo: We don't handle the pixel aspect of the format here but we should!
	float formatHeight = displayWindow.size().y + 1;
	
	M33f p;
	V2f pivotVec = pivotPlug()->getValue();
	pivotVec.y = formatHeight - pivotVec.y;
	p.translate( pivotVec );
	
	M33f t;
	V2f translateVec = translatePlug()->getValue();
	translateVec.y *= -1.;
	t.translate( translateVec );
	
	M33f r;
	r.rotate( IECore::degreesToRadians( rotatePlug()->getValue() ) );
	M33f s;
	s.scale( scalePlug()->getValue() );
	
	M33f pi;
	pi.translate( pivotVec*Imath::V2f(-1.f) );
	M33f result = pi * s * r * t * p;

	return result;
}
M33f ImagePrimitive::uvToPixelMatrix() const
{
	M33f result;
	const Box2i &displayWindow = getDisplayWindow();
	V2i size = displayWindow.size() + V2i( 1 );
	result.translate( V2f( displayWindow.min.x, displayWindow.min.y ) - V2f( 0.5f ) );
	result.scale( V2f( size.x, size.y ) );
	return result;
}
M33f ImagePrimitive::pixelToObjectMatrix() const
{
	M33f result;
	const Box2i &displayWindow = getDisplayWindow();
	V2i size = displayWindow.size();
	result.scale( V2f( 1.0f, -1.0f ) );
	result.translate( -V2f( displayWindow.min.x, displayWindow.min.y ) - V2f( size.x, size.y ) / 2.0f );
	return result;
}
M33f ImagePrimitive::uvToObjectMatrix() const
{
	M33f result;
	const Box2i &displayWindow = getDisplayWindow();
	V2i size = displayWindow.size() + V2i( 1 );
	result.scale( V2f( size.x, -size.y ) );
	result.translate( V2f( -0.5f ) );
	return result;
}
示例#5
0
Imath::M33f Transform2DPlug::matrix() const
{
	M33f p;
	V2f pivotVec = pivotPlug()->getValue();
	p.translate( pivotVec );

	M33f t;
	V2f translateVec = translatePlug()->getValue();
	t.translate( translateVec );

	M33f r;
	r.rotate( IECore::degreesToRadians( rotatePlug()->getValue() ) );
	M33f s;
	s.scale( scalePlug()->getValue() );

	M33f pi;
	pi.translate( pivotVec*Imath::V2f(-1.f) );
	M33f result = pi * s * r * t * p;

	return result;
}