Open topic with navigation
Adding lights
Although only 8 realtime lights are allowed in a lighting group, you
can work around this by defining multiple groups and switching back and
forth between the different lights by enabling and disabling groups. To
work around the 8 active light limit, you can assign lights to new groups.
Only one light group can be active at one time. Change the active light
group with setLightGroup.
Lighting groups
import viz
import vizfx
import vizinfo
viz.go()
viz.move(0,0,-10)
room = vizfx.addChild('pit.osgb')
room.enable(viz.LIGHTING)
#Disable head light
viz.MainView.getHeadLight().disable()
def AddLight(lightColor,quadColor,group):
light = viz.addPointLight(group=group)
light.color(lightColor)
light.linearattenuation(0.2)
LightQuad = viz.addTexQuad(parent=light, scale=[0.2]*3)
LightQuad.billboard()
LightQuad.color(quadColor)
LightQuad.disable(viz.LIGHTING)
return light
LIGHT_SPEED = 2
#Add red light
light1 = AddLight([0.5,0,0],viz.RED,0)
light1.add(vizact.sequence(vizact.goto(-0.5,1.8,3,LIGHT_SPEED),vizact.goto(-0.5,1.8,-3,LIGHT_SPEED),viz.FOREVER))
#Add blue light
light2 = AddLight([0,0,0.5],viz.BLUE,0)
light2.add(vizact.sequence(vizact.goto(0.5,1.8,-3,LIGHT_SPEED),vizact.goto(0.5,1.8,3,LIGHT_SPEED),viz.FOREVER))
#Add white light
light3 = AddLight([1,1,1],viz.WHITE,0)
light3.translate(0,1.8,0)
#Add green light
light4 = AddLight([0,0.5,0],viz.GREEN,1)
light4.add(vizact.sequence(vizact.goto(-0.5,1.8,-3,LIGHT_SPEED),vizact.goto(-0.5,1.8,3,LIGHT_SPEED),viz.FOREVER))
#Add yellow light
light5 = AddLight([1,1,0],viz.YELLOW,1)
light5.add(vizact.sequence(vizact.goto(0.5,1.8,3,LIGHT_SPEED),vizact.goto(0.5,1.8,-3,LIGHT_SPEED),viz.FOREVER))
#Add white light
light6 = AddLight([1,1,1],viz.WHITE,1)
light6.translate(0,1.8,0)
panel = vizinfo.InfoPanel('Select a light group:')
groupList = panel.addItem(viz.addDropList(options=['0','1']))
def setLightGroup(e):
viz.setLightGroup(e.newSel)
vizact.onlist(groupList, setLightGroup)
See also
In this section:
Light basics
Light properties
Lights Command Table
Other sections:
3D model basics
Scene basics
Example scripts:
Spotlight
Shadows