Author: JonNeal Date: 2008-03-09 17:05:07 -0400 (Sun, 09 Mar 2008) New Revision: 1118
Modified: trunk/pysoy/src/_datatypes/BodyPosition.pxi Log: Ticket #945: soy._datatypes.BodyPosition work. Modified: trunk/pysoy/src/_datatypes/BodyPosition.pxi =================================================================== --- trunk/pysoy/src/_datatypes/BodyPosition.pxi 2008-03-09 19:40:19 UTC (rev 1117) +++ trunk/pysoy/src/_datatypes/BodyPosition.pxi 2008-03-09 21:05:07 UTC (rev 1118) @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, see http://www.gnu.org/licenses # -# $Id:$ +# $Id$ cdef class BodyPosition : '''soy._datatypes.BodyPosition @@ -25,3 +25,27 @@ def __cinit__(self, parent) : self._body = parent + + def __setitem__(self, index) : + if type(index)!=tuple and type(index)!=list : + raise TypeError('Must provide a tuple or list') + if len(index)!=3 : + raise IndexError('position index out of range') + if self._body._bodyID != NULL : + (<soy.scenes.Scene> self._body._scene)._stepLock() + ode.dBodySetPosition(self._body._bodyID, index[0], index[1], index[2]) + (<soy.scenes.Scene> self._body._scene)._stepUnLock() + else : + self._body._position[0] = index[0] + self._body._position[1] = index[1] + self._body._position[2] = index[2] + + def __getitem__(self, index) : + if index == 0 or index == "x" : + return self._body._position[0] + if index == 1 or index == "y" : + return self._body._position[1] + if index == 2 or index == "z" : + return self._body._position[2] + return self._body.position + _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn