File: glow.py

package info (click to toggle)
pivy 0.6.10-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,216 kB
  • sloc: python: 36,331; cpp: 787; ansic: 733; makefile: 30; sh: 27; objc: 5
file content (48 lines) | stat: -rw-r--r-- 1,768 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from __future__ import print_function
# make the handler of the color field to call chicken_mcnuggets()
# instead of the default set handle_color() function
handler_registry['color'] = 'chicken_mcnuggets'

def chicken_mcnuggets():
  # print color.getValue().getValue()
  pass

# Initialize the color Packer (required of any property node that
# uses an SoColorPacker to set diffuse color or transparency:
colorPacker = SoColorPacker()
transpValue = floatp()

def doAction(action):
    global transpValue

    if not brightness.isIgnored() and not SoOverrideElement.getEmissiveColorOverride(action.getState()):
        emissiveColor = color.getValue() * brightness.getValue()
        # print 'doAction():', color.getValue().getValue()

        # Use the Lazy element to set emissive color. 
        # Note that this will not actually send the color to GL.       
        SoLazyElement.setEmissive(action.getState(), emissiveColor)

    # To send transparency we again check ignore flag and override element.
    if not transparency.isIgnored() and not SoOverrideElement.getTransparencyOverride(action.getState()):
        # keep a copy of the transparency that we are putting in the state:
        transpValue.assign(transparency.getValue())
     
        # The color packer must be provided when the transparency is set,
        # so that the transparency will be merged with current diffuse color
        # in the state:
        SoLazyElement.setTransparency(action.getState(), self, 1, transpValue, colorPacker)

def GLRender(action):
    action.setTransparencyType(SoGLRenderAction.SORTED_OBJECT_BLEND)
    doAction(action)

def callback(action):
    doAction(action)

wa = SoWriteAction()
wa.apply(self)

print(handler_registry)

print('== Glow script loaded ==')