Selaa lähdekoodia

*** empty log message ***

Mark Mine 25 vuotta sitten
vanhempi
sitoutus
1a1b9ae9c2

+ 9 - 1
direct/src/directutil/DirectLights.py

@@ -42,7 +42,7 @@ class DirectLights(NodePath):
             light.setColor(VBase4(1))
         elif type == 'spot':
             self.spotCount += 1
-            light = SpotLight('spot_' + `self.spotCount`)
+            light = Spotlight('spot_' + `self.spotCount`)
             light.setColor(VBase4(1))
         # Add the new light
         self.addLight(light)
@@ -57,6 +57,7 @@ class DirectLights(NodePath):
 
     def addLight(self, light):
         # Attach node to self
+        # MRM: This doesn't work for spotlights!
         nodePath = self.attachNewNode(light.upcastToNamedNode())
         # Store it in the lists
         self.lightList.append(light)
@@ -71,6 +72,13 @@ class DirectLights(NodePath):
         """ Turn off all DIRECT lights """
         base.initialState.clearAttribute(LightTransition.getClassType())
 
+    def toggle(self):
+        """ Toggles light attribute, but doesn't toggle individual lights """
+        if base.initialState.hasAttribute(LightTransition.getClassType()):
+            self.allOff()
+        else:
+            self.allOn()
+
     def setOnNum(self, index):
         self.setOn(self.lightList[index])
 

+ 2 - 4
direct/src/directutil/DirectManipulation.py

@@ -64,10 +64,10 @@ class DirectManipulationControl(PandaObject):
         taskMgr.spawnTaskNamed(
             Task.doLater(MANIPULATION_MOVE_DELAY,
                          Task.Task(self.switchToMoveMode),
-                         'manip-switch-to-move'),
+                         'manip-move-wait'),
             'manip-move-wait')
         """
-        # Or if we move far enough
+        # Begin manipulating once we move far enough
         self.moveDir = None
         watchMouseTask = Task.Task(self.watchMouseTask)
         watchMouseTask.initX = direct.dr.mouseX
@@ -84,7 +84,6 @@ class DirectManipulationControl(PandaObject):
         if (((abs (state.initX - direct.dr.mouseX)) > 0.01) |
             ((abs (state.initY - direct.dr.mouseY)) > 0.01)):
             taskMgr.removeTasksNamed('manip-move-wait')
-            taskMgr.removeTasksNamed('manip-switch-to-move')
             self.mode = 'move'
             self.manipulateObject()
             return Task.done
@@ -94,7 +93,6 @@ class DirectManipulationControl(PandaObject):
     def manipulationStop(self):
         taskMgr.removeTasksNamed('manipulateObject')
         taskMgr.removeTasksNamed('manip-move-wait')
-        taskMgr.removeTasksNamed('manip-switch-to-move')
         taskMgr.removeTasksNamed('manip-watch-mouse')
         # depending on flag.....
         if self.mode == 'select':

+ 4 - 2
direct/src/directutil/DirectSession.py

@@ -28,7 +28,7 @@ class DirectSession(PandaObject):
         self.useObjectHandles()
         self.grid = DirectGrid()
         self.grid.disable()
-        self.lights = DirectLights()
+        self.lights = DirectLights(direct.group)
         # Create some default lights
         self.lights.createDefaultLights()
         # But turn them off
@@ -83,7 +83,7 @@ class DirectSession(PandaObject):
                           'shift', 'shift-up', 'alt', 'alt-up',
                           'control', 'control-up',
                           'page_up', 'page_down',
-                          'b', 'c', 'f', 'l', 't', 'v', 'w']
+                          'b', 'c', 'f', 'l', 's', 't', 'v', 'w']
         self.mouseEvents = ['mouse1', 'mouse1-up',
                             'mouse2', 'mouse2-up',
                             'mouse3', 'mouse3-up']
@@ -191,6 +191,8 @@ class DirectSession(PandaObject):
         elif input == 'escape':
             self.deselectAll()
         elif input == 'l':
+            self.lights.toggle()
+        elif input == 's':
             if self.selected.last:
                 self.select(self.selected.last)
         elif input == 'delete':