Vizard 7 » Command Index » Vizard objects » node3d » <node3d:light>.constantAttenuation
7.7

<node3d:light>.constantAttenuation

Sets the constant part of the attenuation value.

<node3d:light>.constantAttenuation(  
value  
)  
value
Value must be at least 0.

Remarks

Attenuation is the decrease in intensity of the light with respect to distance. The attenuation for a light is calculated as ([Quad]x)^2+[Linear]x+[Constant] where [Quad] is the quadratic attenuation, [Linear] is the linear attenuation, [Constant] is the constant attenuation and x is the distance from the light source.

The default values for these are:
quad = 0
linear = 0
constant = 1

Return Value

None

Example

import viz
viz.go()

viz.disable(viz.LIGHT0)

ball = list()
for x in range(27):
    ball.append(viz.add('white_ball.wrl'))

for x in range(3):
    for y in range(3):
        for z in range(3):
            ball[9*x+3*y+z].setPosition(x-1,y+.5,z+3)


mylight = viz.addLight()
mylight.enable()
mylight.position(0,1.5,2)
mylight.spread(10)
mylight.lookAt([-1,0,4])
mylight.constantAttenuation(1)
mylight.linearAttenuation(1)
mylight.quadraticAttenuation(1)


for x in range(100):
    mylight.addAction(vizact.spin(0,1,0,15,2))
    mylight.addAction(vizact.spin(0,1,0,-15,2))


vizact.onkeydown('x', mylight.enable)
vizact.onkeydown('z', mylight.disable)

See also

<node3d:light>.linearAttenuation
<node3d:light>.quadraticAttenuation