Author: FrankieWoodruff
Date: 2008-06-19 13:01:51 -0400 (Thu, 19 Jun 2008)
New Revision: 1305

Added:
   trunk/pysoy/src/actions/Locomotive.pym
   trunk/pysoy/src/actions/Rotate.pym
Modified:
   trunk/pysoy/include/soy.actions.pxd
   trunk/pysoy/include/soy.bodies.pxd
   trunk/pysoy/src/actions/soy.actions.pyx
   trunk/pysoy/src/bodies/Body.pym
Log:
Added src/actions/Rotate.pym and /src/actions/Locomotive.pym

Modified: trunk/pysoy/include/soy.actions.pxd
===================================================================
--- trunk/pysoy/include/soy.actions.pxd 2008-06-12 05:23:36 UTC (rev 1304)
+++ trunk/pysoy/include/soy.actions.pxd 2008-06-19 17:01:51 UTC (rev 1305)
@@ -34,3 +34,6 @@
 cdef class Callback (Action) :
   cdef object                  _callback
 
+cdef class Rotate (Action) :
+  cdef soy.bodies.Body         _bod
+  cdef ode.dVector3            _rotvector

Modified: trunk/pysoy/include/soy.bodies.pxd
===================================================================
--- trunk/pysoy/include/soy.bodies.pxd  2008-06-12 05:23:36 UTC (rev 1304)
+++ trunk/pysoy/include/soy.bodies.pxd  2008-06-19 17:01:51 UTC (rev 1305)
@@ -77,6 +77,7 @@
   cdef void                     _copySet                 ( self, ode.dReal* )
   cdef void                     _copyFrom                ( self, ode.dReal* )
   cdef void                     _addForce                ( self, ode.dVector3 )
+  cdef void                     _addRotation             ( self, ode.dVector3 )
   # WindowLoop functions
   cdef void                     _calcFogCoords           ( self )         nogil
   cdef void                     _getModelviewInv         ( self, float* ) nogil

Added: trunk/pysoy/src/actions/Locomotive.pym
===================================================================
--- trunk/pysoy/src/actions/Locomotive.pym                              (rev 0)
+++ trunk/pysoy/src/actions/Locomotive.pym      2008-06-19 17:01:51 UTC (rev 
1305)
@@ -0,0 +1,41 @@
+# PySoy's actions.Locomotive class
+#
+# Copyright (C) 2006,2007,2008 PySoy Group
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published
+#  by the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
+#
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program; if not, see http://www.gnu.org/licenses
+#
+
+cdef class Locomotive (Action) :
+  '''soy.actions.Locomotive
+
+     this is a parent class for actions involving specific movements, e.g. 
Rotation
+  '''
+
+  
###################################################################################
+  #
+  # Python functions
+  #
+
+  def __repr__(self) :
+    return '<%s>' % self.__class__.__name__
+
+
+  
##################################################################################
+  #
+  # C functions
+  #
+
+  cdef void _perform(self, unsigned int _duration) :
+    # Locomotive does nothing, this function is here only to be replaced
+    return


Property changes on: trunk/pysoy/src/actions/Locomotive.pym
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/pysoy/src/actions/Rotate.pym
===================================================================
--- trunk/pysoy/src/actions/Rotate.pym                          (rev 0)
+++ trunk/pysoy/src/actions/Rotate.pym  2008-06-19 17:01:51 UTC (rev 1305)
@@ -0,0 +1,44 @@
+# PySoy's actions.Rotate class
+#
+# Copyright (C) 2006,2007,2008 PySoy Group
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published
+#  by the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
+#
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program; if not, see http://www.gnu.org/licenses
+#
+
+
+cdef class Rotate (Action) :
+  '''soy.actions.Rotate
+
+     changes a target's rotation
+  '''
+  
###################################################################################
+  #
+  # Python functions
+  #
+
+  def __cinit__(self, target, xrot, yrot, zrot, *args, **kw) :
+    if not isinstance(target, soy.bodies.Body) :
+      raise TypeError('first argument must be an instance of soy.bodies.Body')
+    self._bod  = target
+    self._rotvector[0] = xrot
+    self._rotvector[1] = yrot
+    self._rotvector[2] = zrot
+
+  
##################################################################################
+  #
+  # C functions
+  #
+
+  cdef void _perform(self, unsigned int _duration) : 
+    (<soy.bodies.Body> self._bod)._addRotation(self._rotvector)


Property changes on: trunk/pysoy/src/actions/Rotate.pym
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/pysoy/src/actions/soy.actions.pyx
===================================================================
--- trunk/pysoy/src/actions/soy.actions.pyx     2008-06-12 05:23:36 UTC (rev 
1304)
+++ trunk/pysoy/src/actions/soy.actions.pyx     2008-06-19 17:01:51 UTC (rev 
1305)
@@ -23,3 +23,5 @@
 include "Force.pym"
 include "Quit.pym"
 include "Stdout.pym"
+include "Locomotive.pym"
+include "Rotate.pym"

Modified: trunk/pysoy/src/bodies/Body.pym
===================================================================
--- trunk/pysoy/src/bodies/Body.pym     2008-06-12 05:23:36 UTC (rev 1304)
+++ trunk/pysoy/src/bodies/Body.pym     2008-06-19 17:01:51 UTC (rev 1305)
@@ -447,6 +447,15 @@
     self._scene._stepUnLock()
 
 
+  cdef void _addRotation(self, ode.dVector3 _rotvector) :
+    if self._scene is None :
+      raise UnboundLocalError('Body is not in a scene')
+    self._scene._stepLock()
+    ode.dBodyAddTorque(self._bodyID, _rotvector[0], _rotvector[1], 
_rotvector[2])
+    self._scene._stepUnLock()
+
+
+
   ##########################################################################
   #
   # WindowLoop Functions

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

Reply via email to