[vtkusers] reset camera

André Prins a.h.prins at gmail.com
Fri May 7 07:43:18 EDT 2010


Hi Rodrigo,

As far as I know, the interactorstyle should not matter at all for
resetting the camera.

You are right that the ResetCamera sets the focalpoint and changes the
position, but it calculates 'suitable' defaults for them, based on the
current viewdirection. It simply tries to fit all the objects in your
scene in the view by moving the camera along the viewdirection
(without changing this viewdirection). If your viewdireection is
wrong, it will stay wrong.

If you want to reset your camera to a specific position and
viewdirection, then it is maybe better to do this yourself. Keep track
of you 'initial' camera position and orientation and use those to
'reset' the camera. E.g. in my own code I have a method which resets a
camera to a specified 'camera-position', looking to the origin of my
world:

void MyClass:resetcamera( double c[3] )
{
	this->getRenderer( )->GetActiveCamera( )->SetViewUp( 0, 1, 0 );
	this->getRenderer( )->GetActiveCamera( )->SetFocalPoint( 0.0, 0.0, 0.0 );
	this->getRenderer( )->GetActiveCamera( )->SetPosition( c[0], c[1], c[2] );
}

I hope this helps.

Regards,
André


On Fri, May 7, 2010 at 1:04 PM, Rodrigo Valiña Gutiérrez
<rodrigo.valina at usc.es> wrote:
> Hi André.
>
> I tryed before and after reseting the camera, and it does not work, it
> only moves the object a bit.
>
> This way:
>
> renderer.GetActiveCamera().SetViewUp(0.0, 1.0, 0.0)
> renderer.ResetCamera()
> #renderer.GetActiveCamera().SetViewUp(0.0, 1.0, 0.0)
>
> It seems that ResetCameta() only resets FocalPoint, and changes the
> position but not reset it.
>
> I do the following. It matters?
>
> self.widget.GetInteractorStyle().SetCurrentStyleToTrackballCamera()
>
> Any idea?
>
> Rodrigo
>
> On Fri, May 7, 2010 at 12:17 PM, André Prins <a.h.prins at gmail.com> wrote:
>> Hi Rodrigo,
>>
>> Unfortunately the ResetCamera() resets the viewdirection (using
>> SetPosition() and SetFocalPoint()) but not the viewup vector.
>> To reset the orientation as well, reset it before reseting the camera: E.g.
>>
>>    renderer->SetViewUp( 0, 1, 0 ); // assuming this is your initial
>> viewup-vector
>>    renderer->ResetCamer( );
>>
>> Regards,
>> André
>>
>> On Fri, May 7, 2010 at 10:20 AM, Rodrigo Valiña Gutiérrez
>> <rodrigo.valina at usc.es> wrote:
>>> Hi,
>>>
>>> I want to reset the camera, and I am using:
>>>
>>> renderer.ResetCamera().
>>>
>>> That resets the position and size, but not the rotation of the object.
>>> I wanted to place it in the default orientation (like initial
>>> orientation), but I don't find any method that works.
>>>
>>> I can not use the saved position of the camera because in my scene,
>>> the number of objects may have changed, and thus the center and size.
>>>
>>> Is there any form of reseting the camera rotation which works for any
>>> scene configuration ?
>>>
>>> --
>>> Rodrigo
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list