[vtkusers] World orientation

Sergey Programmer croooter at gmail.com
Thu Jun 10 06:29:42 EDT 2010


Thank you, Rodrigo, you helped me a lot! It works just fine!

For others reference, here is the C version (I added only
ren->GetRenderWindow()->Render() for immediate update):

    double *fp;
    double *p;
    double  dist;
    double  unit[3] = { 0, 0, 1.0 };
    double  up[3] = { 0, 1.0, 0.0 };
    ren->ResetCamera();
    fp = ren->GetActiveCamera()->GetFocalPoint();
    p = ren->GetActiveCamera()->GetPosition();
    dist = sqrt( pow((p[0]-fp[0]),2) + pow((p[1]-fp[1]),2) +
pow((p[2]-fp[2]),2) );
    ren->GetActiveCamera()->SetPosition(fp[0]+dist*unit[0],
fp[1]+dist*unit[1], fp[2]+dist*unit[2]);
    ren->GetActiveCamera()->SetViewUp( up );
    ren->GetRenderWindow()->Render();

Regards,
Croot

On Thu, Jun 10, 2010 at 12:12 PM, Rodrigo Valiña Gutiérrez <
rodrigo.valina at usc.es> wrote:

> Hi, this Python code may help you:
>
> -first center the object and position camera and then rotate the
> position to the desired angle:
>
>    def orient_inter(self, pos):
>        if pos == 0: # XY
>            self.orient_handler((0.0,0.0,1.0))
>        elif pos == 1: #XZ
>            self.orient_handler((0.0,1.0,0.0),(0,0,1))
>        elif pos == 2: #YZ
>            self.orient_handler((1.0,0.0,0.0))
>        elif pos == 3: #iso
>            v = math.sqrt(1.0/3.0)
>            self.orient_handler((v,v,v))
>
>    def orient_handler(self, unit, up=(0.0,1.0,0.0)):
>        for ren in self.rens:
>            ren.ResetCamera() # posicion, tamanho
>            fp = ren.GetActiveCamera().GetFocalPoint()
>            p = ren.GetActiveCamera().GetPosition()
>            dist = math.sqrt( (p[0]-fp[0])**2 + (p[1]-fp[1])**2 +
> (p[2]-fp[2])**2 )
>            ren.GetActiveCamera().SetPosition(fp[0]+dist*unit[0],
> fp[1]+dist*unit[1], fp[2]+dist*unit[2])
>            ren.GetActiveCamera().SetViewUp(up)
>
> where unit is a unit vector with the desired direction. initially
> would be: (0,0,1).
>
> --
> Rodrigo
>
> On Thu, Jun 10, 2010 at 9:20 AM, Sergey Programmer <croooter at gmail.com>
> wrote:
> > Hello colleagues,
> >
> > is there a way to reset to defaults world orientation? Sometimes after
> > rotating operations one may want to center it by one button press.. I
> found
> > camera reset function and hotkey (r), but it doesn't reset orientation -
> > only zooming.
> >
> > Regards,
> > Croot
> >
> > _______________________________________________
> > 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
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100610/1a4f275b/attachment.htm>


More information about the vtkusers mailing list