浏览代码

New light routines

Mark Mine 21 年之前
父节点
当前提交
ef181df10e
共有 1 个文件被更改,包括 7 次插入10 次删除
  1. 7 10
      direct/src/directtools/DirectLights.py

+ 7 - 10
direct/src/directtools/DirectLights.py

@@ -29,8 +29,6 @@ class DirectLights(NodePath):
         NodePath.__init__(self)
         NodePath.__init__(self)
         # Create a node for the lights
         # Create a node for the lights
         self.assign(parent.attachNewNode('DIRECT Lights'))
         self.assign(parent.attachNewNode('DIRECT Lights'))
-        # Create a light attrib
-        self.la = LightAttrib.makeAllOff()
         # Create a list of all active lights
         # Create a list of all active lights
         self.lightDict = {}
         self.lightDict = {}
         # Counts of the various types of lights
         # Counts of the various types of lights
@@ -101,13 +99,15 @@ class DirectLights(NodePath):
 
 
     def allOn(self):
     def allOn(self):
         """ Turn on all DIRECT lights """
         """ Turn on all DIRECT lights """
-        render.node().setAttrib(self.la)
+        for light in self.lightDict.values():
+            self.setOn(light)
         # Make sure there is a default material
         # Make sure there is a default material
         render.setMaterial(Material())
         render.setMaterial(Material())
 
 
     def allOff(self):
     def allOff(self):
         """ Turn off all DIRECT lights """
         """ Turn off all DIRECT lights """
-        render.node().clearAttrib(LightAttrib.getClassType())
+        for light in self.lightDict.values():
+            self.setOff(light)
 
 
     def toggle(self):
     def toggle(self):
         """ Toggles light attribute, but doesn't toggle individual lights """
         """ Toggles light attribute, but doesn't toggle individual lights """
@@ -118,14 +118,11 @@ class DirectLights(NodePath):
 
 
     def setOn(self, directLight):
     def setOn(self, directLight):
         """ setOn(directLight) """
         """ setOn(directLight) """
-        self.la = self.la.addLight(directLight.getLight())
-        if render.node().hasAttrib(LightAttrib.getClassType()):
-            render.node().setAttrib(self.la)
+        render.setLight(directLight)
             
             
     def setOff(self, directLight):
     def setOff(self, directLight):
         """ setOff(directLight)"""
         """ setOff(directLight)"""
-        self.la = self.la.removeLight(directLight.getLight())
-        if render.node().hasAttrib(LightAttrib.getClassType()):
-            render.node().setAttrib(self.la)
+        render.clearLight(directLight)
+