Author: ArcRiley Date: 2008-03-22 05:35:19 -0400 (Sat, 22 Mar 2008) New Revision: 1202
Modified: trunk/pysoy/src/atoms/Axis.pxi trunk/pysoy/src/atoms/Face.pxi trunk/pysoy/src/atoms/Vector.pxi trunk/pysoy/src/atoms/Vertex.pxi Log: Ticket #950 : * various cleanups for atoms Modified: trunk/pysoy/src/atoms/Axis.pxi =================================================================== --- trunk/pysoy/src/atoms/Axis.pxi 2008-03-22 09:14:03 UTC (rev 1201) +++ trunk/pysoy/src/atoms/Axis.pxi 2008-03-22 09:35:19 UTC (rev 1202) @@ -1,4 +1,4 @@ -# PySoy's stubs.Stub +# PySoy's atoms.Axis class # # Copyright (C) 2006,2007,2008 PySoy Group # @@ -34,17 +34,31 @@ Body, Bone, Joint. ''' + ############################################################################ + # + # Python functions + # + def __cinit__(self, *args, **keywords) : pass + def __dealloc__(self) : pass + def __repr__(self) : - return '<Axis>' + return '<%s>' % self.__class__.__name__ + + ############################################################################ + # + # Properties + # + property orientation: def __get__(self) : pass + def __set__(self, vector) : pass Modified: trunk/pysoy/src/atoms/Face.pxi =================================================================== --- trunk/pysoy/src/atoms/Face.pxi 2008-03-22 09:14:03 UTC (rev 1201) +++ trunk/pysoy/src/atoms/Face.pxi 2008-03-22 09:35:19 UTC (rev 1202) @@ -22,6 +22,12 @@ An element of FaceList with .verts property ''' + + ############################################################################ + # + # Python functions + # + def __cinit__(self, soy.models.Mesh mesh, verts=None, material=None, index=-1, *args, **keywords) : @@ -85,9 +91,14 @@ def __repr__(self) : - return '<Face>' + return '<%s>' % self.__class__.__name__ + ############################################################################ + # + # Properties + # + property verts : def __get__(self) : cdef float a, b, c @@ -100,6 +111,7 @@ _verts[self._list._array[self._index].c]) py.PyThread_release_lock(self._mutex) return t + def __set__(self, value) : cdef int i if type(value) != tuple and type(value) != list : @@ -135,6 +147,7 @@ return material else : return None + def __set__(self, soy.materials.Material material) : cdef int i, _mindex, _oldindex cdef soy._datatypes.Face _face Modified: trunk/pysoy/src/atoms/Vector.pxi =================================================================== --- trunk/pysoy/src/atoms/Vector.pxi 2008-03-22 09:14:03 UTC (rev 1201) +++ trunk/pysoy/src/atoms/Vector.pxi 2008-03-22 09:35:19 UTC (rev 1202) @@ -1,4 +1,4 @@ -# PySoy's stubs.Stub +# PySoy's atoms.Vector class # # Copyright (C) 2006,2007,2008 PySoy Group # @@ -18,10 +18,16 @@ # $Id$ cdef class Vector : - ''' PySoy Vector + '''soy.atoms.Vector An atom that helps with 3D math ''' + + ############################################################################ + # + # Python functions + # + def __cinit__(self, position=None, *args, **keywords) : if position: self._position[0] = position[0] @@ -48,53 +54,66 @@ return "<Vector at (%f, %f, %f) >" % (self._position[0], self._position[1], self._position[2]) - + + ############################################################################ # - # Math Functions + # Python Math Functions # - def __add__(Vector self, Vector other): + + def __add__(Vector self, Vector other) : return Vector((self._position[0] + other._position[0], self._position[1] + other._position[1], self._position[2] + other._position[2])) - def __mul__(Vector self,other): + + + def __mul__(Vector self,other) : if isinstance(other, Vector) : raise TypeError("Must multiply with an integer, use cross or dot with Vectors") - if isinstance(other, int): + if isinstance(other, int) : return Vector((self._position[0] * other, - self._position[1] * other, - self._position[2] * other)) + self._position[1] * other, + self._position[2] * other)) - def cross(Vector self, Vector other): + + def cross(Vector self, Vector other) : #<x, y, z> X <u, v, w> = <yw - zv, zu - xw, xv - yu> return Vector((self.y * other.z - other.y * self.z, - self.z * other.x - self.x * other.z, - self.x * other.y - self.y * other.x)) - def dot(Vector self, Vector other): + self.z * other.x - self.x * other.z, + self.x * other.y - self.y * other.x)) + + + def dot(Vector self, Vector other) : # <x, y, z> (dot) <u, v, w> = xu + yv + zw return ((self.x * other.x) + (self.y * other.y) + (self.z * other.z)) - - + + ############################################################################ # # Properties # + property x : def __get__(self) : return self._position[0] + def __set__(self, value) : self._position[0] = value + property y : def __get__(self) : return self._position[1] + def __set__(self, value) : self._position[1] = value + property z : def __get__(self) : return self._position[2] + def __set__(self, value) : - self._position[2] = value \ No newline at end of file + self._position[2] = value Modified: trunk/pysoy/src/atoms/Vertex.pxi =================================================================== --- trunk/pysoy/src/atoms/Vertex.pxi 2008-03-22 09:14:03 UTC (rev 1201) +++ trunk/pysoy/src/atoms/Vertex.pxi 2008-03-22 09:35:19 UTC (rev 1202) @@ -22,6 +22,12 @@ An element of VertexList with .position .normal and .texcoord properties ''' + + ############################################################################ + # + # Python functions + # + def __cinit__(self, soy.models.Mesh mesh, position=None, normal=None, texcoord=None, tangent=None, index=-1, *args, **keywords) : @@ -63,11 +69,17 @@ def __repr__(self) : - return '<Vertex at (%f, %f, %f)>' % (self._list._array[self._index].px, - self._list._array[self._index].py, - self._list._array[self._index].pz) + return '<%s at (%f, %f, %f)>' % (self.__class__.__name__, + self._list._array[self._index].px, + self._list._array[self._index].py, + self._list._array[self._index].pz) + ############################################################################ + # + # Properties + # + property position : def __get__(self) : cdef float x, y, z @@ -106,6 +118,7 @@ self._list._array[self._index].nz) py.PyThread_release_lock(self._mutex) return t + def __set__(self, value) : if type(value)!=tuple and type(value)!=list : raise TypeError('Must provide a tuple or list') @@ -129,6 +142,7 @@ self._list._array[self._index].tz) py.PyThread_release_lock(self._mutex) return t + def __set__(self, value) : if type(value)!=tuple and type(value)!=list : raise TypeError('Must provide a tuple or list') @@ -141,8 +155,9 @@ self._list._flagUpdated(self._index) py.PyThread_release_lock(self._mutex) + property tangent: - def __get__(self): + def __get__(self) : cdef object t py.PyThread_acquire_lock(self._mutex, 1) t = (self._list._array[self._index].tan_x, @@ -150,7 +165,8 @@ self._list._array[self._index].tan_z) py.PyThread_release_lock(self._mutex) return t - def __set__(self,value): + + def __set__(self,value) : if type(value)!=tuple and type(value)!=list : raise TypeError('Must provide a tuple or list') if len(value)!=3 : @@ -161,5 +177,4 @@ self._list._array[self._index].tan_y = value[1] self._list._array[self._index].tan_z = value[2] self._list._flagUpdated(self._index) - py.PyThread_release_lock(self._mutex) - + py.PyThread_release_lock(self._mutex) _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn