/[escript]/trunk/pyvisi/py_src/light.py
ViewVC logotype

Annotation of /trunk/pyvisi/py_src/light.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1078 - (hide annotations)
Thu Apr 5 06:18:47 2007 UTC (13 years, 10 months ago) by jongui
File MIME type: text/x-python
File size: 2820 byte(s)
Added and updated some epydocs.
1 jongui 1037 """
2     @author: John NGUI
3     """
4    
5     import vtk
6     from position import GlobalPosition
7     from constant import Viewport
8    
9     class Light:
10     """
11 jongui 1078 Class that defines a light. A light controls the lighting for the
12 jongui 1037 rendered object and works in a similar way to L{Camera <camera.Camera>}.
13     """
14    
15     # The SOUTH_WEST default viewport is used when there is only one viewport.
16     # This saves the user from specifying the viewport when there is only one.
17     def __init__(self, scene, data_collector, viewport = Viewport.SOUTH_WEST):
18     """
19     Initialise the light.
20    
21     @type scene: L{Scene <scene.Scene>} object
22     @param scene: Scene in which components are to be added to
23     @type data_collector: L{DataCollector <datacollector.DataCollector>}
24     object
25 jongui 1078 @param data_collector: Source of data for vizualization
26 jongui 1037 @type viewport: L{Viewport <constant.Viewport>} constant
27     @param viewport: Viewport in which objects are to be rendered on
28     """
29    
30     self.__scene = scene
31     self.__data_collector = data_collector
32     self.__viewport = viewport
33     self.__vtk_light = vtk.vtkLight()
34    
35     self.__setupLight()
36    
37     def __setupLight(self):
38     """
39     Set up the light and associate it with the renderer.
40     """
41    
42     self.__scene._addLight(self.__viewport, self.__vtk_light)
43    
44     def setColor(self, color):
45     """
46     Set the light color.
47    
48     @type color: L{Color <constant.Color>} constant
49     @param color: Light color
50     """
51    
52     self.__vtk_light.SetColor(color)
53    
54     def setFocalPoint(self, position):
55     """
56     Set the focal point of the light.
57    
58     @type position: L{GlobalPosition <position.GlobalPosition>} object
59     @param position: Light focal point
60     """
61    
62     self.__vtk_light.SetFocalPoint(position._getGlobalPosition())
63    
64     def setPosition(self, position):
65     """
66     Set the position of the light.
67    
68     @type position: L{GlobalPosition <position.GlobalPosition>} object
69     @param position: Light position
70     """
71    
72     self.__vtk_light.SetPosition(position._getGlobalPosition())
73    
74 jongui 1078 # Elevation and azimuth is set to zero so that users do not
75 jongui 1037 # have to change both at the same time.
76     def setAngle(self, elevation = 0, azimuth = 0):
77     """
78     An alternative to set the position and focal point of the light
79 jongui 1078 by using the elevation and azimuth.
80 jongui 1037
81     @type elevation: Number
82     @param elevation: Degree to rotate the light to the top and bottom
83     @type azimuth: Number
84     @param azimuth: Degree to rotate the light to the left and right
85     """
86    
87 jongui 1078 # NOTE: The elevation angle of light does not appear to suffer the same
88 jongui 1037 # constraint as the elevation angle of camera where the elevation
89     # angle is constraint between 90/-90.
90     self.__vtk_light.SetDirectionAngle(elevation, azimuth)
91    
92     def setIntensity(self, intensity):
93     """
94     Set the intensity (brightness) of the light.
95    
96     @type intensity: Number
97     @param intensity: Intensity (brightness) of the light
98     """
99    
100     self.__vtk_light.SetIntensity(intensity)
101    

  ViewVC Help
Powered by ViewVC 1.1.26