Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r1970 - trunk/SwigInterface


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [Manta] r1970 - trunk/SwigInterface
  • Date: Sun, 6 Jan 2008 21:03:05 -0700 (MST)

Author: abe
Date: Sun Jan  6 21:03:04 2008
New Revision: 1970

Modified:
   trunk/SwigInterface/wxManta.py
Log:

Moved status bar frame rate update into a idle callback, instead of
directly calling from the swap buffer code.
M    SwigInterface/wxManta.py


Modified: trunk/SwigInterface/wxManta.py
==============================================================================
--- trunk/SwigInterface/wxManta.py      (original)
+++ trunk/SwigInterface/wxManta.py      Sun Jan  6 21:03:04 2008
@@ -89,7 +89,29 @@
 
###############################################################################
 
###############################################################################
 
+def createEmptyScenePython( frame, engine ):
+
+    frame.SetTitle( "Empty Scene" );
+
+    # Empty scene.
+    scene = manta_new(Scene())
+    
scene.setBackground(manta_new(ConstantBackground(ColorDB.getNamedColor("white"))))
+    scene.getRenderParameters().maxDepth = 5
+    
+    # Empty object group.
+    scene.setObject(manta_new(Group()))
+
+    # Empty light set.
+    lights = manta_new(LightSet())
+    lights.setAmbientLight(manta_new(ConstantAmbient(Color.black())))
+    scene.setLights(lights)
+    
+    engine.setScene( scene )
+
 def createDefaultScenePython( frame, engine ):
+
+    frame.SetTitle( "Default Scene" );
+
     scene = manta_new(Scene())
     
scene.setBackground(manta_new(ConstantBackground(ColorDB.getNamedColor("SkyBlue3").scaled(0.5))))
     red = manta_new(Phong(Color(RGBColor(0.6, 0, 0)),
@@ -216,10 +238,14 @@
         self.sync_display.doneRendering()
         self.SwapBuffers()
         current_time = time.time()
-        framerate = 1.0/(current_time - self.prev_time)
-        self.updateFramerate(framerate)
+        delta_time = current_time - self.prev_time;
+
         self.prev_time = current_time
+        self.framerate = 1.0/delta_time
 
+        # if (delta_time > 0.5):
+        #    framerate = 1.0/delta_time
+        #    self.updateFramerate(framerate)
 
 
###############################################################################
 
###############################################################################
@@ -239,6 +265,7 @@
         # Setup events
         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
         self.Bind(wx.EVT_SIZE, self.OnSize)
+        self.Bind(wx.EVT_IDLE, self.OnIdle)
 
         # Create the StatusBar
         self.statusbar = self.CreateStatusBar()
@@ -830,14 +857,19 @@
         currentTimeView = TimeViewSampler.toggleTimeView(self.engine, 
self.timeView)
         if (self.timeView != currentTimeView):
             self.timeView = currentTimeView
+
+    def OnIdle(self,event):
+        self.updateFramerate(self.canvas.framerate);
     
     def updateFramerate(self, framerate):
         text = ""
         if (framerate > 1):
-            text = "%3.1lf fps" % framerate
+            text = "%3.1lf fps" % framerate            
         else:
             text = "%2.2lf fps - %3.1lf spf" % (framerate , 1.0/framerate);
+
         self.statusbar.SetStatusText(text, 0)
+        
 
 ###########################################################################
 ## usage




  • [Manta] r1970 - trunk/SwigInterface, abe, 01/06/2008

Archive powered by MHonArc 2.6.16.

Top of page