Author: ArcRiley Date: 2008-09-03 03:57:06 -0400 (Wed, 03 Sep 2008) New Revision: 1351
Added: trunk/pysoy/src/actions/Torque.pym Removed: trunk/pysoy/src/actions/Locomotive.pym trunk/pysoy/src/actions/Rotate.pym Modified: trunk/pysoy/examples/TexBlocks.py trunk/pysoy/include/soy.actions.pxd trunk/pysoy/include/soy.atoms.pxd trunk/pysoy/include/soy.bodies.pxd trunk/pysoy/src/actions/Quit.pym trunk/pysoy/src/actions/soy.actions.pyx trunk/pysoy/src/atoms/Axis.pym trunk/pysoy/src/atoms/Vector.pym trunk/pysoy/src/atoms/soy.atoms.pyx trunk/pysoy/src/bodies/Body.pym Log: Tickets #916 and #927 : * renamed soy.actions.Rotate -> soy.actions.Torque * more soy.atoms and soy.actions documentation * soy.atoms.Axis now inherits soy.atoms.Vector as a rotational vector * soy.actions.Torque now uses soy.atoms.Axis * TexBlocks example now uses cursor keys to change rotation Modified: trunk/pysoy/examples/TexBlocks.py =================================================================== --- trunk/pysoy/examples/TexBlocks.py 2008-09-02 23:07:39 UTC (rev 1350) +++ trunk/pysoy/examples/TexBlocks.py 2008-09-03 07:57:06 UTC (rev 1351) @@ -50,12 +50,12 @@ key = soy.controllers.Keyboard(win) 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.Torque(marble, soy.atoms.Axis((-100, 0, 0))) +key['R'] = soy.actions.Torque(marble, soy.atoms.Axis(( 0, 100, 0))) +key['S'] = soy.actions.Torque(marble, soy.atoms.Axis(( 100, 0, 0))) +key['T'] = soy.actions.Torque(marble, soy.atoms.Axis(( 0, -100, 0))) +key['U'] = soy.actions.Torque(marble, soy.atoms.Axis(( 0, 0, -100))) +key['V'] = soy.actions.Torque(marble, soy.atoms.Axis(( 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-09-02 23:07:39 UTC (rev 1350) +++ trunk/pysoy/include/soy.actions.pxd 2008-09-03 07:57:06 UTC (rev 1351) @@ -35,6 +35,6 @@ cdef class Callback (Action) : cdef object _callback -cdef class Rotate (Action) : - cdef soy.bodies.Body _bod - cdef ode.dVector3 _rotvector +cdef class Torque (Action) : + cdef soy.bodies.Body _target + cdef soy.atoms.Axis _vector Modified: trunk/pysoy/include/soy.atoms.pxd =================================================================== --- trunk/pysoy/include/soy.atoms.pxd 2008-09-02 23:07:39 UTC (rev 1350) +++ trunk/pysoy/include/soy.atoms.pxd 2008-09-03 07:57:06 UTC (rev 1351) @@ -24,17 +24,18 @@ cimport soy.materials cimport ode -cdef class Vertex : - cdef soy._datatypes.VertexList _list +cdef class Face : + cdef soy._datatypes.FaceList _list cdef int _index cdef void* _mutex +cdef class Vector : + cdef ode.dVector3 _position -cdef class Face : - cdef soy._datatypes.FaceList _list +cdef class Axis (Vector) : + cdef float _noop + +cdef class Vertex : + cdef soy._datatypes.VertexList _list cdef int _index cdef void* _mutex - - -cdef class Vector : - cdef ode.dVector3 _position \ No newline at end of file Modified: trunk/pysoy/include/soy.bodies.pxd =================================================================== --- trunk/pysoy/include/soy.bodies.pxd 2008-09-02 23:07:39 UTC (rev 1350) +++ trunk/pysoy/include/soy.bodies.pxd 2008-09-03 07:57:06 UTC (rev 1351) @@ -78,7 +78,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 ) + cdef void _addTorque ( self, ode.dVector3 ) # WindowLoop functions cdef void _calcFogCoords ( self ) nogil cdef void _getModelviewInv ( self, float* ) nogil Deleted: trunk/pysoy/src/actions/Locomotive.pym =================================================================== --- trunk/pysoy/src/actions/Locomotive.pym 2008-09-02 23:07:39 UTC (rev 1350) +++ trunk/pysoy/src/actions/Locomotive.pym 2008-09-03 07:57:06 UTC (rev 1351) @@ -1,42 +0,0 @@ -# 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 -# -# $Id$ - -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 Modified: trunk/pysoy/src/actions/Quit.pym =================================================================== --- trunk/pysoy/src/actions/Quit.pym 2008-09-02 23:07:39 UTC (rev 1350) +++ trunk/pysoy/src/actions/Quit.pym 2008-09-03 07:57:06 UTC (rev 1351) @@ -18,10 +18,9 @@ # $Id$ cdef class Quit (Action) : - '''PySoy Quit + '''soy.actions.Quit When called PySoy will quit. There are no arguments to this class. - See soy.actions.Action for more information. ''' ############################################################################ Deleted: trunk/pysoy/src/actions/Rotate.pym =================================================================== --- trunk/pysoy/src/actions/Rotate.pym 2008-09-02 23:07:39 UTC (rev 1350) +++ trunk/pysoy/src/actions/Rotate.pym 2008-09-03 07:57:06 UTC (rev 1351) @@ -1,45 +0,0 @@ -# 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 -# -# $Id$ - - -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) Copied: trunk/pysoy/src/actions/Torque.pym (from rev 1350, trunk/pysoy/src/actions/Force.pym) =================================================================== --- trunk/pysoy/src/actions/Torque.pym (rev 0) +++ trunk/pysoy/src/actions/Torque.pym 2008-09-03 07:57:06 UTC (rev 1351) @@ -0,0 +1,53 @@ +# PySoy's action.Torque 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 +# +# $Id$ + +cdef class Torque (Action) : + '''soy.actions.Torque + + Adds rotational velocity to a target L{body<soy.bodies.Body>}. + + @type target : soy.bodies.Body + @param target : Body which torque will be applied to + @type vector : soy.atoms.Axis + @param vector : Rotational vector to be applied + ''' + + ############################################################################ + # + # Python functions + # + + 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') + if not isinstance(vector, soy.atoms.Axis) : + raise TypeError('second argument must be an instance of soy.atoms.Axis') + self._target = target + self._vector = vector + + + ############################################################################ + # + # C functions + # + + cdef void _perform(self, unsigned int _duration) : + # + # Body._addTorque calls ode.dBodyAddTorque on itself with proper locking + (<soy.bodies.Body> self._target)._addTorque(self._vector._position) Property changes on: trunk/pysoy/src/actions/Torque.pym ___________________________________________________________________ Added: svn:keywords + Id Added: svn:mergeinfo + Modified: trunk/pysoy/src/actions/soy.actions.pyx =================================================================== --- trunk/pysoy/src/actions/soy.actions.pyx 2008-09-02 23:07:39 UTC (rev 1350) +++ trunk/pysoy/src/actions/soy.actions.pyx 2008-09-03 07:57:06 UTC (rev 1351) @@ -23,5 +23,4 @@ include "Force.pym" include "Quit.pym" include "Stdout.pym" -include "Locomotive.pym" -include "Rotate.pym" +include "Torque.pym" Modified: trunk/pysoy/src/atoms/Axis.pym =================================================================== --- trunk/pysoy/src/atoms/Axis.pym 2008-09-02 23:07:39 UTC (rev 1350) +++ trunk/pysoy/src/atoms/Axis.pym 2008-09-03 07:57:06 UTC (rev 1351) @@ -17,48 +17,9 @@ # # $Id$ -''' - We need an atom class called Axis storing the three axis values ODE -takes for various functions (joints, rotating a body, etc) - Testing should be done to ensure the three values constrain to ODE's specs -and a cdef function should return a dReal[3] for internal use. Lastly, adding -a function to soy.bodies.Body such as .rotate which accepts an axis and angle, -applying these to dRFromAxisAndAngle, or axis or two axis arguments to - dRFrom2Axes, or None for both which sets the body's rotational identity. -''' -cdef class Axis : - ''' PySoy Axis +cdef class Axis (Vector) : + '''soy.atoms.Axis - An atom class which stores 3 ODE axis values. - Body, Bone, Joint. + An axis is a rotational L{vector<soy.atoms.Vector>}. ''' - - ############################################################################ - # - # Python functions - # - - def __cinit__(self, *args, **keywords) : - pass - - - def __dealloc__(self) : - pass - - - def __repr__(self) : - return '<%s>' % self.__class__.__name__ - - - ############################################################################ - # - # Properties - # - - property orientation: - def __get__(self) : - pass - - def __set__(self, vector) : - pass Modified: trunk/pysoy/src/atoms/Vector.pym =================================================================== --- trunk/pysoy/src/atoms/Vector.pym 2008-09-02 23:07:39 UTC (rev 1350) +++ trunk/pysoy/src/atoms/Vector.pym 2008-09-03 07:57:06 UTC (rev 1351) @@ -51,9 +51,14 @@ self._position[index]=value def __repr__(self) : - return "<Vector at (%f, %f, %f) >" % (self._position[0], - self._position[1], - self._position[2]) + ''' + @rtype : string + @return : class name and value + ''' + return '<%s (%f, %f, %f)>' % (self.__class__.__name__, + self._position[0], + self._position[1], + self._position[2]) ############################################################################ Modified: trunk/pysoy/src/atoms/soy.atoms.pyx =================================================================== --- trunk/pysoy/src/atoms/soy.atoms.pyx 2008-09-02 23:07:39 UTC (rev 1350) +++ trunk/pysoy/src/atoms/soy.atoms.pyx 2008-09-03 07:57:06 UTC (rev 1351) @@ -18,6 +18,7 @@ # $Id$ include "__init__.pym" +include "Axis.pym" include "Face.pym" include "Vertex.pym" include "Vector.pym" Modified: trunk/pysoy/src/bodies/Body.pym =================================================================== --- trunk/pysoy/src/bodies/Body.pym 2008-09-02 23:07:39 UTC (rev 1350) +++ trunk/pysoy/src/bodies/Body.pym 2008-09-03 07:57:06 UTC (rev 1351) @@ -447,11 +447,11 @@ self._scene._stepUnLock() - cdef void _addRotation(self, ode.dVector3 _rotvector) : + cdef void _addTorque(self, ode.dVector3 _vector) : 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]) + ode.dBodyAddTorque(self._bodyID, _vector[0], _vector[1], _vector[2]) self._scene._stepUnLock() _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn