<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
"K.R.Subramanian" wrote:
<blockquote TYPE=CITE>Is there a convenient way to save a particular view
(camera, perspective, etc.) so that
<br>the application can be brought back at a later time to the same view?
[...]</blockquote>
I'm using the following tcl functions to save and restore the camera position:
<br>If you want to use this script with the latest nightly vtk you'll probably
have to change it according to the mail from David Gobbi [New vtkCamera
class] on Mon, 1 May 2000 15:35:38 -0400 (EDT).
<br>
<pre>proc saveCamera { fileName } {
set filePtr [open $fileName w]
set camera "\[ren1 GetActiveCamera\]"
set activeCamera [ren1 GetActiveCamera]
puts $filePtr "$camera SetPosition [$activeCamera GetPosition]"
puts $filePtr "$camera SetFocalPoint [$activeCamera GetFocalPoint]"
puts $filePtr "$camera SetViewAngle [$activeCamera GetViewAngle]"
puts $filePtr "$camera SetViewUp [$activeCamera GetViewUp]"
puts $filePtr "$camera SetViewPlaneNormal [$activeCamera GetViewPlaneNormal]"
close $filePtr
}
#-----------------------------------------------------------------------------
# load a saved camera position
proc loadCamera { fileName } {
global renWin
#load the camera position
source $fileName
puts "file read"
reset_light
$renWin Render
}
#------------------------------------------------------------------------------# set the position of the light to the position of the active camera
proc reset_light {} {
set lights [ren1 GetLights]
puts "got lights $lights"
set num_lights [$lights GetNumberOfItems]
if { $num_lights == 1 } {
puts "has $num_lights lights"
$lights InitTraversal
set light [$lights GetNextItem]
puts "got light $light"
set activeCamera [ren1 GetActiveCamera]
set position [$activeCamera GetPosition]
set pos0 [lindex $position 0]
set pos1 [lindex $position 1]
set pos2 [lindex $position 2]
puts "position=($pos0,$pos1,$pos2)"
$light SetPosition $pos0 $pos1 $pos2
}
}</pre>
<pre>--
Rainer Sabelka | Institute for Microelectronics
phone: +43 1 58801-36029 | Technical University Vienna
fax: +43 1 58801-36099 | Gusshausstrasse 27-29/E360
e-mail: sabelka@iue.tuwien.ac.at | A-1040 Vienna, Austria/Europe</pre>
</html>