Commits

resurtm committed 6a97319

New functions for body.

Comments (0)

Files changed (4)

 newpy—Python binding for Newton Game Dynamics physics library
 -------------------------------------------------------------
 
+Note that this project is under heavy development. Main branch may be unstable, API may break
+anytime, etc. Sorry for that. Criticism and advice on any points are welcome.
+
 Main purpose of this project is to create full featured Python version of the popular
 [Newton Game Dynamics](http://newtondynamics.com/ "Official project site") physics simulation
 library.
+
+Project roadmap will be added later.

cython/newton.pxd

     
     void NewtonBodyAddBuoyancyForce(NewtonBodyConstPtr body, float fluidDensity,
             float fluidLinearViscosity, float fluidAngularViscosity, 
-    ConstFloatPtr gravityVector, NewtonGetBuoyancyPlane buoyancyPlane, VoidPtr context)
+            ConstFloatPtr gravityVector, NewtonGetBuoyancyPlane buoyancyPlane, VoidPtr context)
     
     void NewtonBodyAddImpulse(NewtonBodyConstPtr body, ConstFloatPtr pointDeltaVeloc,
             ConstFloatPtr pointPosit)

cython/newton.pyx

 
 cdef class Body:
     cdef newton.NewtonWorldPtr _world
+    cdef Collision _collision
     cdef newton.NewtonBodyPtr _body
     callbacks = {}
     
     def set_angular_damping(self, dx, dy, dz):
         cdef float *_vector = [dx, dy, dz]
         newton.NewtonBodySetAngularDamping(self._body, _vector)
-
+    
+    # NewtonBodyAddForce
+    def add_force(self, forcex, forcey, forcez):
+        cdef float *_vector = [forcex, forcey, forcez]
+        newton.NewtonBodyAddForce(self._body, _vector)
+        
+    # NewtonBodyAddImpulse
+    def add_impulse(self, pointDeltaVelocX, pointDeltaVelocY, pointDeltaVelocZ,
+            pointPositX, pointPositY, pointPositZ):
+        cdef float *_vector0 = [pointDeltaVelocX, pointDeltaVelocY, pointDeltaVelocZ]
+        cdef float *_vector1 = [pointPositX, pointPositY, pointPositZ]
+        newton.NewtonBodyAddImpulse(self._body, _vector0, _vector1)
+    
+    # NewtonBodyAddTorque
+    def add_torque(self, tx, ty, tz):
+        cdef float *_vector = [tx, ty, tz]
+        newton.NewtonBodyAddTorque(self._body, _vector)
+    
+    # NewtonBodyGetAABB
+    def get_aabb(self):
+        cdef float _vector0[3]
+        cdef float _vector1[3]
+        newton.NewtonBodyGetAABB(self._body, _vector0, _vector1)
+        return (_vector0[0], _vector0[1], _vector0[2]), (_vector1[0], _vector1[1], _vector1[2])
+    
+    # NewtonBodyGetAngularDamping
+    def get_angular_damping(self):
+        cdef float _vector[3]
+        newton.NewtonBodyGetAngularDamping(self._body, _vector)
+        return _vector[0], _vector[1], _vector[2]
+    
+    # NewtonBodyGetAutoSleep
+    def get_auto_sleep(self):
+        return newton.NewtonBodyGetAutoSleep(self._body)
+        
+    # NewtonBodyGetCentreOfMass
+    def get_centre_of_mass(self):
+        cdef float _vector[3]
+        newton.NewtonBodyGetCentreOfMass(self._body, _vector)
+        return _vector[0], _vector[1], _vector[2]
+    
+    # NewtonBodyGetCollision
+    def get_collision(self):
+        return self._collision
+        
+    # NewtonBodyGetContinuousCollisionMode
+    def get_continuous_collision_mode(self):
+        return newton.NewtonBodyGetContinuousCollisionMode(self._body)
+    
+    # NewtonBodyGetForce
+    def get_force(self):
+        cdef float _vector[3]
+        newton.NewtonBodyGetForce(self._body, _vector)
+        return _vector[0], _vector[1], _vector[2]
+        
+    # NewtonBodySetOmega
+    def set_omega(self, ox, oy, oz):
+        cdef float *_vector = [ox, oy, oz]
+        newton.NewtonBodySetOmega(self._body, _vector)
+           
+    # NewtonBodySetVelocity
+    def set_velocity(self, vx, vy, vz):
+        cdef float *_vector = [vx, vy, vz]
+        newton.NewtonBodySetVelocity(self._body, _vector)
+        
+    # NewtonBodySetUserData
+    def set_user_data(self, user_data):
+        self.__user_data = user_data
+        
+    # NewtonBodyGetUserData
+    def get_user_data(self):
+        return self.__user_data
+        
 #---------------------------------------------------------------------------------------------------
 # Joint and constraints related functions.
 #---------------------------------------------------------------------------------------------------
         
         body = Body()
         body._world = self._world
+        body._collision = <Collision>collision
         body._body = newton.NewtonCreateBody(self._world, <newton.NewtonCollisionPtr>collision._collision, _matrix)
         newton.NewtonBodySetUserData(body._body, <void *>body)
         return body

function_status.txt

 NewtonBallSetConeLimits
 NewtonBallSetUserCallback
 NewtonBodyAddBuoyancyForce
-NewtonBodyAddForce
-NewtonBodyAddImpulse
-NewtonBodyAddTorque
+NewtonBodyAddForce *DONE*
+NewtonBodyAddImpulse *DONE*
+NewtonBodyAddTorque *DONE*
 NewtonBodyCalculateInverseDynamicsForce
-NewtonBodyGetAABB
-NewtonBodyGetAngularDamping
-NewtonBodyGetAutoSleep
-NewtonBodyGetCentreOfMass
-NewtonBodyGetCollision
-NewtonBodyGetContinuousCollisionMode
+NewtonBodyGetAABB *DONE*
+NewtonBodyGetAngularDamping *DONE*
+NewtonBodyGetAutoSleep *DONE*
+NewtonBodyGetCentreOfMass *DONE*
+NewtonBodyGetCollision *DONE*
+NewtonBodyGetContinuousCollisionMode *DONE*
 NewtonBodyGetFirstContactJoint
 NewtonBodyGetFirstJoint
-NewtonBodyGetForce
+NewtonBodyGetForce *DONE*
 NewtonBodyGetForceAcc
 NewtonBodyGetForceAndTorqueCallback
 NewtonBodyGetFreezeState
 NewtonBodyGetTorque
 NewtonBodyGetTorqueAcc
 NewtonBodyGetTransformCallback
-NewtonBodyGetUserData
+NewtonBodyGetUserData *DONE*
 NewtonBodyGetVelocity
 NewtonBodyGetWorld
 NewtonBodySetAngularDamping *DONE*
 NewtonBodySetMaterialGroupID
 NewtonBodySetMatrix *DONE*
 NewtonBodySetMatrixRecursive *DONE*
-NewtonBodySetOmega
+NewtonBodySetOmega *DONE*
 NewtonBodySetTorque *DONE*
 NewtonBodySetTransformCallback *DONE*
-NewtonBodySetUserData
-NewtonBodySetVelocity
+NewtonBodySetUserData *DONE*
+NewtonBodySetVelocity *DONE*
 NewtonBreakableBeginDelete
 NewtonBreakableCreateDerbieBody
 NewtonBreakableDeleteComponent