Author: AngeloTheodorou
Date: 2007-07-03 21:29:24 -0400 (Tue, 03 Jul 2007)
New Revision: 337

Modified:
   trunk/pysoy/src/_core-common/Scene.pxi
   trunk/pysoy/src/bodies.lights/Light.pxi
Log:
Initial lighting support for a scene (doesn't compile)


Modified: trunk/pysoy/src/_core-common/Scene.pxi
===================================================================
--- trunk/pysoy/src/_core-common/Scene.pxi      2007-07-04 01:27:00 UTC (rev 
336)
+++ trunk/pysoy/src/_core-common/Scene.pxi      2007-07-04 01:29:24 UTC (rev 
337)
@@ -28,6 +28,7 @@
   def __new__(self, *args, **kw) :
     global _scenes
     self._bodies   = soy._internals.Children()
+    self._lights   = soy._internals.Children()
     self._worldID  = ode.dWorldCreate()
     self._spaceID  = ode.dSimpleSpaceCreate(NULL)
     self._stepSize = 0.01
@@ -36,6 +37,7 @@
     _scenes.append(<void *>self)
     _scenes.unlock()
 
+
   def __dealloc__(self) :
     global _scenes
     _scenes.lock()
@@ -46,6 +48,7 @@
     if self._spaceID != NULL :
       ode.dSpaceDestroy(self._spaceID)
 
+
   def __repr__(self) :
     report = []
     if self._bodies.current == 1 :
@@ -53,9 +56,18 @@
     elif self._bodies.current > 1 :
       report.append('%d bodies' % self._bodies.current)
 
+    if report != [] and self._lights.current > 0 :
+      report.append(' and ')
+
+    if self._lights.current == 1 :
+      report.append('1 light')
+    elif self._bodies.current > 1 :
+      report.append('%d lights' % self._lights.current)
+
     if report == [] : return '<Empty Scene>'
     else : return '<Scene with %s>' % ', '.join(report)
 
+
   cdef void _render(self) :
     cdef int i
     self._bodies.lock()
@@ -63,7 +75,13 @@
       (<soy.bodies._bodies.Body> self._bodies.list[i])._render()
     self._bodies.unlock()
 
+    self._lights.lock()
+    for i from 0 <= i < self._lights.current :
+      (<soy.bodies._lights.Light> self._lights.list[i])._on()
+      (<soy.bodies._lights.Light> self._lights.list[i])._render()
+    self._lights.unlock()
 
+
   cdef int _steps(self) :
     cdef int     _step
     cdef double  _lapsTime

Modified: trunk/pysoy/src/bodies.lights/Light.pxi
===================================================================
--- trunk/pysoy/src/bodies.lights/Light.pxi     2007-07-04 01:27:00 UTC (rev 
336)
+++ trunk/pysoy/src/bodies.lights/Light.pxi     2007-07-04 01:29:24 UTC (rev 
337)
@@ -45,7 +45,38 @@
   cdef void _off(self, int id) :
     return
 
+  property scene :
+    '''Light's Scene
 
+    This is the Scene that the light is in.  When changed the body's position,
+    orientation, velocity, and rotation are all reset to (0,0,0).
+       It has be overridden from Body's method and altered to let the light be 
+       added to the more specific _lights Children object.
+    '''
+    def __get__(self) :
+      if self._isActive() :
+        return self._scene
+      else :
+        return None
+    def __set__(self, newscene) :
+      if not (isinstance(newscene, soy._core.Scene) or newscene==None) :
+        raise TypeError('not an instance of soy.Scene')
+      if self._isActive() :
+        self._scene._lights.lock()
+        self._scene._lights.remove(<void *>self)
+        self._destroy()
+        self._scene._lights.unlock()
+        if self._shape :
+          if self._scene :
+            ode.dSpaceRemove(self._scene._spaceID, self._shape._geomID)
+          ode.dSpaceAdd((<soy._core.Scene> newscene)._spaceID, 
self._shape._geomID)
+      if newscene != None :
+        self._scene = newscene
+        self._scene._lights.lock()
+        self._create()
+        self._scene._lights.append(<void *>self)
+        self._scene._lights.unlock()
+
   property ambient :
     def __get__(self) :
       return self._ambient

_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to