[vtkusers] World orientation
Rodrigo Valiña Gutiérrez
rodrigo.valina at usc.es
Thu Jun 10 04:12:46 EDT 2010
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
>
>
More information about the vtkusers
mailing list