Author: DavyWybiral Date: 2007-12-30 22:44:01 +0000 (Sun, 30 Dec 2007) New Revision: 640
Added: trunk/pysoy/src/shapes/Capsule.pxi Removed: trunk/pysoy/src/shapes/CCylinder.pxi Modified: trunk/pysoy/src/shapes/soy.shapes.pyx Log: Changed shape class CCylinder to Capsule (which changed in ode 0.6) Deleted: trunk/pysoy/src/shapes/CCylinder.pxi =================================================================== --- trunk/pysoy/src/shapes/CCylinder.pxi 2007-12-30 22:03:57 UTC (rev 639) +++ trunk/pysoy/src/shapes/CCylinder.pxi 2007-12-30 22:44:01 UTC (rev 640) @@ -1,74 +0,0 @@ -# PySoy's soy.shapes.CCylinder class -# -# Copyright (C) 2007 Team PySoy -# -# 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 -# -# $Id$ - -cdef class CCylinder (Shape) : - '''PySoy CCylinder - - An encapsulated ODE Geom - ''' - - def __cinit__(self, float radius, float length) : - self._geomID = ode.dCreateCCylinder(NULL, radius, length) - ode.dGeomSetData(self._geomID, <void*> self) - - cdef float pointDepth(self, float x, float y, float z) : - return <float> ode.dGeomCCylinderPointDepth(self._geomID, x, y, z) - - cdef float _volume(self) : - cdef ode.dReal r, l - ode.dGeomCCylinderGetParams(self._geomID, &r, &l) - return (l * powf(r, 2) * 3.1415926535 + 4 / 3 * powf(r, 3) * 3.1415926535) - - cdef float _radius(self) : - cdef ode.dReal r, l - ode.dGeomCCylinderGetParams(self._geomID, &r, &l) - return <float> (l / 2 + r) - - cdef int _finite(self) : - return 1 - - property radius : - '''CCylinder's radius - - This is the distance between the center and the surface - ''' - def __get__(self) : - cdef ode.dReal r, l - ode.dGeomCCylinderGetParams(self._geomID, &r, &l) - return r - def __set__(self, value) : - cdef ode.dReal r, l - ode.dGeomCCylinderGetParams(self._geomID, &r, &l) - r = value - ode.dGeomCCylinderSetParams(self._geomID, r, l) - - property length : - '''CCylinder's length - - This is the length, not counting the caps - ''' - def __get__(self) : - cdef ode.dReal r, l - ode.dGeomCCylinderGetParams(self._geomID, &r, &l) - return l - def __set__(self, value) : - cdef ode.dReal r, l - ode.dGeomCCylinderGetParams(self._geomID, &r, &l) - l = value - ode.dGeomCCylinderSetParams(self._geomID, r, l) Added: trunk/pysoy/src/shapes/Capsule.pxi =================================================================== --- trunk/pysoy/src/shapes/Capsule.pxi (rev 0) +++ trunk/pysoy/src/shapes/Capsule.pxi 2007-12-30 22:44:01 UTC (rev 640) @@ -0,0 +1,74 @@ +# PySoy's soy.shapes.Capsule class +# +# Copyright (C) 2007 Team PySoy +# +# 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 +# +# $Id: Capsule.pxi 540 2007-08-18 19:46:36Z EricStein $ + +cdef class Capsule (Shape) : + '''PySoy Capsule + + An encapsulated ODE Geom + ''' + + def __new__(self, float radius, float length) : + self._geomID = ode.dCreateCapsule(NULL, radius, length) + ode.dGeomSetData(self._geomID, <void*> self) + + cdef float pointDepth(self, float x, float y, float z) : + return <float> ode.dGeomCapsulePointDepth(self._geomID, x, y, z) + + cdef float _volume(self) : + cdef ode.dReal r, l + ode.dGeomCapsuleGetParams(self._geomID, &r, &l) + return (l * powf(r, 2) * 3.1415926535 + 4 / 3 * powf(r, 3) * 3.1415926535) + + cdef float _radius(self) : + cdef ode.dReal r, l + ode.dGeomCapsuleGetParams(self._geomID, &r, &l) + return <float> (l / 2 + r) + + cdef int _finite(self) : + return 1 + + property radius : + '''Capsule's radius + + This is the distance between the center and the surface + ''' + def __get__(self) : + cdef ode.dReal r, l + ode.dGeomCapsuleGetParams(self._geomID, &r, &l) + return r + def __set__(self, value) : + cdef ode.dReal r, l + ode.dGeomCapsuleGetParams(self._geomID, &r, &l) + r = value + ode.dGeomCapsuleSetParams(self._geomID, r, l) + + property length : + '''Capsule's length + + This is the length, not counting the caps + ''' + def __get__(self) : + cdef ode.dReal r, l + ode.dGeomCapsuleGetParams(self._geomID, &r, &l) + return l + def __set__(self, value) : + cdef ode.dReal r, l + ode.dGeomCapsuleGetParams(self._geomID, &r, &l) + l = value + ode.dGeomCapsuleSetParams(self._geomID, r, l) Modified: trunk/pysoy/src/shapes/soy.shapes.pyx =================================================================== --- trunk/pysoy/src/shapes/soy.shapes.pyx 2007-12-30 22:03:57 UTC (rev 639) +++ trunk/pysoy/src/shapes/soy.shapes.pyx 2007-12-30 22:44:01 UTC (rev 640) @@ -27,5 +27,5 @@ include "Shape.pxi" include "Sphere.pxi" include "Box.pxi" -include "CCylinder.pxi" +include "Capsule.pxi" include "Ray.pxi" _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn