Author: ArcRiley Date: 2008-09-02 19:07:39 -0400 (Tue, 02 Sep 2008) New Revision: 1350
Modified: trunk/pysoy/examples/AnimBlock.py trunk/pysoy/examples/CollideBlocks.py trunk/pysoy/examples/GlowBlocks.py trunk/pysoy/examples/RainbowBlocks.py trunk/pysoy/examples/SuperBlocks.py trunk/pysoy/examples/TexBlocks.py trunk/pysoy/examples/joint_blocks.py trunk/pysoy/examples/planar_blocks.py trunk/pysoy/examples/test_blocks.py trunk/pysoy/include/soy.actions.pxd trunk/pysoy/src/actions/Action.pym trunk/pysoy/src/actions/Callback.pym trunk/pysoy/src/actions/Force.pym trunk/pysoy/src/actions/Locomotive.pym trunk/pysoy/src/actions/Rotate.pym Log: Tickets #898 #915 : * added docs to soy.actions.Action .Callback & .Force * changed soy.actions.Force to take a Vector as second argument * updated examples to new Force API * added Id keyword to Locomotive and Rotate classes Modified: trunk/pysoy/examples/AnimBlock.py =================================================================== --- trunk/pysoy/examples/AnimBlock.py 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/examples/AnimBlock.py 2008-09-02 23:07:39 UTC (rev 1350) @@ -51,12 +51,13 @@ print lig.diffuse key = soy.controllers.Keyboard(win) -key['Q'] = soy.actions.Force(bks['Marble'], -100, 0, 0) -key['R'] = soy.actions.Force(bks['Marble'], 0, 100, 0) -key['S'] = soy.actions.Force(bks['Marble'], 100, 0, 0) -key['T'] = soy.actions.Force(bks['Marble'], 0, -100, 0) -key['U'] = soy.actions.Force(bks['Marble'], 0, 0, -100) -key['V'] = soy.actions.Force(bks['Marble'], 0, 0, 100) +marble = bks['Marble'] +key['Q'] = soy.actions.Force(marble, soy.atoms.Vector((-100, 0, 0))) +key['R'] = soy.actions.Force(marble, soy.atoms.Vector(( 0, 100, 0))) +key['S'] = soy.actions.Force(marble, soy.atoms.Vector(( 100, 0, 0))) +key['T'] = soy.actions.Force(marble, soy.atoms.Vector(( 0, -100, 0))) +key['U'] = soy.actions.Force(marble, soy.atoms.Vector(( 0, 0, -100))) +key['V'] = soy.actions.Force(marble, soy.atoms.Vector(( 0, 0, 100))) key['q'] = soy.actions.Quit() key[ 1 ] = soy.actions.Quit() # 9 = esc key key['f'] = fullscreenToggle Modified: trunk/pysoy/examples/CollideBlocks.py =================================================================== --- trunk/pysoy/examples/CollideBlocks.py 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/examples/CollideBlocks.py 2008-09-02 23:07:39 UTC (rev 1350) @@ -55,12 +55,13 @@ 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) +pearl = bks['Pearl'] +key['Q'] = soy.actions.Force(pearl, soy.atoms.Vector((-100, 0, 0))) +key['R'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 100, 0))) +key['S'] = soy.actions.Force(pearl, soy.atoms.Vector(( 100, 0, 0))) +key['T'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, -100, 0))) +key['U'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, -100))) +key['V'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, 100))) key['q'] = soy.actions.Quit() key[ 1 ] = soy.actions.Quit() # 9 = esc key key['f'] = fullscreenToggle Modified: trunk/pysoy/examples/GlowBlocks.py =================================================================== --- trunk/pysoy/examples/GlowBlocks.py 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/examples/GlowBlocks.py 2008-09-02 23:07:39 UTC (rev 1350) @@ -57,12 +57,13 @@ 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) +pearl = bks['Pearl'] +key['Q'] = soy.actions.Force(pearl, soy.atoms.Vector((-100, 0, 0))) +key['R'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 100, 0))) +key['S'] = soy.actions.Force(pearl, soy.atoms.Vector(( 100, 0, 0))) +key['T'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, -100, 0))) +key['U'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, -100))) +key['V'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, 100))) key['q'] = soy.actions.Quit() key[ 1 ] = soy.actions.Quit() # 9 = esc key key['f'] = fullscreenToggle Modified: trunk/pysoy/examples/RainbowBlocks.py =================================================================== --- trunk/pysoy/examples/RainbowBlocks.py 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/examples/RainbowBlocks.py 2008-09-02 23:07:39 UTC (rev 1350) @@ -56,12 +56,13 @@ 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) +pearl = bks['Pearl'] +key['Q'] = soy.actions.Force(pearl, soy.atoms.Vector((-100, 0, 0))) +key['R'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 100, 0))) +key['S'] = soy.actions.Force(pearl, soy.atoms.Vector(( 100, 0, 0))) +key['T'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, -100, 0))) +key['U'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, -100))) +key['V'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, 100))) key['q'] = soy.actions.Quit() key[ 1 ] = soy.actions.Quit() # 9 = esc key key['f'] = fullscreenToggle Modified: trunk/pysoy/examples/SuperBlocks.py =================================================================== --- trunk/pysoy/examples/SuperBlocks.py 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/examples/SuperBlocks.py 2008-09-02 23:07:39 UTC (rev 1350) @@ -177,12 +177,13 @@ print lig.diffuse key = soy.controllers.Keyboard(win) -key['Q'] = soy.actions.Force(bks['Pearl0'], -100, 0, 0) -key['R'] = soy.actions.Force(bks['Pearl0'], 0, 100, 0) -key['S'] = soy.actions.Force(bks['Pearl0'], 100, 0, 0) -key['T'] = soy.actions.Force(bks['Pearl0'], 0, -100, 0) -key['U'] = soy.actions.Force(bks['Pearl0'], 0, 0, -100) -key['V'] = soy.actions.Force(bks['Pearl0'], 0, 0, 100) +pearl = bks['Pearl0'] +key['Q'] = soy.actions.Force(pearl, soy.atoms.Vector((-100, 0, 0))) +key['R'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 100, 0))) +key['S'] = soy.actions.Force(pearl, soy.atoms.Vector(( 100, 0, 0))) +key['T'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, -100, 0))) +key['U'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, -100))) +key['V'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, 100))) key['q'] = soy.actions.Quit() key[ 1 ] = soy.actions.Quit() # 9 = esc key key['f'] = fullscreenToggle Modified: trunk/pysoy/examples/TexBlocks.py =================================================================== --- trunk/pysoy/examples/TexBlocks.py 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/examples/TexBlocks.py 2008-09-02 23:07:39 UTC (rev 1350) @@ -49,12 +49,13 @@ print lig.diffuse key = soy.controllers.Keyboard(win) -key['Q'] = soy.actions.Force(bks['Marble'], -100, 0, 0) -key['R'] = soy.actions.Force(bks['Marble'], 0, 100, 0) -key['S'] = soy.actions.Force(bks['Marble'], 100, 0, 0) -key['T'] = soy.actions.Force(bks['Marble'], 0, -100, 0) -key['U'] = soy.actions.Force(bks['Marble'], 0, 0, -100) -key['V'] = soy.actions.Force(bks['Marble'], 0, 0, 100) +marble = bks['Marble'] +key['Q'] = soy.actions.Force(marble, soy.atoms.Vector((-100, 0, 0))) +key['R'] = soy.actions.Force(marble, soy.atoms.Vector(( 0, 100, 0))) +key['S'] = soy.actions.Force(marble, soy.atoms.Vector(( 100, 0, 0))) +key['T'] = soy.actions.Force(marble, soy.atoms.Vector(( 0, -100, 0))) +key['U'] = soy.actions.Force(marble, soy.atoms.Vector(( 0, 0, -100))) +key['V'] = soy.actions.Force(marble, soy.atoms.Vector(( 0, 0, 100))) key['q'] = soy.actions.Quit() key[ 1 ] = soy.actions.Quit() # 9 = esc key key['f'] = fullscreenToggle Modified: trunk/pysoy/examples/joint_blocks.py =================================================================== --- trunk/pysoy/examples/joint_blocks.py 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/examples/joint_blocks.py 2008-09-02 23:07:39 UTC (rev 1350) @@ -17,12 +17,13 @@ win = soy.Window(scr, 'Collision Blocks', background=soy.colors.teal) pro = soy.widgets.Projector(win, camera=cam) 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) +pearl = bks['Pearl'] +key['Q'] = soy.actions.Force(pearl, soy.atoms.Vector((-100, 0, 0))) +key['R'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 100, 0))) +key['S'] = soy.actions.Force(pearl, soy.atoms.Vector(( 100, 0, 0))) +key['T'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, -100, 0))) +key['U'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, -100))) +key['V'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, 100))) key['q'] = soy.actions.Quit() key[ 1 ] = soy.actions.Quit() # 9 = esc key wcn = soy.controllers.Window(win) Modified: trunk/pysoy/examples/planar_blocks.py =================================================================== --- trunk/pysoy/examples/planar_blocks.py 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/examples/planar_blocks.py 2008-09-02 23:07:39 UTC (rev 1350) @@ -60,12 +60,13 @@ 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) +pearl = bks['Pearl'] +key['Q'] = soy.actions.Force(pearl, soy.atoms.Vector((-100, 0, 0))) +key['R'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 100, 0))) +key['S'] = soy.actions.Force(pearl, soy.atoms.Vector(( 100, 0, 0))) +key['T'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, -100, 0))) +key['U'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, -100))) +key['V'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, 100))) key['q'] = soy.actions.Quit() key[ 1 ] = soy.actions.Quit() # 9 = esc key key['f'] = fullscreenToggle Modified: trunk/pysoy/examples/test_blocks.py =================================================================== --- trunk/pysoy/examples/test_blocks.py 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/examples/test_blocks.py 2008-09-02 23:07:39 UTC (rev 1350) @@ -39,12 +39,13 @@ 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) +pearl = bks['Pearl'] +key['Q'] = soy.actions.Force(pearl, soy.atoms.Vector((-100, 0, 0))) +key['R'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 100, 0))) +key['S'] = soy.actions.Force(pearl, soy.atoms.Vector(( 100, 0, 0))) +key['T'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, -100, 0))) +key['U'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, -100))) +key['V'] = soy.actions.Force(pearl, soy.atoms.Vector(( 0, 0, 100))) key['q'] = soy.actions.Quit() key[ 1 ] = soy.actions.Quit() # 9 = esc key key['f'] = fullscreenToggle Modified: trunk/pysoy/include/soy.actions.pxd =================================================================== --- trunk/pysoy/include/soy.actions.pxd 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/include/soy.actions.pxd 2008-09-02 23:07:39 UTC (rev 1350) @@ -18,6 +18,7 @@ # $Id$ cimport ode +cimport soy.atoms cimport soy.bodies cdef class Action : @@ -26,7 +27,7 @@ cdef class Force (Action) : cdef soy.bodies.Body _target - cdef ode.dVector3 _vector + cdef soy.atoms.Vector _vector cdef class Stdout (Action) : cdef char* _text Modified: trunk/pysoy/src/actions/Action.pym =================================================================== --- trunk/pysoy/src/actions/Action.pym 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/src/actions/Action.pym 2008-09-02 23:07:39 UTC (rev 1350) @@ -1,4 +1,4 @@ -# PySoy action.Action class +# PySoy's action.Action class # # Copyright (C) 2006,2007,2008 PySoy Group # @@ -18,10 +18,10 @@ # $Id$ cdef class Action : - '''PySoy Action + '''soy.actions.Action This is the base Action class which all actions must inherit. - It serves no other function. + It serves no other purpose. ''' ############################################################################ @@ -30,6 +30,10 @@ # def __repr__(self) : + ''' + @rtype : string + @return : class name + ''' return '<%s>' % self.__class__.__name__ Modified: trunk/pysoy/src/actions/Callback.pym =================================================================== --- trunk/pysoy/src/actions/Callback.pym 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/src/actions/Callback.pym 2008-09-02 23:07:39 UTC (rev 1350) @@ -1,18 +1,18 @@ -# PySoy action.Callback class +# PySoy's action.Callback 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 +# 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. +# GNU Affero General Public License for more details. # -# You should have received a copy of the GNU Affero General Public License +# 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 # # $Id$ @@ -22,7 +22,10 @@ cdef class Callback (Action) : '''soy.actions.Callback - This is a Python callback action. + This is a Python function callback action. + + @type callback : function + @param callback : Python function to be called when action is performed ''' ############################################################################ Modified: trunk/pysoy/src/actions/Force.pym =================================================================== --- trunk/pysoy/src/actions/Force.pym 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/src/actions/Force.pym 2008-09-02 23:07:39 UTC (rev 1350) @@ -20,8 +20,12 @@ cdef class Force (Action) : '''soy.actions.Force - Adds velocity to it's target. - First argument is the force's target, an instance of soy.bodies.Body. + Adds velocity to a target L{body<soy.bodies.Body>}. + + @type target : soy.bodies.Body + @param target : Body which force will be applied to + @type vector : soy.atoms.Vector + @param vector : Vector of force to be applied ''' ############################################################################ @@ -29,13 +33,13 @@ # Python functions # - def __cinit__(self, target, xforce, yforce, zforce, *args, **kw) : + def __cinit__(self, target, vector, *args, **kw) : if not isinstance(target, soy.bodies.Body) : raise TypeError('first argument must be an instance of soy.bodies.Body') - self._target = target - self._vector[0] = xforce - self._vector[1] = yforce - self._vector[2] = zforce + if not isinstance(vector, soy.atoms.Vector) : + raise TypeError('second argument must be an instance of soy.atoms.Vector') + self._target = target + self._vector = vector ############################################################################ @@ -46,4 +50,4 @@ cdef void _perform(self, unsigned int _duration) : # # Body._addForce calls ode.dBodyAddForce on itself with proper locking - (<soy.bodies.Body> self._target)._addForce(self._vector) + (<soy.bodies.Body> self._target)._addForce(self._vector._position) Modified: trunk/pysoy/src/actions/Locomotive.pym =================================================================== --- trunk/pysoy/src/actions/Locomotive.pym 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/src/actions/Locomotive.pym 2008-09-02 23:07:39 UTC (rev 1350) @@ -15,6 +15,7 @@ # 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 # +# $Id$ cdef class Locomotive (Action) : '''soy.actions.Locomotive Property changes on: trunk/pysoy/src/actions/Locomotive.pym ___________________________________________________________________ Added: svn:keywords + Id Modified: trunk/pysoy/src/actions/Rotate.pym =================================================================== --- trunk/pysoy/src/actions/Rotate.pym 2008-08-28 05:09:07 UTC (rev 1349) +++ trunk/pysoy/src/actions/Rotate.pym 2008-09-02 23:07:39 UTC (rev 1350) @@ -15,6 +15,7 @@ # 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 # +# $Id$ cdef class Rotate (Action) : Property changes on: trunk/pysoy/src/actions/Rotate.pym ___________________________________________________________________ Added: svn:keywords + Id _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn