Vizard 8 » Tutorials & Examples » Example scripts » Lights » Spotlight
8.0

Spotlight

\examples\tex_lighting\spotlight.py

The following script demonstrates the use of user-defined lights, and in particular shows how a spotlight works.

import viz
import vizfx
import vizact

viz.setMultiSample(4)
viz.fov(60)
viz.go()

# Load environment
room = vizfx.addChild('pit.osgb')
room.enable(viz.LIGHTING)

# Disable the headlight on the room
viz.MainView.getHeadLight().disable()

# Reduce ambient light
vizfx.setAmbientColor([0.1]*3)

# Add a spot light
mylight = viz.addSpotLight(spread=30, pos=(0,1,0))
mylight.setIntensity(2)
mylight.setSpotPenumbra(0.5)

# Spin the light
mylight.addAction(vizact.spin(0,1,0,90))