1 |
""" |
""" |
2 |
Class and functions associated with lights |
Class that controls the light and its settings. |
|
|
|
|
@var __author__: name of author |
|
|
@var __license__: licence agreement |
|
|
@var __copyright__: copyrights |
|
|
@var __url__: url entry point on documentation |
|
|
@var __version__: version |
|
|
@var __date__: date of the version |
|
3 |
""" |
""" |
4 |
|
|
|
__copyright__=""" Copyright (c) 2006 by ACcESS MNRF |
|
|
http://www.access.edu.au |
|
|
Primary Business: Queensland, Australia""" |
|
|
__license__="""Licensed under the Open Software License version 3.0 |
|
|
http://www.opensource.org/licenses/osl-3.0.php""" |
|
|
__author__="Paul Cochrane, L. Gross" |
|
|
__url__="http://www.iservo.edu.au/esys" |
|
|
__version__="$Revision:$" |
|
|
__date__="$Date:$" |
|
|
|
|
5 |
import vtk |
import vtk |
6 |
|
|
7 |
class Light: |
class Light: |
8 |
|
""" |
9 |
|
@author: John Ngui |
10 |
|
@author: Lutz Gross |
11 |
|
""" |
12 |
|
|
13 |
def __init__(self, open_scene): |
def __init__(self, open_scene): |
14 |
|
""" |
15 |
|
@type open_scene: L{OpenScene <openscene.OpenScene>} object |
16 |
|
@param open_scene: Scene in which components are to be added to |
17 |
|
""" |
18 |
|
|
19 |
self.open_scene = open_scene |
self.open_scene = open_scene |
20 |
self.vtk_light = None |
self.vtk_light = None |
21 |
|
|
22 |
self.setLight() |
self.setLight() |
23 |
|
|
24 |
def setLight(self): |
def setLight(self): |
25 |
|
""" |
26 |
|
Set up the light and associate it with the renderer. |
27 |
|
""" |
28 |
self.vtk_light = vtk.vtkLight() |
self.vtk_light = vtk.vtkLight() |
29 |
self.open_scene.getRenderer().AddLight(self.vtk_light) |
self.open_scene.getRenderer().AddLight(self.vtk_light) |
30 |
|
|
31 |
def setColor(self, red, green, blue): |
def setColor(self, colorMap): |
32 |
self.vtk_light.SetColor(red, green, blue) |
""" |
33 |
|
Set the color of the light. |
34 |
|
|
35 |
|
@type colorMap: L{ColorMap <colormap.ColorMap>} object |
36 |
|
@param colorMap: Color of the light |
37 |
|
""" |
38 |
|
|
39 |
|
self.vtk_light.SetColor(colorMap.getR(), colorMap.getG(), |
40 |
|
colorMap.getB()) |
41 |
|
|
42 |
|
|
43 |
|
def setFocalPoint(self, position): |
44 |
|
""" |
45 |
|
Set the focal point of the light. |
46 |
|
|
47 |
|
@type position: L{Position <geo.Position>} object |
48 |
|
@param position: Light focal point position |
49 |
|
""" |
50 |
|
|
51 |
|
self.vtk_light.SetFocalPoint(position.getXCoor(), position.getYCoor(), |
52 |
|
position.getZCoor()) |
53 |
|
|
54 |
|
def setPosition(self, position): |
55 |
|
""" |
56 |
|
Set the position of the light. |
57 |
|
|
58 |
|
@type position: L{Position <geo.Position>} object |
59 |
|
@param position: Light position |
60 |
|
""" |
61 |
|
|
62 |
def setFocalPoint(self, x_coor, y_coor, z_coor): |
self.vtk_light.SetPosition(position.getXCoor(), position.getYCoor(), |
63 |
self.vtk_light.SetFocalPoint(x_coor, y_coor, z_coor) |
position.getZCoor()) |
|
|
|
|
def setPosition(self, x_coor, y_coor, z_coor): |
|
|
self.vtk_light.SetPosition(x_coor, y_coor, z_coor) |
|
64 |
|
|
65 |
def setIntensity(self, intensity): |
def setIntensity(self, intensity): |
66 |
|
""" |
67 |
|
Set the intensity (brightness) of the light. |
68 |
|
|
69 |
|
@type intensity: Number |
70 |
|
@param intensity: intensity (brightness) of the light |
71 |
|
""" |
72 |
|
|
73 |
self.vtk_light.SetIntensity(intensity) |
self.vtk_light.SetIntensity(intensity) |
74 |
|
|
75 |
|
|
76 |
|
|