Wall of lights – How to set up a wall of animated light bulbs
Nine out of ten times you’re overegging the pudding by adding actual light source to the setup as you most likely could get away with a using really bright material on the object. But there is that one time you do need it, and this apparently is it.
Start by opening the scene Light_Wall.scn from this issues CD. There are several ways you can animate the lights switching on and off, but the perhaps most intuitive is by using an image sequence. Select the Wall object and from the Get > Property > Texture Map menu choose Texture Map. In the Clip section of the PPG, click the New button and choose New From File. In the Browser, select the LightSwitch.pic sequence from the Pictures folder and click OK. Select the Texture_Projection in the UV Property section and then close the PPG.
From the Get > Primitive > Point Cloud menu choose Empty and press [Alt] +  to open an ICE Tree. From the Create menu choose ICE Tree. Press  to open an Explorer and drag and drop the Wall object into the ICE Tree. Get a Get Data node and connect the Out Name output of the Wall node to its In Name input. Open its Property Page (PPG) and enter PolygonPosition as the reference. This will get the centre of each of the polygons of the wall object, but as the object itself is rotated you’ll also need to add the global rotation. This is done by multiplying the polygons position with the objects global matrix. Get a Get Data node and enter kine.global as the reference and connect the Name output of the Get Wall node to the In Name input. Then get a Multiply Vector by Matrix node and connect the Value output of the Get PolygonPosition node to the Vector input and Value output of the kine.global to the Matrix input. Get an Add Point node and connect the Result output of the Multiply Vector by Matrix to the Positions1 input. Connect the Add output of the Add Point node to the Port1 of the ICE tree. Get a Set Data node, enter Self.Size as the reference and then enter 1 as the Size. Connect the Execute output of the Set Data node to the Port2 input of the ICE Tree.
Get a Get Closets Location node and connect the Value output of the Get Wall node to its Geometry input. The location you want to get is the location closest to each point so get a Get Data node, enter Self.PointPosition as the reference and connect it to the Position input of the Get Closest Location node. Then connect the Value output of the Wall node to the Geometry input. Get a Get Data node, enter Texture_Map as the reference and connect the Location output of the Get Closest Location to its Source input. Get a Color to Brightness node and connect the Color output of the Get_Texture to its Color input.
Get an Instance Shape node and open its PPG. Click on the Explore button and select the Light_ Bulbs group. Change the Hierarchy Mode to Object and Children. The Index value controls which object/hierarchy to be used. If the lightness value of the texture map is less than 0.5, the light should be off and the light bulb hierarchy with Index 0 should be used. If the lightness is higher than 0.5 the light should be switched on and the hierarchy with the added point light (index 1) should be used instead. Get a Round node and connect the Brightness output of Color to Brightness to its Value input. Then connect the Integer output of the Round node to the Index input of the Instance Shape. Connect the Shape output of the Instance Shape to the New(Value) input of the Set Data node. Open the PPG and enter Self.Shape as Reference1.
While the points are in the right locations they are facing the wrong direction. To fix this, you can get the orientation of each of the polygons and then use that data to set the orientation of the points. Get a Get Data node and enter PolygonRefFrame as the reference. Get a Matrix to SRT node and connect the Value output of the PolygonRefFrame to the Matrix input. Connect the Rotation output of the Matrix to SRT to the New(Value) input of the Set Data node. Open the PPG and enter Self.Orientation as Reference2.
The perhaps most intuitive way to create different patterns for the lights switching on and off is by using a texture map, which in turn controls the lights based on the lightness of the images.
The project files used in this tutorial can be found at: http://dl.dropbox.com/u/3834689/CaffeineAbuse/Wall_of_Lights.zip
To add color to the lights you can add a second texture map using a different image sequence. Use the same approach as for the first map, but connect the Value output of the Texture_Map directly to a Self.Color input on the Set Data node. Then add a Color_Attribute node (with the Attribute set to Color) to the light’s Render Tree and connect it to the color input of the soft_light shader.