Author: ArcRiley Date: 2007-07-08 15:57:24 -0400 (Sun, 08 Jul 2007) New Revision: 425
Added: trunk/pysoy/src/meshes/soy.meshes.pxd trunk/pysoy/src/meshes/soy.meshes.pyx Removed: trunk/pysoy/src/meshes/Body.pxi trunk/pysoy/src/meshes/Bone.pxi trunk/pysoy/src/meshes/Camera.pxi trunk/pysoy/src/meshes/soy.bodies._bodies.pxd trunk/pysoy/src/meshes/soy.bodies._bodies.pyx Log: more moving for ticket #277 Deleted: trunk/pysoy/src/meshes/Body.pxi =================================================================== --- trunk/pysoy/src/meshes/Body.pxi 2007-07-08 19:51:39 UTC (rev 424) +++ trunk/pysoy/src/meshes/Body.pxi 2007-07-08 19:57:24 UTC (rev 425) @@ -1,228 +0,0 @@ -# PySoy Body Class -# -# Copyright (C) 2006,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 Body : - '''PySoy Body - - Bodies are generic objects in 3d space with a position, velocity, - mass, and which joints and shapes may be provided to limit movement. - ''' - - def __new__(self, object scene=None, *args, **keywords) : - self._quaternion[0] = 1.0 - if scene == None : - self._bodyID = NULL - else : - self.scene = scene - - def __dealloc__(self) : - del(self.scene) - - cdef void poke(self, vector) : - if self._bodyID : - ode.dBodyAddForce(self._bodyID, vector[0], vector[1], vector[2]) - else : - raise UnboundLocalError('Body is not in a scene') - - property scene : - '''Body's Scene - - This is the Scene that the body is in. When changed the body's position, - orientation, velocity, and rotation are all reset to (0,0,0). - ''' - def __get__(self) : - if self._isActive() : - return self._scene - else : - return None - def __set__(self, newscene) : - if not (isinstance(newscene, soy._core.Scene) or newscene==None) : - raise TypeError('not an instance of soy.Scene') - if self._isActive() : - self._scene._bodies.lock() - self._scene._bodies.remove(<void *>self) - self._destroy() - self._scene._bodies.unlock() - if self._shape : - if self._scene : - ode.dSpaceRemove(self._scene._spaceID, self._shape._geomID) - ode.dSpaceAdd((<soy._core.Scene> newscene)._spaceID, self._shape._geomID) - if newscene != None : - self._scene = newscene - self._scene._bodies.lock() - self._create() - self._scene._bodies.append(<void *>self) - self._scene._bodies.unlock() - - def __del__(self) : - if self._isActive() : - self._scene._bodies.lock() - self._scene._bodies.remove(<void *>self) - self._destroy() - self._scene._bodies.unlock() - - property mass : - '''Body's mass - - This is the mass of the body in the scene. Effects physics. - - TODO thread safety on set - ''' - - def __get__(self) : - if self._bodyID : - ode.dBodyGetMass(self._bodyID, &self._mass) - return self._mass.mass - else : - return self._mass.mass - def __set__(self, value) : - if type(value)!=float and type(value)!=int : - raise TypeError('Must provide an interger or float') - if value < 0 : - raise TypeError('No negative masses') - else : - ode.dBodyGetMass(self._bodyID, &self._mass) - self._mass.mass = value - ode.dBodySetMass(self._bodyID, &self._mass) - - - property position : - '''Body's Position - - This is the (x,y,z) of where your body is in the scene. - Defaults to (0.0, 0.0, 0.0). - ''' - def __get__(self) : - cdef ode.dVector3 xyz - if self._bodyID : - ode.dBodyCopyPosition(self._bodyID, xyz) - return (xyz[0], xyz[1], xyz[2]) - else : - return (self._position[0], self._position[1], self._position[2]) - def __set__(self, value) : - if type(value)!=tuple and type(value)!=list : - raise TypeError('Must provide a tuple or list') - if len(value)!=3 : - raise TypeError('Must provide (x,y,z)') - if self._bodyID : - ode.dBodySetPosition(self._bodyID, value[0], value[1], value[2]) - else : - self._position[0] = value[0] - self._position[1] = value[1] - self._position[2] = value[2] - - property rotation : - '''Body's Rotational Velocity - - This is how fast your body is rotating on it's own axis. - Defaults to (0.0, 0.0, 0.0). - ''' - def __get__(self) : - cdef ode.dReal *real - if self._bodyID : - real = <ode.dReal *> ode.dBodyGetAngularVel(self._bodyID) - return (real[0], real[1], real[2]) - else : - return (self._angularVel[0], self._angularVel[1], self._angularVel[2]) - def __set__(self, value) : - if type(value)!=tuple and type(value)!=list : - raise TypeError('Must provide a tuple or list') - if len(value)!=3 : - raise TypeError('Must provide (x,y,z)') - if self._bodyID : - ode.dBodySetAngularVel(self._bodyID, value[0], value[1], value[2]) - else : - self._angularVel[0] = value[0] - self._angularVel[1] = value[1] - self._angularVel[2] = value[2] - - property velocity : - '''Body's Linear Velocity - - This is how fast and in which direction a body is moving in a scene. - Defaults to (0.0, 0.0, 0.0). - ''' - def __get__(self) : - cdef ode.dReal *real - if self._bodyID : - real = <ode.dReal *> ode.dBodyGetLinearVel(self._bodyID) - return (real[0], real[1], real[2]) - else : - return (self._linearVel[0], self._linearVel[1], self._linearVel[2]) - def __set__(self, value) : - if type(value)!=tuple and type(value)!=list : - raise TypeError('Must provide a tuple or list') - if len(value)!=3 : - raise TypeError('Must provide (x,y,z)') - if self._bodyID : - ode.dBodySetLinearVel(self._bodyID, value[0], value[1], value[2]) - else : - self._linearVel[0] = value[0] - self._linearVel[1] = value[1] - self._linearVel[2] = value[2] - - cdef void _create(self) : - self._bodyID = ode.dBodyCreate(self._scene._worldID) - ode.dBodySetData(self._bodyID, <void *>self) - ode.dBodySetPosition(self._bodyID, self._position[0], - self._position[1], self._position[2]) - ode.dBodySetQuaternion(self._bodyID, self._quaternion) - ode.dBodySetLinearVel(self._bodyID, self._linearVel[0], - self._linearVel[1], self._linearVel[2]) - ode.dBodySetAngularVel(self._bodyID, self._angularVel[0], - self._angularVel[1], self._angularVel[2]) - - cdef void _destroy(self) : - cdef ode.dReal *real - ode.dBodyCopyPosition(self._bodyID, self._position) - ode.dBodyCopyQuaternion(self._bodyID, self._quaternion) - real = <ode.dReal *>ode.dBodyGetLinearVel(self._bodyID) - self._linearVel[0] = real[0] - self._linearVel[1] = real[1] - self._linearVel[2] = real[2] - real = <ode.dReal *>ode.dBodyGetAngularVel(self._bodyID) - self._angularVel[0] = real[0] - self._angularVel[1] = real[1] - self._angularVel[2] = real[2] - - ode.dBodyDestroy(self._bodyID) - self._bodyID = NULL - - property shape : - '''Body's shape, if it has one. - - The shape used for collisions. - ''' - def __get__(self) : - return self._shape - - def __set__(self, object value) : - if not isinstance(value, soy.shapes.Shape) : - raise TypeError('Requires a Shape') - # This call will make any needed changes to this object as well - (<soy.shapes.Shape> value).body = self - - cdef int _isActive(self) : - if self._bodyID == NULL : - return 0 - else : - return 1 - - cdef void _render(self) : - return Deleted: trunk/pysoy/src/meshes/Bone.pxi =================================================================== --- trunk/pysoy/src/meshes/Bone.pxi 2007-07-08 19:51:39 UTC (rev 424) +++ trunk/pysoy/src/meshes/Bone.pxi 2007-07-08 19:57:24 UTC (rev 425) @@ -1,39 +0,0 @@ -# PySoy bodies.Bones Class -# -# Copyright (C) 2006,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 Bone(Body) : - '''PySoy Bones - - This is an element of soy.bodies.Mesh.armature - ''' - # def _new_(self, object scene=None, *args, **keywords) : - # self._mesh = #the mesh it's part of - # self._scene = self._mesh._scene # just so the ODE stuff still works - - - # cdef int _nvert(self) : # the number of verticies it effects - - # cdef int* _verts(self) : # index numbers of verticies it effects - - # cdef float* _weights(self) : # the amount, 0.0-1.0, it affects each vertex - - - - Deleted: trunk/pysoy/src/meshes/Camera.pxi =================================================================== --- trunk/pysoy/src/meshes/Camera.pxi 2007-07-08 19:51:39 UTC (rev 424) +++ trunk/pysoy/src/meshes/Camera.pxi 2007-07-08 19:57:24 UTC (rev 425) @@ -1,64 +0,0 @@ -# PySoy Camera Class -# -# Copyright (C) 2006,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 Camera(Body) : - '''PySoy Camera - - A camera is an invisible object in 3d space through which the scene can - be rendered through. It must be attached to a soy.widgets.Projector or - other rendering class to be activated. - ''' - def __new__(self, soy._core.Scene parent, *args, **keywords) : - self._fovy = 45.0 - - cdef void _project(self) : - cdef ode.dReal *pos - cdef ode.dReal *rot - cdef gl.GLfloat mtx[16] - pos = <ode.dReal *> ode.dBodyGetPosition(self._bodyID) - rot = <ode.dReal *> ode.dBodyGetRotation(self._bodyID) - mtx[0] = rot[0] - mtx[1] = rot[1] - mtx[2] = rot[2] - mtx[3] = 0.0 - mtx[4] = rot[4] - mtx[5] = rot[5] - mtx[6] = rot[6] - mtx[7] = 0.0 - mtx[8] = rot[8] - mtx[9] = rot[9] - mtx[10] = rot[10] - mtx[11] = 0.0 - mtx[12] = 0.0 - mtx[13] = 0.0 - mtx[14] = 0.0 - mtx[15] = 1.0 - gl.glLoadMatrixf(mtx) - gl.glTranslatef(-pos[0], -pos[1], -pos[2]) - self._scene._render() - - property lens : - '''Camera Lens - - This is the (vertical) angle which the lens can view. Defaults to 45.0 - ''' - def __get__(self) : - return self._fovy - def __set__(self, value) : - self._fovy = value Deleted: trunk/pysoy/src/meshes/soy.bodies._bodies.pxd =================================================================== --- trunk/pysoy/src/meshes/soy.bodies._bodies.pxd 2007-07-08 19:51:39 UTC (rev 424) +++ trunk/pysoy/src/meshes/soy.bodies._bodies.pxd 2007-07-08 19:57:24 UTC (rev 425) @@ -1,91 +0,0 @@ -# PySoy bodies declarations -# -# Copyright (C) 2006,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$ - -cimport gl -cimport ode -cimport py -cimport stdio -cimport soy._core -cimport soy._datatypes -cimport soy._internals -cimport soy.materials -cimport soy.textures -cimport soy.shapes - -cdef struct Face : - unsigned short a - unsigned short b - unsigned short c - - -cdef struct Range : - int offset - int length - - -cdef struct MatRange : - void *mat - int offset - int length - - -cdef class Body : - cdef ode.dBodyID _bodyID - cdef soy._core.Scene _scene - cdef soy.shapes.Shape _shape - # for loading/saving - cdef ode.dMass _mass - cdef ode.dVector3 _position - cdef ode.dQuaternion _quaternion - cdef ode.dReal _linearVel[3] - cdef ode.dReal _angularVel[3] - # C functions - cdef void _create(self) - cdef void _destroy(self) - cdef int _isActive(self) - cdef void _render(self) - cdef void poke(self, vector) - - -cdef class Camera (Body) : - cdef float _fovy - cdef void _project(self) - - -cdef class Mesh (Body) : - cdef soy._datatypes.FaceList _faces - cdef soy._datatypes.VertexList _verts - # - # Texture Data - cdef unsigned int _nmate # number of - cdef int _mmate # malloced - cdef MatRange *_mates # material ranges - - # - # Mesh Functions - cdef void _renderVA (self) - cdef void _renderVBO (self) - cdef void _createVBO (self) - cdef void *_alloc (self, int, int*, void*, int) - cdef void _allocMates (self, int) - -cdef class Pyramid (Mesh) : - cdef soy.materials.Material mat0 - cdef soy.materials.Material mat1 - cdef soy.materials.Material mat2 Deleted: trunk/pysoy/src/meshes/soy.bodies._bodies.pyx =================================================================== --- trunk/pysoy/src/meshes/soy.bodies._bodies.pyx 2007-07-08 19:51:39 UTC (rev 424) +++ trunk/pysoy/src/meshes/soy.bodies._bodies.pyx 2007-07-08 19:57:24 UTC (rev 425) @@ -1,29 +0,0 @@ -'''Body Classes - -This is a collection of classes that exist in 3d space. - -''' -__credits__ = '''Copyright (C) 2006,2007 PySoy Developers - - 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 -''' -__author__ = '''Maintained by ArcRiley''' -__date__ = 'Last change on '+ \ - '$Date$'[7:-20]+ \ - 'by '+'$Author$'[9:-2] -__version__ = 'Trunk (r'+'$Rev$'[6:-2]+')' - -include "Body.pxi" -include "Camera.pxi" -include "Mesh.pxi" Copied: trunk/pysoy/src/meshes/soy.meshes.pxd (from rev 424, trunk/pysoy/src/meshes/soy.bodies._bodies.pxd) =================================================================== --- trunk/pysoy/src/meshes/soy.meshes.pxd (rev 0) +++ trunk/pysoy/src/meshes/soy.meshes.pxd 2007-07-08 19:57:24 UTC (rev 425) @@ -0,0 +1,56 @@ +# PySoy bodies declarations +# +# Copyright (C) 2006,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$ + +cimport gl +cimport py +cimport stdio +cimport soy._datatypes +cimport soy._internals +cimport soy.materials +cimport soy.textures + + +cdef struct MatRange : + void *mat + int offset + int length + + +cdef class Mesh (Body) : + cdef soy._datatypes.FaceList _faces + cdef soy._datatypes.VertexList _verts + # + # Texture Data + cdef unsigned int _nmate # number of + cdef int _mmate # malloced + cdef MatRange *_mates # material ranges + # + # Mesh Functions + cdef void _render (self) + cdef void _renderVA (self) + cdef void _renderVBO (self) + cdef void _createVBO (self) + cdef void *_alloc (self, int, int*, void*, int) + cdef void _allocMates (self, int) + + +cdef class Pyramid (Mesh) : + cdef soy.materials.Material mat0 + cdef soy.materials.Material mat1 + cdef soy.materials.Material mat2 Copied: trunk/pysoy/src/meshes/soy.meshes.pyx (from rev 424, trunk/pysoy/src/meshes/soy.bodies._bodies.pyx) =================================================================== --- trunk/pysoy/src/meshes/soy.meshes.pyx (rev 0) +++ trunk/pysoy/src/meshes/soy.meshes.pyx 2007-07-08 19:57:24 UTC (rev 425) @@ -0,0 +1,26 @@ +'''PySoy's meshes + + These are our "renderable" classes +''' +__credits__ = '''Copyright (C) 2006,2007 PySoy Developers + + 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 +''' +__author__ = '''Maintained by ArcRiley''' +__date__ = 'Last change on '+ \ + '$Date$'[7:-20]+ \ + 'by '+'$Author$'[9:-2] +__version__ = 'Trunk (r'+'$Rev$'[6:-2]+')' + +include "Mesh.pxi" _______________________________________________ PySoy-SVN mailing list [email protected] http://www.pysoy.org/mailman/listinfo/pysoy-svn
