newpy — Newton Game Dynamics for Python

Share with us how are you using the powerrrr of the force

Moderator: Alain

newpy — Newton Game Dynamics for Python

Postby resurtm » Tue Jul 21, 2009 11:25 am

Hello all!

I recently started project of making Newton Game Dynamics interface for Python language. There was pynewton project but it's not updated for a long time (since 2006—2007 years). I needed physics (Newton Game Dynamics fits excellent for me) for my new game project entirely written in Python language — this is the main reason of starting this project.

newpy uses ctypes foreign function library with direct shared library function calls using only standard Python libraries. Just like Delphi header does — direct shared library functions calling. I'm currently using Windows_SDK_2.02 and Python 2.6.1 for development.

Project page is here: http://code.google.com/p/newpy/

I will be glad if this project will help somebody in the future — not just for me. I would appreciate your advices, tips and testings.

Sample of using newpy API:

Code: Select all
# init
newton = Newton()
newton.create()

# some info about simulation
print 'Version: %s' % newton.worldGetVersion()
print 'Memory used: %s' % newton.getMemoryUsed()

# create box body
collision = newton.createBox(1., 1., 1.)
body = newton.createBody(collision)
newton.releaseCollision(collision)
newton.bodySetMassMatrix(body, 1., 1., 1., 1.)
newton.bodySetMatrix(body, [ 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1., 0., 0., 20., 0, 1. ])

# create static body
collision2 = newton.createBox(1000., 1., 1000.)
body2 = newton.createBody(collision2)
newton.releaseCollision(collision2)
newton.bodySetMassMatrix(body2, 0., 0., 0., 0.)

# test omega
newton.bodySetOmega(body, 1.0, 0.5, 0.25)

def bodyForceAndTorqueCallback(body, timestep, threadIndex):
   newton.bodySetForce(body, 0., -9.8, 0.)
   newton.bodySetTorque(body, 0.1, 0.2, 0.3)

newton.bodySetForceAndTorqueCallback(body, bodyForceAndTorqueCallback)

# some physics advance
for counter in xrange(100):
   newton.update(0.1)
   
for item in newton.bodyGetMatrix(body):
   print item

# deinit
newton.destroyAllBodies()
newton.destroy()


Library is under heavy development at the moment, but there are several screenshots. Samples uses Pygame, PyOpenGL and newpy libraries. Here they are:

Image

Image
newpy — Newton Game Dynamics for Python
resurtm
 
Posts: 4
Joined: Tue Jul 21, 2009 11:09 am

Re: newpy — Newton Game Dynamics for Python

Postby JernejL » Tue Jul 21, 2009 12:43 pm

Good work, i'm sure this might help many people (i can only dream of running python + newton app on nokia series60).

I also stickied the topic so it doesn't get lost, but it might be better to move this to general discussion? as the pascal header topics are also there already.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1374
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: newpy — Newton Game Dynamics for Python

Postby resurtm » Tue Jul 21, 2009 1:02 pm

Delfi wrote:Good work, i'm sure this might help many people (i can only dream of running python + newton app on nokia series60).

I also stickied the topic so it doesn't get lost, but it might be better to move this to general discussion? as the pascal header topics are also there already.


I'm not sure if ctypes library is available on Nokia Series 60 smartphones (and i don't know how shared libraries organized in Symbian OS). Can you verify it (just import ctypes then dir(ctypes))? Or can you explain how can i install latest Python on my Nokia 6630 if it is possible. =)

Sure, you can move it into general discussion section. =) Thanks for your support and response, but there are a lot of things to do in binding. %)
newpy — Newton Game Dynamics for Python
resurtm
 
Posts: 4
Joined: Tue Jul 21, 2009 11:09 am

Re: newpy — Newton Game Dynamics for Python

Postby Julio Jerez » Tue Jul 21, 2009 1:16 pm

Ha this is very cool, maybe this can be used for Blender exporter.

since you are a new Newton user I recomend you take a look at the new tutorials for 2.0
http://newtondynamics.com/wiki/index.ph ... =Tutorials
Julio Jerez
Moderator
Moderator
 
Posts: 10485
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: newpy — Newton Game Dynamics for Python

Postby resurtm » Tue Jul 21, 2009 1:22 pm

Julio Jerez wrote:Ha this is very cool, maybe this can be used for Blender exporter.

since you are a new Newton user I recomend you take a look at the new tutorials for 2.0
http://newtondynamics.com/wiki/index.ph ... =Tutorials


Thanks, Julio! Blender integration in future would be cool! But not in near future. =\

Btw, i'm not new Newton user. I used Newton approx. at 1.3 version with C. :) And i have already downloaded Newton 2.0 tutorial pack for porting into Python.
newpy — Newton Game Dynamics for Python
resurtm
 
Posts: 4
Joined: Tue Jul 21, 2009 11:09 am

Re: newpy — Newton Game Dynamics for Python

Postby Julio Jerez » Tue Jul 21, 2009 1:40 pm

resurtm wrote:Thanks, Julio! Blender integration in future would be cool! But not in near future. =\
Btw, i'm not new Newton user. I used Newton approx. at 1.3 version with C. :) And i have already downloaded Newton 2.0 tutorial pack for porting into Python.

oh you have experiece very cool.

on the blender thiong, I did not mean you now, I mean that with a Phyton Wraper I think it is possible export blender objects with Newton physics.
Blender do not support DLL interface, so it is prohivitive for close source library to integrate with blender, but I think that with physic wraper it is possible to write blende plug ins..
I am no sure about hwo must is exposed to Phyton but I here it is possible.

That is something I might take a look in the future, with a Phyton wraper. :mrgreen:
Julio Jerez
Moderator
Moderator
 
Posts: 10485
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: newpy — Newton Game Dynamics for Python

Postby resurtm » Tue Jul 21, 2009 2:03 pm

Julio Jerez wrote:
resurtm wrote:Thanks, Julio! Blender integration in future would be cool! But not in near future. =\
Btw, i'm not new Newton user. I used Newton approx. at 1.3 version with C. :) And i have already downloaded Newton 2.0 tutorial pack for porting into Python.

oh you have experiece very cool.

on the blender thiong, I did not mean you now, I mean that with a Phyton Wraper I think it is possible export blender objects with Newton physics.
Blender do not support DLL interface, so it is prohivitive for close source library to integrate with blender, but I think that with physic wraper it is possible to write blende plug ins..
I am no sure about hwo must is exposed to Phyton but I here it is possible.

That is something I might take a look in the future, with a Phyton wraper. :mrgreen:


Ok. I understand you now. =) We see what we can do with Blender + NGD in future, when binding itself will be completed. :)

PS: GNU/Linux (Debian Lenny, x86) screenshot:

Image
newpy — Newton Game Dynamics for Python
resurtm
 
Posts: 4
Joined: Tue Jul 21, 2009 11:09 am

Re: newpy — Newton Game Dynamics for Python

Postby JernejL » Tue Jul 21, 2009 3:00 pm

I added the python bindings to the "links page", i should probably go and split that page into several and separate it (games, bindings, projects..) that page is growing very fast.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1374
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: newpy — Newton Game Dynamics for Python

Postby pwagner » Wed Apr 06, 2011 3:56 am

Hey there,

I'm searching for a physics library that fit my needs. Newton is fairly interesting and as I am a Python developer I'm interested in python bindings as well. So I hope someone can give me an update about the project (I have seen it moved from Google Project Hosting to bitbucket)?
Does anybody know which method is used for wrapping the newton library to Python (read something about ctypes and Cython)?

Thanks in advance.
pwagner
 
Posts: 13
Joined: Wed Apr 06, 2011 3:14 am

Re: newpy — Newton Game Dynamics for Python

Postby JernejL » Wed Apr 06, 2011 9:42 am

It is best if you contact resurtm directly, he is developing the wrapper.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1374
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: newpy — Newton Game Dynamics for Python

Postby pwagner » Wed Apr 06, 2011 2:06 pm

Ok thanks. What about you? Are you the developer of newton?

[Edit]Found out myself you are not one of them ^^[/Edit]
pwagner
 
Posts: 13
Joined: Wed Apr 06, 2011 3:14 am

Re: newpy — Newton Game Dynamics for Python

Postby perkins » Wed Jan 15, 2014 2:39 pm

For anyone interested, I'm working on writing a new version of this against 3.10. I'm using pypy with cffi, but it will probably work with cffi in CPython too. I'll post a link to the source as soon as I have a working demo.
perkins
 
Posts: 22
Joined: Sat Dec 24, 2011 9:41 pm

Re: newpy — Newton Game Dynamics for Python

Postby Julio Jerez » Wed Jan 15, 2014 2:50 pm

use the lates SVN instead. I cna no longe upliad stable download to Google code.

The latest is 2.12 and it is very stable.
Julio Jerez
Moderator
Moderator
 
Posts: 10485
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: newpy — Newton Game Dynamics for Python

Postby perkins » Wed Jan 15, 2014 4:55 pm

The latest svn fails to build on linux (64 bit). unsigned64 is undefined, I assume that is probably unsigned long, but even with that change, it fails because it cannot create ../../source/physics/dgCollisionCompoundBreakable.o
Also, in neither the latest svn nor the packaged version does cmake work,
CMake Error at CMakeLists.txt:13 (add_subdirectory):
add_subdirectory given source "/core" which is not an existing directory.
and similar errors.

dgCollisionCompoundBreakable.* seem to have been removed from /physics/, but not from the make file...
perkins
 
Posts: 22
Joined: Sat Dec 24, 2011 9:41 pm

Re: newpy — Newton Game Dynamics for Python

Postby Julio Jerez » Wed Jan 15, 2014 6:03 pm

Oh you are in Linux, it is a long time since I build it,
Yes there are some new files, I need to add to the make file. I only tested the Cmake in windows.

I see if I can fix it tonight for Mac and Linux.
Julio Jerez
Moderator
Moderator
 
Posts: 10485
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to User Gallery

Who is online

Users browsing this forum: No registered users and 1 guest

cron