Author: ArcRiley
Date: 2008-05-20 15:36:23 -0400 (Tue, 20 May 2008)
New Revision: 1294

Added:
   trunk/pysoy/examples/GlowBlocks.py
   trunk/pysoy/examples/media/greendot.soy
Modified:
   trunk/pysoy/examples/blocks.py
Log:
Ticket #955 :
  * added GlowBlocks example, which shows glowmap isn't working correctly yet
  * added greendot.soy
  * did some trivial work with blocks.py


Added: trunk/pysoy/examples/GlowBlocks.py
===================================================================
--- trunk/pysoy/examples/GlowBlocks.py                          (rev 0)
+++ trunk/pysoy/examples/GlowBlocks.py  2008-05-20 19:36:23 UTC (rev 1294)
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+import soy
+import blocks
+from time import sleep
+
+sce = soy.scenes.Scene()
+cam = soy.bodies.Camera(sce)
+cam.position = (0.0, 0.0, 15.0)
+lig = soy.bodies.Light(sce)
+lig.position = (-10.0,10.0,2.0)
+
+greendot = soy.transports.File('media/greendot.soy')['gimp']
+black = soy.materials.Textured()
+black.ambient = soy.colors.black
+black.diffuse = soy.colors.Color('#222')
+black.specular= soy.colors.Color('#222')
+black.shininess = 5.0
+black.glowmap = greendot
+colors = {
+  'Aventurine'     : (soy.materials.aventurine,    black, ( 0, 0, 0)),
+  'Basalt'         : (soy.materials.basalt,        black, ( 4,-1,-4)),
+  'Copper'         : (soy.materials.copper,        black, (-3,-2,-2)),
+  'CopperSulfate'  : (soy.materials.copperSulfate, black, ( 0,-2,-1)),
+  'DarkWood'       : (soy.materials.darkWood,      black, ( 5, 3,-6)),
+  'Pearl'          : (soy.materials.pearl,         black, (-1, 2,-3)),
+  'Rhodonite'      : (soy.materials.rhodonite,     black, (-4, 1,-5)),
+  'VelvetyRed'     : (soy.materials.velvetyRed,    black, ( 3, 0,-8)),
+}
+
+bks = blocks.blocks(sce, colors)
+
+fps = soy.textures.Print()
+
+scr = soy.Screen()
+win = soy.Window(scr, 'CollideBlocks', background=soy.colors.gray)
+pro = soy.widgets.Projector(win, camera=cam)
+can = soy.widgets.Canvas(win, texture=fps)
+
+def wireframeToggle() :
+  if cam.wireframe :
+    cam.wireframe = False
+  else :
+    cam.wireframe = True
+
+def fullscreenToggle() :
+  if scr.fullscreen :
+    scr.fullscreen = None
+  else :
+    scr.fullscreen = win
+
+def moreLight() :
+  lig.diffuse = lig.diffuse + 1.0
+  print lig.diffuse  
+
+def lessLight() :
+  lig.diffuse = lig.diffuse - 1.0
+  print lig.diffuse  
+
+key = soy.controllers.Keyboard(win)
+key['Q'] = soy.actions.Force(bks['Pearl'], -100,    0,    0)
+key['R'] = soy.actions.Force(bks['Pearl'],    0,  100,    0)
+key['S'] = soy.actions.Force(bks['Pearl'],  100,    0,    0)
+key['T'] = soy.actions.Force(bks['Pearl'],    0, -100,    0)
+key['U'] = soy.actions.Force(bks['Pearl'],    0,    0, -100)
+key['V'] = soy.actions.Force(bks['Pearl'],    0,    0,  100)
+key['q'] = soy.actions.Quit()
+key[ 1 ] = soy.actions.Quit() # 9 = esc key
+key['f'] = fullscreenToggle
+key['w'] = wireframeToggle
+key['['] = lessLight
+key[']'] = moreLight
+wcn = soy.controllers.Window(win)
+wcn['close'] = soy.actions.Quit()
+
+if __name__ == '__main__' :
+  while True:
+    sleep(.1)
+    fps.text = '%sfps' % str(int(cam.fps)).zfill(4)
+    for bk in bks :
+      p = bks[bk].position
+      v = bks[bk].velocity
+      v = [v[0], v[1], v[2]]
+      if abs(p[0]) > 5 and ((p[0]>0 and v[0]>0) or (p[0]<0 and v[0]< 0)) : 
+        v[0] = v[0]*-1
+      if abs(p[1]) > 5 and ((p[1]>0 and v[1]>0) or (p[1]<0 and v[1]< 0)) : 
+        v[1] = v[1]*-1
+      if abs(p[2]) > 5 and ((p[2]>0 and v[2]>0) or (p[2]<0 and v[2]< 0)) : 
+        v[2] = v[2]*-1
+      bks[bk].velocity = v
+


Property changes on: trunk/pysoy/examples/GlowBlocks.py
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/pysoy/examples/blocks.py
===================================================================
--- trunk/pysoy/examples/blocks.py      2008-05-20 17:22:13 UTC (rev 1293)
+++ trunk/pysoy/examples/blocks.py      2008-05-20 19:36:23 UTC (rev 1294)
@@ -37,27 +37,27 @@
               Vert(b,                                      # 4
                    ( a*.485,     c*.485,     0         ),
                    ( a*.7071070, c*.7071070, 0         ),
-                   (0,1,0), #wrong
+                   ( 0,          c*1,          0       ), #wrong
                    (c*.485,      0,          0,        )),
               Vert(b,                                      # 5
                    ( a*.485,     c*.485,     d*.450    ),
                    ( a*.7071070, c*.7071070, 0         ),
-                   (0,1,0), #wrong
+                   ( 0,          c*1,        0         ), #wrong
                    (c*.485,      d*.450,     0         )),
               Vert(b,                                      # 6
                    ( a*.475,     c*.475,     d*.475    ),
                    ( a*.5773503, c*.5773503, d*.5773503),
-                   (0,1,0), #wrong
+                   ( 0,          c*1,        0         ), #wrong
                    (c*.475,      d*.475,     0         )),
               Vert(b,                                      # 7
                    ( a*.485,     c*.450,     d*.485    ),
                    ( a*.7071070, 0,          d*.7071070),
-                   (0,1,0), #wrong
+                   ( 0,          c*1,        0), #wrong
                    (c*.450,      d*.485,     0         )),
               Vert(b,                                      # 8
                    ( a*.485,     0,          d*.485    ),
                    ( a*.7071070, 0,          d*.7071070),
-                   (0,1,0), #wrong
+                   ( 0,          c*1,        0         ), #wrong
                    (0,           d*.485,     0         )))
             faces = ([points[0], points[1], points[2]],
                      [points[0], points[2], points[3]],


Property changes on: trunk/pysoy/examples/media/greendot.soy
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to