1from __future__ import print_function 2# make the handler of the color field to call chicken_mcnuggets() 3# instead of the default set handle_color() function 4handler_registry['color'] = 'chicken_mcnuggets' 5 6def chicken_mcnuggets(): 7 # print color.getValue().getValue() 8 pass 9 10# Initialize the color Packer (required of any property node that 11# uses an SoColorPacker to set diffuse color or transparency: 12colorPacker = SoColorPacker() 13transpValue = floatp() 14 15def doAction(action): 16 global transpValue 17 18 if not brightness.isIgnored() and not SoOverrideElement.getEmissiveColorOverride(action.getState()): 19 emissiveColor = color.getValue() * brightness.getValue() 20 # print 'doAction():', color.getValue().getValue() 21 22 # Use the Lazy element to set emissive color. 23 # Note that this will not actually send the color to GL. 24 SoLazyElement.setEmissive(action.getState(), emissiveColor) 25 26 # To send transparency we again check ignore flag and override element. 27 if not transparency.isIgnored() and not SoOverrideElement.getTransparencyOverride(action.getState()): 28 # keep a copy of the transparency that we are putting in the state: 29 transpValue.assign(transparency.getValue()) 30 31 # The color packer must be provided when the transparency is set, 32 # so that the transparency will be merged with current diffuse color 33 # in the state: 34 SoLazyElement.setTransparency(action.getState(), self, 1, transpValue, colorPacker) 35 36def GLRender(action): 37 action.setTransparencyType(SoGLRenderAction.SORTED_OBJECT_BLEND) 38 doAction(action) 39 40def callback(action): 41 doAction(action) 42 43wa = SoWriteAction() 44wa.apply(self) 45 46print(handler_registry) 47 48print('== Glow script loaded ==') 49