Thank you, Rodrigo, you helped me a lot! It works just fine!<br><br>For others reference, here is the C version (I added only ren->GetRenderWindow()->Render() for immediate update):<br><br> double *fp;<br> double *p;<br>
double dist;<br> double unit[3] = { 0, 0, 1.0 };<br> double up[3] = { 0, 1.0, 0.0 };<br> ren->ResetCamera();<br> fp = ren->GetActiveCamera()->GetFocalPoint();<br> p = ren->GetActiveCamera()->GetPosition();<br>
dist = sqrt( pow((p[0]-fp[0]),2) + pow((p[1]-fp[1]),2) + pow((p[2]-fp[2]),2) );<br> ren->GetActiveCamera()->SetPosition(fp[0]+dist*unit[0], fp[1]+dist*unit[1], fp[2]+dist*unit[2]);<br> ren->GetActiveCamera()->SetViewUp( up );<br>
ren->GetRenderWindow()->Render();<br><br>Regards,<br>Croot<br><br><div class="gmail_quote">On Thu, Jun 10, 2010 at 12:12 PM, Rodrigo Valiña Gutiérrez <span dir="ltr"><<a href="mailto:rodrigo.valina@usc.es">rodrigo.valina@usc.es</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi, this Python code may help you:<br>
<br>
-first center the object and position camera and then rotate the<br>
position to the desired angle:<br>
<br>
def orient_inter(self, pos):<br>
if pos == 0: # XY<br>
self.orient_handler((0.0,0.0,1.0))<br>
elif pos == 1: #XZ<br>
self.orient_handler((0.0,1.0,0.0),(0,0,1))<br>
elif pos == 2: #YZ<br>
self.orient_handler((1.0,0.0,0.0))<br>
elif pos == 3: #iso<br>
v = math.sqrt(1.0/3.0)<br>
self.orient_handler((v,v,v))<br>
<br>
def orient_handler(self, unit, up=(0.0,1.0,0.0)):<br>
for ren in self.rens:<br>
ren.ResetCamera() # posicion, tamanho<br>
fp = ren.GetActiveCamera().GetFocalPoint()<br>
p = ren.GetActiveCamera().GetPosition()<br>
dist = math.sqrt( (p[0]-fp[0])**2 + (p[1]-fp[1])**2 +<br>
(p[2]-fp[2])**2 )<br>
ren.GetActiveCamera().SetPosition(fp[0]+dist*unit[0],<br>
fp[1]+dist*unit[1], fp[2]+dist*unit[2])<br>
ren.GetActiveCamera().SetViewUp(up)<br>
<br>
where unit is a unit vector with the desired direction. initially<br>
would be: (0,0,1).<br>
<br>
--<br>
Rodrigo<br>
<div><div></div><div class="h5"><br>
On Thu, Jun 10, 2010 at 9:20 AM, Sergey Programmer <<a href="mailto:croooter@gmail.com">croooter@gmail.com</a>> wrote:<br>
> Hello colleagues,<br>
><br>
> is there a way to reset to defaults world orientation? Sometimes after<br>
> rotating operations one may want to center it by one button press.. I found<br>
> camera reset function and hotkey (r), but it doesn't reset orientation -<br>
> only zooming.<br>
><br>
> Regards,<br>
> Croot<br>
><br>
</div></div>> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><br>
><br>
</blockquote></div><br>