Author: DavidCzech Date: 2008-01-25 01:19:34 +0000 (Fri, 25 Jan 2008) New Revision: 797
Modified: trunk/pysoy/src/bodies._bodies/Body.pxi Log: Floor function Modified: trunk/pysoy/src/bodies._bodies/Body.pxi =================================================================== --- trunk/pysoy/src/bodies._bodies/Body.pxi 2008-01-23 22:15:51 UTC (rev 796) +++ trunk/pysoy/src/bodies._bodies/Body.pxi 2008-01-25 01:19:34 UTC (rev 797) @@ -16,7 +16,7 @@ # along with this program; if not, see http://www.gnu.org/licenses # # $Id$ - + cimport soy._datatypes cimport soy.meshes @@ -60,21 +60,29 @@ cdef ode.dVector3 b cdef ode.dReal dist if self._scene != 0 and self._scene == myBody._scene: - #print "Vars setup" - #a=ode.dBodyGetPosition(<ode.dBodyID>self._bodyID) ode.dBodyCopyPosition(<ode.dBodyID> self._bodyID, a) - #print "a got position" ode.dBodyCopyPosition(<ode.dBodyID> myBody._bodyID, b) - #print "b got position" dist =ode.dDISTANCE(a,b) - #print "dist got Distance",dist return dist #elif <void *> self._scene == NULL: # FAILS to catch # raise UnboundLocalError('Body is not in a scene') elif self._scene != myBody._scene: raise RuntimeError('Make sure that both Bodies are in the same Scene') - #def distance(self,other) : - # return _distance(self,other) + + def floor(self,Body floor) : + cdef ode.dGeomID myray + cdef ode.dContactGeom cg[10] + myray = ode.dCreateRay(self._scene._spaceID,1000) + ode.dGeomRaySet(myray,self.position[0],self.position[1],self.position[2],0,-1,0) + countacts =ode.dCollide(<ode.dGeomID> myray,<ode.dGeomID> self._scene._spaceID,10, cg,sizeof(cg[0])) + print "done" + for contact in range(countacts): # countacts contains amount of collisions + print "Trying a contact" + if ode.dGeomGetBody(cg[contact].g2)==floor._bodyID: + print "Floor found" + self.position = (self.position[0], cg[contact].pos[1], self.position[2]) + break + cdef void poke(self, vector) : if self._bodyID : ode.dBodyAddForce(self._bodyID, vector[0], vector[1], vector[2]) _______________________________________________ PySoy-SVN mailing list [email protected] http://www.pysoy.org/mailman/listinfo/pysoy-svn
