[vtkusers] Problems with vtkCamera::SetUserTransform()...

Jannis Linxweiler j.linxweiler at tu-bs.de
Wed Apr 20 12:23:58 EDT 2005


Dear All,

I'm trying to change the perspective of a vtkCamera object using the
SetUserTransform method. I used the code from vtkCamera::Yaw() as an
example. 


CODE:
void MyYaw(double angle)
{
	//modify camera position
	vtkCamera *cam = this->ren1->GetActiveCamera();
	vtkTransform* transform = vtkTransform::New();
	vtkPerspectiveTransform* pTransform =
vtkPerspectiveTransform::New();
	double pos[3]; cam->GetPosition(pos);
	double newFocalPoint[3];
	double viewup[3]; cam->GetViewUp(viewup);

	//transform->Identity();
	// translate the camera to the origin,
	// rotate about axis,
	// translate back again
	transform->Translate(+pos[0],+pos[1],+pos[2]);   
	transform->RotateWXYZ(angle,viewup);
	transform->Translate(-pos[0],-pos[1],-pos[2]);
	
	cam->SetUserTransform(transform);
	transform->TransformPoint(cam->GetFocalPoint,newFocalPoint);
	cam->SetFocalPoint(newFocalPoint);
}

Unfortunately I'm not getting the same results as using the Yaw(angle)
method. Can anyone tell me what I'm doing wrong in this place?

If I change the code and use the line...

vtkTransform* transform = = cam->GetViewTransformObject();

instead of..

vtkTransform* transform = vtkTransform::New(); and
cam->SetUserTransform(transform);

...than everything works as expected.

Nevertheless this is not an solution for my Problem as it woks the same way
as Yaw() does. 

Thanks, Jannis




More information about the vtkusers mailing list