source: development/steve/visualisation/Tutorial/Step4/Cone4.tcl @ 2229

Last change on this file since 2229 was 2229, checked in by steve, 19 years ago

Moved directories into production and development parent directories

File size: 3.2 KB
Line 
1#
2# This example demonstrates the creation of multiple actors and the
3# manipulation of their properties and transformations. It is a
4# derivative of Cone.tcl, see that example for more information.
5#
6
7#
8# First we include the VTK Tcl packages which will make available
9# all of the VTK commands to Tcl.
10#
11package require vtk
12
13#
14# Next we create an instance of vtkConeSource and set some of its
15# properties. The instance of vtkConeSource "cone" is part of a visualization
16# pipeline (it is a source process object); it produces data (output type is
17# vtkPolyData) which other filters may process.
18#
19vtkConeSource cone
20cone SetHeight 3.0
21cone SetRadius 1.0
22cone SetResolution 10
23
24#
25# In this example we terminate the pipeline with a mapper process object.
26# (Intermediate filters such as vtkShrinkPolyData could be inserted in
27# between the source and the mapper.)  We create an instance of
28# vtkPolyDataMapper to map the polygonal data into graphics primitives. We
29# connect the output of the cone souece to the input of this mapper.
30#
31vtkPolyDataMapper coneMapper
32coneMapper SetInput [cone GetOutput]
33
34#
35# Create an actor to represent the first cone. The actor's properties are
36# modified to give it different surface properties. By default, an actor
37# is create with a property so the GetProperty() method can be used.
38#
39vtkActor coneActor
40coneActor SetMapper coneMapper
41[coneActor GetProperty] SetColor 0.2 0.63 0.79
42[coneActor GetProperty] SetDiffuse 0.7
43[coneActor GetProperty] SetSpecular 0.4
44[coneActor GetProperty] SetSpecularPower 20
45
46#
47# Create a property and directly manipulate it. Assign it to the
48# second actor.
49#
50vtkProperty property
51property SetColor 1.0 0.3882 0.2784
52property SetDiffuse 0.7
53property SetSpecular 0.4
54property SetSpecularPower 20
55
56#
57# Create a second actor and a property. The property is directly
58# manipulated and then assigned to the actor. In this way, a single
59# property can be shared among many actors. Note also that we use the
60# same mapper as the first actor did. This way we avoid duplicating
61# geometry, which may save lots of memory if the geoemtry is large.
62vtkActor coneActor2
63coneActor2 SetMapper coneMapper
64[coneActor2 GetProperty] SetColor 0.2 0.63 0.79
65coneActor2 SetProperty property
66coneActor2 SetPosition 0 2 0
67
68#
69# Create the Renderer and assign actors to it. A renderer is like a
70# viewport. It is part or all of a window on the screen and it is responsible
71# for drawing the actors it has.  We also set the background color here.
72#
73vtkRenderer ren1
74ren1 AddActor coneActor
75ren1 AddActor coneActor2
76ren1 SetBackground 0.1 0.2 0.4
77
78#
79# Finally we create the render window which will show up on the screen
80# We put our renderer into the render window using AddRenderer. We also
81# set the size to be 300 pixels by 300.
82#
83vtkRenderWindow renWin
84renWin AddRenderer ren1
85renWin SetSize 300 300
86
87#
88# Now we loop over 360 degreeees and render the cone each time.
89#
90for {set i 0} {$i < 360} {incr i} {
91   after 10
92   # render the image
93   renWin Render
94   # rotate the active camera by one degree
95   [ren1 GetActiveCamera] Azimuth 1
96}
97
98#
99# Free up any objects we created.
100#
101vtkCommand DeleteAllObjects
102
103#
104# Exit the application.
105#
106exit
107
108
109
Note: See TracBrowser for help on using the repository browser.