camera tuning

Brian Alexander Todd bat5 at po.cwru.edu
Wed Apr 12 11:49:21 EDT 2000


At 03:40 PM 4/10/00 +0200, Robert Riviere wrote:
>Hello,
>
>	I'm using the Renderer to display a flat 2D object.
>I'd like to tune the camera to make the object fill as much as 
>possible the rendering window.
>

Robert,

This is what I use to trick the camera to giving me a tight 
view around the vtkActor "viewplane".

void wxVTKView2D::FocusCameraToPlane()
{
	float center[3], bounds[6], diff,
factor=0.625;

	viewplane->GetBounds( bounds );

	center[0] = (bounds[0] +
bounds[1])/2.0;
	center[1] = (bounds[2] + bounds[3])/2.0;
	center[2] =
(bounds[4] + bounds[5])/2.0;

	diff = bounds[1] - bounds[0];
	bounds[0] =
center[0] - factor*diff/2.0;
	bounds[1] = center[0] + factor*diff/2.0;

diff = bounds[3] - bounds[2];
	bounds[2] = center[1] - factor*diff/2.0;

bounds[3] = center[1] + factor*diff/2.0;
	bounds[4] = bounds[5] = 0;


this->ren->SetActiveCamera( camera );
	this->ren->ResetCamera( bounds );
}

Hope this helps.

Brian Todd


Brian Todd				"Evidently the operation of
email:      bat5 at po.cwru.edu		differentiation is rather 
home:       (216) 321-8882		unpleasent.  It can transform 
office:     (216) 368-4209		a nice function into one much
fax:        (216) 368-4969		less behaved" 	-GM Wing

--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------



More information about the vtkusers mailing list