[vtkusers] NormalizedViewport to World using vtkCoordinate

Louis Desjardins lost_bits1110 at hotmail.com
Thu Dec 9 21:26:05 EST 2004

Hello experts

Say I have a Viewport that is defined as:
Ren->SetViewport( 0.5, 0.5, 1, 1)    // (x_min,y_min, x_max,y_max)

so basically it takes some fraction of the screen (half in this case)

I've rendered an UnstructuredGrid in this viewport, and thus I have an idea 
of what my world coordinates are

I would like to know the points defined above for my 'Ren' viewport in these 
defined world coordinates

so I would like to convert (0.5,0.5) to world coords
and (1,1) to world coords

this my code:

        double *worldValue1 = new double[2];
	double *worldValue2 = new double[2];

	ViewPortToWorld->SetCoordinateSystemToNormalizedViewport( );
	ViewPortToWorld->SetViewport( Ren );
	ViewPortToWorld->SetValue(0.5, 0.5);

	worldValue1 = ViewPortToWorld->GetComputedWorldValue( Ren );
	cout<<worldValue1[0]<<" "<<worldValue1[1]<<endl;

	ViewPortToWorld->SetValue(1, 1);
	worldValue2 = ViewPortToWorld->GetComputedWorldValue( ColorDoppler.Ren1 );
	cout<<worldValue2[0]<<" "<<worldValue2[1]<<endl;

Like I said, I have an idea of what the values should be, but I dont get the 
right ones
also, worldValue1 and worldValue2 give the exact same values!??

Any help at all would be greatly appreciated =S
Thank you!


More information about the vtkusers mailing list