Explorar el Código

*** empty log message ***

Joe Shochet hace 25 años
padre
commit
4e636e6d38
Se han modificado 1 ficheros con 12 adiciones y 2 borrados
  1. 12 2
      direct/src/showbase/ShowBase.py

+ 12 - 2
direct/src/showbase/ShowBase.py

@@ -17,7 +17,7 @@ import AngularEulerIntegrator
 import ClockObject
 import Transitions
 import Loader
-
+import time
 
 globalClock = ClockObject.ClockObject.getGlobalClock()
 
@@ -396,7 +396,17 @@ class ShowBase:
                 self.oobeVis.reparentTo(self.camera)
             self.oobeMode = 1
 
-
+    def screenshot(self, namePrefix='screenshot'):
+        # Get the current date and time to uniquify the image (down to the second)
+        date = time.ctime(time.time())
+        # Get the current frame count to uniqify it even more
+        frameCount = globalClock.getFrameCount()
+        # Replace spaces with dashes because unix does not like spaces in the filename
+        date = date.replace(' ', '-')
+        date = date.replace(':', '-')
+        imageName = (namePrefix + '-' + date + '-' + str(frameCount) + '.pnm')
+        self.notify.info("Taking screenshot: " + imageName)
+        takeSnapshot(self.win, imageName)
 
     def run(self):
         self.taskMgr.run()