Author: AkkaradechSujanil Date: 2008-04-01 23:30:45 -0400 (Tue, 01 Apr 2008) New Revision: 1215
Added: trunk/pysoy/src/masses/Box.pxi trunk/pysoy/src/masses/Capsule.pxi trunk/pysoy/src/masses/Cylinder.pxi Modified: trunk/pysoy/src/masses/Mass.pxi trunk/pysoy/src/masses/soy.masses.pxd trunk/pysoy/src/masses/soy.masses.pyx Log: Added: trunk/pysoy/src/masses/Box.pxi =================================================================== --- trunk/pysoy/src/masses/Box.pxi (rev 0) +++ trunk/pysoy/src/masses/Box.pxi 2008-04-02 03:30:45 UTC (rev 1215) @@ -0,0 +1,28 @@ +# PySoy's soy.shapes.Sphere 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 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see http://www.gnu.org/licenses + +cdef class Box (Mass) : + '''PySoy Sphere + + A spherical shape class. + ''' + + def Create(self,float density = 1, float lx=1 , float ly=1 , float lz=1 ) : + ode.dMassSetBox(&self._mass,density,lx,ly,lz); + ode.dBodySetMass(self._bodyID,&self._mass) + + Added: trunk/pysoy/src/masses/Capsule.pxi =================================================================== --- trunk/pysoy/src/masses/Capsule.pxi (rev 0) +++ trunk/pysoy/src/masses/Capsule.pxi 2008-04-02 03:30:45 UTC (rev 1215) @@ -0,0 +1,28 @@ +# PySoy's soy.shapes.Sphere 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 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see http://www.gnu.org/licenses + +cdef class Capsule (Mass) : + '''PySoy Sphere + + A spherical shape class. + ''' + + def Create(self,float density = 1, int direction=1, float radius=1,float length=1 ) : + ode.dMassSetCapsule(&self._mass,density,direction,radius,length); + ode.dBodySetMass(self._bodyID,&self._mass) + + Added: trunk/pysoy/src/masses/Cylinder.pxi =================================================================== --- trunk/pysoy/src/masses/Cylinder.pxi (rev 0) +++ trunk/pysoy/src/masses/Cylinder.pxi 2008-04-02 03:30:45 UTC (rev 1215) @@ -0,0 +1,28 @@ +# PySoy's soy.shapes.Sphere 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 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see http://www.gnu.org/licenses + +cdef class Cylinder (Mass) : + '''PySoy Sphere + + A spherical shape class. + ''' + + def Create(self,float density = 1, int direction=1, float radius=1,float length=1 ) : + ode.dMassSetCylinder(&self._mass,density,direction,radius,length); + ode.dBodySetMass(self._bodyID,&self._mass) + + Modified: trunk/pysoy/src/masses/Mass.pxi =================================================================== --- trunk/pysoy/src/masses/Mass.pxi 2008-04-02 03:29:58 UTC (rev 1214) +++ trunk/pysoy/src/masses/Mass.pxi 2008-04-02 03:30:45 UTC (rev 1215) @@ -16,3 +16,40 @@ # along with this program; if not, see http://www.gnu.org/licenses # # $Id$ + + +cdef class Mass : + '''PySoy Mass + + This class gives bodies a physical presence for Mass + + ''' + + def __cinit__(self,soy.bodies.Body body, *args, **kw) : + cdef ode.dMass m + self._mass = m + self._body = body + self._bodyID = body._bodyID + #pass + + + property mass : + + def __get__(self) : + return self._mass.mass + + def __set__(self, value) : + if type(value)!=float and type(value)!=int : + raise TypeError('Must provide an integer or float') + if value < 0 : + raise TypeError('No negative masses') + elif self._bodyID : + self._mass.mass = value + if value != 0 : + ode.dBodySetGravityMode(self._bodyID, 1) + else: + ode.dBodySetGravityMode(self._bodyID, 0) + else : + self._mass.mass = value + + \ No newline at end of file Modified: trunk/pysoy/src/masses/soy.masses.pxd =================================================================== --- trunk/pysoy/src/masses/soy.masses.pxd 2008-04-02 03:29:58 UTC (rev 1214) +++ trunk/pysoy/src/masses/soy.masses.pxd 2008-04-02 03:30:45 UTC (rev 1215) @@ -18,3 +18,14 @@ # $Id $ cimport soy._internals +cimport stdio +cimport ode +cimport soy._core +cimport soy._internals +cimport soy.bodies + + +cdef class Mass : + cdef ode.dMass _mass + cdef soy.bodies.Body _body + cdef ode.dBodyID _bodyID Modified: trunk/pysoy/src/masses/soy.masses.pyx =================================================================== --- trunk/pysoy/src/masses/soy.masses.pyx 2008-04-02 03:29:58 UTC (rev 1214) +++ trunk/pysoy/src/masses/soy.masses.pyx 2008-04-02 03:30:45 UTC (rev 1215) @@ -25,4 +25,9 @@ cimport stdlib -include "Stub.pxi" +#include "Stub.pxi" +include "Mass.pxi" +include "Sphere.pxi" +include "Box.pxi" +include "Cylinder.pxi" +include "Capsule.pxi" _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn