Full python physics engine

1,397 views
Skip to first unread message

Arnaud Waels

unread,
Dec 23, 2011, 9:35:56 AM12/23/11
to kivy-...@googlegroups.com
Hi all

Looking for a full python physics engine in order to run it under android as well, i ended up trying pypybox2d : the full python port of pybox2d
http://pybox2d.blogspot.com/

Source is available here
http://code.google.com/p/pybox2d/source/browse/#svn%2Fbranches%2Fpure_python

On my laptop it's running very well, still slow in case of vertical stacks, but very fast in case of simple top view blocks collision
Top view physics (instead of side view) is achievable by setting gravity to 0 and using a friction joint (see apply force example here http://pybox2d.googlecode.com/svn/trunk/examples/test_ApplyForce.py)

Has anyone ever tried to run it under android, or maybe another engine to suggest ?

A

Mathieu Virbel

unread,
Dec 23, 2011, 11:29:25 AM12/23/11
to kivy-...@googlegroups.com, Nicolas Niemczycki
Hi Arnaud,

Good news so far !
I know that Nicolas (attached here) are trying to compile pymunk for android. Maybe both of you can work together on that point ?

:)

Mathieu

Arnaud Waels

unread,
Dec 23, 2011, 11:43:32 AM12/23/11
to kivy-...@googlegroups.com, Nicolas Niemczycki
ok thanks for the info
i'm currently writing a test app running box2d inside of a kivy app. I'll let you know what the outcome is.

A

2011/12/23 Mathieu Virbel <m...@kivy.org>

Mathieu Virbel

unread,
Dec 23, 2011, 11:51:18 AM12/23/11
to kivy-...@googlegroups.com
For any compiled module, take pgs4a-kivy project from launchpad (bzr clone), copy/paste an existing build_<module>.sh (like build_PIL.sh), and use it as a template for pybox2d (or underlaying module like box2d).

(2 steps: generate an arm binary, and install it in python-install).

Then generate a ./distribute.sh package, and you'll have pybox2d in it.

(build_lxml contain 2 C lib + 1 python module.)


Mathieu

Nicolas Niemczycki

unread,
Dec 24, 2011, 12:03:17 PM12/24/11
to Kivy users support
Hi,
I follow this instruction.
I tested to do a package with kivy, android and pymunk.
I have just a problem with ctypes.
When I launch :
try ../python-install/bin/python.host setup.py build_chipmunk

File "setup.py", line 4, in <module>
import ctypes
File "~/kivy/python-install/lib/python2.7/ctypes/__init__.py", line
10, in <module>
from _ctypes import Union, Structure, Array
ImportError: No module named _ctypes

Nicolas.


On Dec 23, 5:51 pm, Mathieu Virbel <m...@kivy.org> wrote:
> For any compiled module, take pgs4a-kivy project from launchpad (bzr clone), copy/paste an existing build_<module>.sh (like build_PIL.sh), and use it as a template for pybox2d (or underlaying module like box2d).
>
> (2 steps: generate an arm binary, and install it in python-install).
>
> Then generate a ./distribute.sh package, and you'll have pybox2d in it.
>
> (build_lxml contain 2 C lib + 1 python module.)
>
> Mathieu
>
> Le 23 déc. 2011 à 17:43, Arnaud Waels a écrit :
>
>
>
>
>
>
>
> > ok thanks for the info
> > i'm currently writing a test app running box2d inside of a kivy app. I'll let you know what the outcome is.
>
> > A
>
> > 2011/12/23 Mathieu Virbel <m...@kivy.org>
> > Hi Arnaud,
>
> > Good news so far !
> > I know that Nicolas (attached here) are trying to compile pymunk for android. Maybe both of you can work together on that point ?
>
> > :)
>
> > Mathieu
>
> > Le 23 déc. 2011 à 15:35, Arnaud Waels a écrit :
>
> >> Hi all
>
> >> Looking for a full python physics engine in order to run it under android as well, i ended up trying pypybox2d : the full python port of pybox2d
> >>http://pybox2d.blogspot.com/
>
> >> Source is available here
> >>http://code.google.com/p/pybox2d/source/browse/#svn%2Fbranches%2Fpure...
>
> >> On my laptop it's running very well, still slow in case of vertical stacks, but very fast in case of simple top view blocks collision
> >> Top view physics (instead of side view) is achievable by setting gravity to 0 and using a friction joint (see apply force example herehttp://pybox2d.googlecode.com/svn/trunk/examples/test_ApplyForce.py)

Mathieu Virbel

unread,
Dec 24, 2011, 12:30:37 PM12/24/11
to kivy-...@googlegroups.com
I doubt that ctypes is working. Porting task include all that kind of debugging, try to look why and how you can resolve it.

Arnaud Waels

unread,
Dec 26, 2011, 11:49:25 AM12/26/11
to kivy-...@googlegroups.com
Hi

Integration of pypybox2d inside a kivy app works, but slowly..
I tried to improve it using a C extension, but it doesn 't help

So far, i'm scheduling the physics engine stepping ( world.step() function ) using Clock.schedule_interval(function, 0)
I would like to increase that refreshing frequency
Calling this function every canvas.draw() could help ?

A

2011/12/24 Mathieu Virbel <m...@kivy.org>

Mathieu Virbel

unread,
Dec 26, 2011, 12:01:22 PM12/26/11
to kivy-...@googlegroups.com
Using schedule_interval with 0 is already calling the callback each frame, so it will not help.
I'll try to check about chipmunk or box2d compilation if that can help

Mathieu Virbel

unread,
Dec 26, 2011, 8:46:34 PM12/26/11
to kivy-...@googlegroups.com
Ok, nicolas told me that he was trying to understand why ctypes doesn't work.
Just a tip, ctypes python is using libc on your desktop computer, but
on android, libc doesn't exist. It's bionic. And so, some internals
structures doesn't match libc.

For pymunk, removing ctypes would mean that somebody must do the
wrapper using swig or cython. It's a long work, and unless you're
familiar with one of both way, forget about it.
I've found https://bitbucket.org/timostolz/gamephysics/, a cython
wrapper for box2d. But the compilation was a mess.

So after checking more about pybox2d, and why it would not compile, we have now:

1. a new pybox2d-android project, with all the changes needed to pass
the compilation (changes from cstdlib->stdlib.h, and some other
includes changes.) => http://github.com/tito/pybox2d-android
2. a new build_pybox2d.sh script, that clone the previous directory,
build pybox2d and install locally (you need to generate a new
distribution after that with ./distribute.sh)
3. an example using box2d + kivy, located at
https://github.com/tito/pybox2d-android/tree/master/pybox2d-kivy-test

For testing, i'm doing:
cd pgs4a-kivy
bzr update
./build_all.sh
./build_pybox2d.sh
./distribute.sh Kivy-box2d
cd Kivy-box2d
./build.py --package net.txzone.box2d.test --name TestBox2D --version
0.1 --dir ../../pybox2d/pybox2dtest/ debug installd

(Note that the example can be run if you have python-box2d package installed)

Unfortunately, it doesn't work yet, as soon as the _Box2D module is
loaded, i got an exception:
I/python ( 6697): Traceback (most recent call last):
I/python ( 6697): File "main.py", line 1, in <module>
I/python ( 6697): from Box2D import *
I/python ( 6697): File
"/data/data/net.txzone.box2d.test/files/lib/Box2D/__init__.py", line
20, in <module>
I/python ( 6697): from .Box2D import *
I/python ( 6697): File
"/data/data/net.txzone.box2d.test/files/lib/Box2D/Box2D.py", line 28,
in <module>
I/python ( 6697): _Box2D = swig_import_helper()
I/python ( 6697): File
"/data/data/net.txzone.box2d.test/files/lib/Box2D/Box2D.py", line 24,
in swig_import_helper
I/python ( 6697): _mod = imp.load_module('_Box2D', fp, pathname,
description)
I/python ( 6697): ImportError: Cannot load library:
reloc_library[1315]: 87 cannot locate '__cxa_get_exception_ptr'...
I/python ( 6697): Kivy for android ended.

Step by step, i hope that will help both of you for going further.

2011/12/26 Mathieu Virbel <m...@kivy.org>:

Arnaud Waels

unread,
Dec 27, 2011, 9:21:31 AM12/27/11
to kivy-...@googlegroups.com
amazing work you did ! For sure that's helping a lot

Maybe trying with another version of gcc would help
http://www.itk.org/pipermail/insight-users/2007-October/023849.html


2011/12/27 Mathieu Virbel <m...@kivy.org>

Mathieu Virbel

unread,
Dec 27, 2011, 11:49:01 AM12/27/11
to kivy-...@googlegroups.com
I'm using the one cross compiled for arm, shipped in the NDK r7.
(i've spent time to move from r5b to r7, but didn't help).

Also tryed without success:
* -lgnustl_shared
* + libgnustl_static.a
* + preload one of them
* + same with libstdc++ shipped with r7
(both gnustl_shared and libstdc++ contain the symbol).
* -fno-use-cxa-get-exception-ptr (should deactivate usage of thoses
symbols too)

I don't understand why not a single one of all theses approach is not
working. Will retry a little bit tomorrow.


On 27/12/2011 15:21, Arnaud Waels wrote:
> amazing work you did ! For sure that's helping a lot
>
> Maybe trying with another version of gcc would help
> http://www.itk.org/pipermail/insight-users/2007-October/023849.html
>
>

> 2011/12/27 Mathieu Virbel <m...@kivy.org <mailto:m...@kivy.org>>

> 2011/12/26 Mathieu Virbel <m...@kivy.org <mailto:m...@kivy.org>>:


> > Using schedule_interval with 0 is already calling the callback
> each frame,
> > so it will not help.
> > I'll try to check about chipmunk or box2d compilation if that can
> help
> >
> >

> > Le 26 d�c. 2011 � 17:49, Arnaud Waels a �crit :


> >
> > Hi
> >
> > Integration of pypybox2d inside a kivy app works, but slowly..
> > I tried to improve it using a C extension, but it doesn 't help
> >
> > So far, i'm scheduling the physics engine stepping ( world.step()
> function )
> > using Clock.schedule_interval(function, 0)
> > I would like to increase that refreshing frequency
> > Calling this function every canvas.draw() could help ?
> >
> > A
> >

> > 2011/12/24 Mathieu Virbel <m...@kivy.org <mailto:m...@kivy.org>>


> >>
> >> I doubt that ctypes is working. Porting task include all that
> kind of
> >> debugging, try to look why and how you can resolve it.
> >>

> >> Le 24 d�c. 2011 � 18:03, Nicolas Niemczycki a �crit :


> >>
> >> > Hi,
> >> > I follow this instruction.
> >> > I tested to do a package with kivy, android and pymunk.
> >> > I have just a problem with ctypes.
> >> > When I launch :
> >> > try ../python-install/bin/python.host setup.py build_chipmunk
> >> >
> >> > File "setup.py", line 4, in <module>
> >> > import ctypes
> >> > File
> "~/kivy/python-install/lib/python2.7/ctypes/__init__.py", line
> >> > 10, in <module>
> >> > from _ctypes import Union, Structure, Array
> >> > ImportError: No module named _ctypes
> >> >
> >> > Nicolas.
> >> >
> >> >
> >> > On Dec 23, 5:51 pm, Mathieu Virbel <m...@kivy.org

> <mailto:m...@kivy.org>> wrote:
> >> >> For any compiled module, take pgs4a-kivy project from
> launchpad (bzr
> >> >> clone), copy/paste an existing build_<module>.sh (like
> build_PIL.sh), and
> >> >> use it as a template for pybox2d (or underlaying module like
> box2d).
> >> >>
> >> >> (2 steps: generate an arm binary, and install it in
> python-install).
> >> >>
> >> >> Then generate a ./distribute.sh package, and you'll have
> pybox2d in it.
> >> >>
> >> >> (build_lxml contain 2 C lib + 1 python module.)
> >> >>
> >> >> Mathieu
> >> >>

> >> >> Le 23 d�c. 2011 � 17:43, Arnaud Waels a �crit :


> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>> ok thanks for the info
> >> >>> i'm currently writing a test app running box2d inside of a
> kivy app.
> >> >>> I'll let you know what the outcome is.
> >> >>
> >> >>> A
> >> >>

> >> >>> 2011/12/23 Mathieu Virbel <m...@kivy.org <mailto:m...@kivy.org>>


> >> >>> Hi Arnaud,
> >> >>
> >> >>> Good news so far !
> >> >>> I know that Nicolas (attached here) are trying to compile
> pymunk for
> >> >>> android. Maybe both of you can work together on that point ?
> >> >>
> >> >>> :)
> >> >>
> >> >>> Mathieu
> >> >>

> >> >>> Le 23 d�c. 2011 � 15:35, Arnaud Waels a �crit :


> >> >>
> >> >>>> Hi all
> >> >>
> >> >>>> Looking for a full python physics engine in order to run it
> under
> >> >>>> android as well, i ended up trying pypybox2d : the full
> python port of
> >> >>>> pybox2d
> >> >>>> http://pybox2d.blogspot.com/
> >> >>
> >> >>>> Source is available here
> >> >>>>
> >> >>>>
> http://code.google.com/p/pybox2d/source/browse/#svn%2Fbranches%2Fpure...
> >> >>
> >> >>>> On my laptop it's running very well, still slow in case of
> vertical
> >> >>>> stacks, but very fast in case of simple top view blocks
> collision
> >> >>>> Top view physics (instead of side view) is achievable by
> setting
> >> >>>> gravity to 0 and using a friction joint (see apply force
> example
> >> >>>>
> herehttp://pybox2d.googlecode.com/svn/trunk/examples/test_ApplyForce.py

> <http://pybox2d.googlecode.com/svn/trunk/examples/test_ApplyForce.py>)

Nicolas Niemczycki

unread,
Jan 5, 2012, 10:06:54 AM1/5/12
to Kivy users support
Hi

I do a project for building chipmunk with cython.
https://github.com/minou/chipmunk-android
I have just a problem when I import.
Many pymunk functions are implemented.
> >     I've foundhttps://bitbucket.org/timostolz/gamephysics/, a cython

Mathieu Virbel

unread,
Jan 5, 2012, 11:09:24 AM1/5/12
to kivy-...@googlegroups.com
What's the problem at import ?

Nicolas Niemczycki

unread,
Jan 5, 2012, 11:15:29 AM1/5/12
to kivy-...@googlegroups.com
When I do : import cymunk
ImportError: cymunk.so: undefined symbol: cpBodyApplyImpulse
But cpBodyApplyImpulse is defined in body.pxd.

2012/1/5 Mathieu Virbel <txp...@gmail.com>

Mathieu Virbel

unread,
Jan 5, 2012, 11:16:41 AM1/5/12
to kivy-...@googlegroups.com
How did you load the chipmunk lib into android ?
Are you compiling your extension with dynamic or static chipmunk lib ?

On 05/01/2012 17:15, Nicolas Niemczycki wrote:
> When I do : import cymunk
> ImportError: cymunk.so: undefined symbol: cpBodyApplyImpulse
> But cpBodyApplyImpulse is defined in body.pxd.
>

> 2012/1/5 Mathieu Virbel <txp...@gmail.com <mailto:txp...@gmail.com>>


>
> What's the problem at import ?
>
>
> On 05/01/2012 16:06, Nicolas Niemczycki wrote:
>
> Hi
>
> I do a project for building chipmunk with cython.

> https://github.com/minou/__chipmunk-android


> <https://github.com/minou/chipmunk-android>
> I have just a problem when I import.
> Many pymunk functions are implemented.
>
>
> On Dec 27 2011, 5:49 pm, Mathieu Virbel<txp...@gmail.com

> <mailto:txp...@gmail.com>> wrote:
>
> I'm using the one cross compiled for arm, shipped in the NDK r7.
> (i've spent time to move from r5b to r7, but didn't help).
>
> Also tryed without success:
> * -lgnustl_shared
> * + libgnustl_static.a
> * + preload one of them
> * + same with libstdc++ shipped with r7
> (both gnustl_shared and libstdc++ contain the symbol).
> * -fno-use-cxa-get-exception-ptr (should deactivate usage of
> thoses
> symbols too)
>
> I don't understand why not a single one of all theses
> approach is not
> working. Will retry a little bit tomorrow.
>
> On 27/12/2011 15:21, Arnaud Waels wrote:
>
>
>
>
>
>
>
> amazing work you did ! For sure that's helping a lot
>
>
> Maybe trying with another version of gcc would help

> http://www.itk.org/pipermail/__insight-users/2007-October/__023849.html

> <mailto:m...@kivy.org><mailto:m.__..@kivy.org


> <mailto:m...@kivy.org>>>
>
>
> Ok, nicolas told me that he was trying to
> understand why ctypes
> doesn't work.
> Just a tip, ctypes python is using libc on your
> desktop computer, but
> on android, libc doesn't exist. It's bionic. And
> so, some internals
> structures doesn't match libc.
>
>
> For pymunk, removing ctypes would mean that
> somebody must do the
> wrapper using swig or cython. It's a long work, and
> unless you're
> familiar with one of both way, forget about it.
> I've

> foundhttps://bitbucket.org/__timostolz/gamephysics/
> <http://bitbucket.org/timostolz/gamephysics/>, a cython


> wrapper for box2d. But the compilation was a mess.
>
>
> So after checking more about pybox2d, and why it
> would not compile,
> we have now:
>
>
> 1. a new pybox2d-android project, with all the
> changes needed to pass
> the compilation (changes from cstdlib->stdlib.h,
> and some other
> includes changes.)

> =>http://github.com/tito/__pybox2d-android


> <http://github.com/tito/pybox2d-android>
> 2. a new build_pybox2d.sh script, that clone the
> previous directory,
> build pybox2d and install locally (you need to
> generate a new
> distribution after that with ./distribute.sh)
> 3. an example using box2d + kivy, located at

> https://github.com/tito/__pybox2d-android/tree/master/__pybox2d-kivy-test


> <https://github.com/tito/pybox2d-android/tree/master/pybox2d-kivy-test>
>
>
> For testing, i'm doing:
> cd pgs4a-kivy
> bzr update
> ./build_all.sh
> ./build_pybox2d.sh
> ./distribute.sh Kivy-box2d
> cd Kivy-box2d
> ./build.py --package net.txzone.box2d.test --name
> TestBox2D --version
> 0.1 --dir ../../pybox2d/pybox2dtest/ debug installd
>
>
> (Note that the example can be run if you have
> python-box2d package
> installed)
>
>
> Unfortunately, it doesn't work yet, as soon as the
> _Box2D module is
> loaded, i got an exception:
> I/python ( 6697): Traceback (most recent call last):
> I/python ( 6697): File "main.py", line 1, in<module>
> I/python ( 6697): from Box2D import *
> I/python ( 6697): File

> "/data/data/net.txzone.box2d.__test/files/lib/Box2D/__init__.__py",


> line
> 20, in<module>
> I/python ( 6697): from .Box2D import *
> I/python ( 6697): File

> "/data/data/net.txzone.box2d.__test/files/lib/Box2D/Box2D.py"__,


> line 28,
> in<module>
> I/python ( 6697): _Box2D = swig_import_helper()
> I/python ( 6697): File

> "/data/data/net.txzone.box2d.__test/files/lib/Box2D/Box2D.py"__,


> line 24,
> in swig_import_helper
> I/python ( 6697): _mod =
> imp.load_module('_Box2D', fp, pathname,
> description)
> I/python ( 6697): ImportError: Cannot load library:
> reloc_library[1315]: 87 cannot locate
> '__cxa_get_exception_ptr'...
> I/python ( 6697): Kivy for android ended.
>
>
> Step by step, i hope that will help both of you for
> going further.
>
>
> 2011/12/26 Mathieu Virbel<m...@kivy.org

> <mailto:m...@kivy.org><mailto:m.__..@kivy.org


> <mailto:m...@kivy.org>>>:
> > Using schedule_interval with 0 is already calling
> the callback
> each frame,
> > so it will not help.
> > I'll try to check about chipmunk or box2d
> compilation if that can
> help
>
>
> > Le 26 d c. 2011 17:49, Arnaud Waels a crit :
>
>
> > Hi
>
>
> > Integration of pypybox2d inside a kivy app works,
> but slowly..
> > I tried to improve it using a C extension, but it
> doesn 't help
>
>
> > So far, i'm scheduling the physics engine stepping (
> world.step()
> function )

> > using Clock.schedule_interval(__function, 0)


> > I would like to increase that refreshing frequency
> > Calling this function every canvas.draw() could help ?
>
>
> > A
>
>
> > 2011/12/24 Mathieu Virbel<m...@kivy.org

> <mailto:m...@kivy.org><mailto:m.__..@kivy.org


> <mailto:m...@kivy.org>>>
>
>
> >> I doubt that ctypes is working. Porting task
> include all that
> kind of
> >> debugging, try to look why and how you can resolve it.
>
>
> >> Le 24 d c. 2011 18:03, Nicolas Niemczycki a crit :
>
>
> >> > Hi,
> >> > I follow this instruction.
> >> > I tested to do a package with kivy, android and
> pymunk.
> >> > I have just a problem with ctypes.
> >> > When I launch :

> >> > try ../python-install/bin/python.__host setup.py


> build_chipmunk
>
>
> >> > File "setup.py", line 4, in<module>
> >> > import ctypes
> >> > File

> "~/kivy/python-install/lib/__python2.7/ctypes/__init__.py",


> line
> >> > 10, in<module>
> >> > from _ctypes import Union, Structure, Array
> >> > ImportError: No module named _ctypes
>
>
> >> > Nicolas.
>
>
> >> > On Dec 23, 5:51 pm, Mathieu Virbel<m...@kivy.org
> <mailto:m...@kivy.org>

> <mailto:m...@kivy.org><mailto:m.__..@kivy.org


> <mailto:m...@kivy.org>>>
> >> >>> Hi Arnaud,
>
>
> >> >>> Good news so far !
> >> >>> I know that Nicolas (attached here) are trying
> to compile
> pymunk for
> >> >>> android. Maybe both of you can work together on
> that point ?
>
>
> >> >>> :)
>
>
> >> >>> Mathieu
>
>
> >> >>> Le 23 d c. 2011 15:35, Arnaud Waels a crit :
>
>
> >> >>>> Hi all
>
>
> >> >>>> Looking for a full python physics engine in
> order to run it
> under
> >> >>>> android as well, i ended up trying pypybox2d :
> the full
> python port of
> >> >>>> pybox2d

> >> >>>>http://pybox2d.blogspot.__com/


> <http://pybox2d.blogspot.com/>
>
>
> >> >>>> Source is available here
>
>

> http://code.google.com/p/__pybox2d/source/browse/#svn%__2Fbranches%2Fpure.
> <http://code.google.com/p/pybox2d/source/browse/#svn%2Fbranches%2Fpure.>..


>
>
> >> >>>> On my laptop it's running very well, still
> slow in case of
> vertical
> >> >>>> stacks, but very fast in case of simple top
> view blocks
> collision
> >> >>>> Top view physics (instead of side view) is
> achievable by
> setting
> >> >>>> gravity to 0 and using a friction joint (see
> apply force
> example
>
>
>

> herehttp://pybox2d.googlecode.__com/svn/trunk/examples/test___ApplyForce.py
> <http://pybox2d.googlecode.com/svn/trunk/examples/test_ApplyForce.py>
> <http://pybox2d.googlecode.__com/svn/trunk/examples/test___ApplyForce.py

Nicolas Niemczycki

unread,
Jan 5, 2012, 3:29:05 PM1/5/12
to kivy-...@googlegroups.com
To start, I would test on my ubuntu.
I have install chipmunk from github.


2012/1/5 Mathieu Virbel <txp...@gmail.com>

Mathieu Virbel

unread,
Jan 5, 2012, 5:29:28 PM1/5/12
to kivy-...@googlegroups.com
Well ok, so it might be dynamic.
You'll need to

1. compile chipmunk for arm platform
2. ensure the libchipmunk.so is arm: file libchipmunk.so
3. copy the libchipmunk.so in libs/armeabi/
4. open src/org/renpy/android/PythonActivity.java, search for
_imaging.so, and to the same try/catch/System.load for libchipmunk.

=> Before python interpreter really start, it will load libchipmunk.
Then the symbols will be available for when you'll import your module.

Mathieu

On 05/01/2012 21:29, Nicolas Niemczycki wrote:
> To start, I would test on my ubuntu.
> I have install chipmunk from github.
>
>

> 2012/1/5 Mathieu Virbel <txp...@gmail.com <mailto:txp...@gmail.com>>


>
> How did you load the chipmunk lib into android ?
> Are you compiling your extension with dynamic or static chipmunk lib ?
>
>
> On 05/01/2012 17:15, Nicolas Niemczycki wrote:
>
> When I do : import cymunk
> ImportError: cymunk.so: undefined symbol: cpBodyApplyImpulse
> But cpBodyApplyImpulse is defined in body.pxd.
>
> 2012/1/5 Mathieu Virbel <txp...@gmail.com

> <mailto:txp...@gmail.com> <mailto:txp...@gmail.com


> <mailto:txp...@gmail.com>>>
>
>
> What's the problem at import ?
>
>
> On 05/01/2012 16:06, Nicolas Niemczycki wrote:
>
> Hi
>
> I do a project for building chipmunk with cython.

> https://github.com/minou/____chipmunk-android
> <https://github.com/minou/__chipmunk-android>


>
> <https://github.com/minou/__chipmunk-android
> <https://github.com/minou/chipmunk-android>>
> I have just a problem when I import.
> Many pymunk functions are implemented.
>
>
> On Dec 27 2011, 5:49 pm, Mathieu Virbel<txp...@gmail.com
> <mailto:txp...@gmail.com>

> <mailto:txp...@gmail.com <mailto:txp...@gmail.com>>> wrote:
>
>
> I'm using the one cross compiled for arm, shipped in
> the NDK r7.
> (i've spent time to move from r5b to r7, but didn't
> help).
>
> Also tryed without success:
> * -lgnustl_shared
> * + libgnustl_static.a
> * + preload one of them
> * + same with libstdc++ shipped with r7
> (both gnustl_shared and libstdc++ contain the symbol).
> * -fno-use-cxa-get-exception-ptr (should deactivate
> usage of
> thoses
> symbols too)
>
> I don't understand why not a single one of all theses
> approach is not
> working. Will retry a little bit tomorrow.
>
> On 27/12/2011 15:21, Arnaud Waels wrote:
>
>
>
>
>
>
>
> amazing work you did ! For sure that's helping a lot
>
>
> Maybe trying with another version of gcc would help

> http://www.itk.org/pipermail/____insight-users/2007-October/____023849.html
> <http://www.itk.org/pipermail/__insight-users/2007-October/__023849.html>

> <mailto:m...@kivy.org
> <mailto:m...@kivy.org>><mailto:__m.__..@kivy.org
> <mailto:m.__..@kivy.org>
>
> <mailto:m...@kivy.org <mailto:m...@kivy.org>>>>


>
>
> Ok, nicolas told me that he was trying to
> understand why ctypes
> doesn't work.
> Just a tip, ctypes python is using libc on your
> desktop computer, but
> on android, libc doesn't exist. It's
> bionic. And
> so, some internals
> structures doesn't match libc.
>
>
> For pymunk, removing ctypes would mean that
> somebody must do the
> wrapper using swig or cython. It's a long
> work, and
> unless you're
> familiar with one of both way, forget about it.
> I've
>

> foundhttps://bitbucket.org/____timostolz/gamephysics/
> <http://bitbucket.org/__timostolz/gamephysics/>
> <http://bitbucket.org/__timostolz/gamephysics/


> <http://bitbucket.org/timostolz/gamephysics/>>, a cython
>
> wrapper for box2d. But the compilation was
> a mess.
>
>
> So after checking more about pybox2d, and
> why it
> would not compile,
> we have now:
>
>
> 1. a new pybox2d-android project, with all the
> changes needed to pass
> the compilation (changes from
> cstdlib->stdlib.h,
> and some other
> includes changes.)

> =>http://github.com/tito/____pybox2d-android
> <http://github.com/tito/__pybox2d-android>


>
> <http://github.com/tito/__pybox2d-android
> <http://github.com/tito/pybox2d-android>>
> 2. a new build_pybox2d.sh script, that
> clone the
> previous directory,
> build pybox2d and install locally (you need to
> generate a new
> distribution after that with ./distribute.sh)
> 3. an example using box2d + kivy, located at

> https://github.com/tito/____pybox2d-android/tree/master/____pybox2d-kivy-test
> <https://github.com/tito/__pybox2d-android/tree/master/__pybox2d-kivy-test>

> "/data/data/net.txzone.box2d.____test/files/lib/Box2D/__init____.__py",


>
> line
> 20, in<module>
> I/python ( 6697): from .Box2D import *
> I/python ( 6697): File

> "/data/data/net.txzone.box2d.____test/files/lib/Box2D/Box2D.__py"__,


>
> line 28,
> in<module>
> I/python ( 6697): _Box2D =
> swig_import_helper()
> I/python ( 6697): File

> "/data/data/net.txzone.box2d.____test/files/lib/Box2D/Box2D.__py"__,


>
> line 24,
> in swig_import_helper
> I/python ( 6697): _mod =
> imp.load_module('_Box2D', fp, pathname,
> description)
> I/python ( 6697): ImportError: Cannot load
> library:
> reloc_library[1315]: 87 cannot locate
> '__cxa_get_exception_ptr'...
> I/python ( 6697): Kivy for android ended.
>
>
> Step by step, i hope that will help both of
> you for
> going further.
>
>
> 2011/12/26 Mathieu Virbel<m...@kivy.org
> <mailto:m...@kivy.org>

> <mailto:m...@kivy.org
> <mailto:m...@kivy.org>><mailto:__m.__..@kivy.org
> <mailto:m.__..@kivy.org>
>
> <mailto:m...@kivy.org <mailto:m...@kivy.org>>>>:


> > Using schedule_interval with 0 is already calling
> the callback
> each frame,
> > so it will not help.
> > I'll try to check about chipmunk or box2d
> compilation if that can
> help
>
>
> > Le 26 d c. 2011 17:49, Arnaud Waels a crit :
>
>
> > Hi
>
>
> > Integration of pypybox2d inside a kivy app works,
> but slowly..
> > I tried to improve it using a C extension, but it
> doesn 't help
>
>
> > So far, i'm scheduling the physics engine stepping (
> world.step()
> function )

> > using Clock.schedule_interval(____function, 0)


>
> > I would like to increase that refreshing frequency
> > Calling this function every canvas.draw() could help ?
>
>
> > A
>
>
> > 2011/12/24 Mathieu Virbel<m...@kivy.org <mailto:m...@kivy.org>

> <mailto:m...@kivy.org
> <mailto:m...@kivy.org>><mailto:__m.__..@kivy.org
> <mailto:m.__..@kivy.org>
>
> <mailto:m...@kivy.org <mailto:m...@kivy.org>>>>


>
>
> >> I doubt that ctypes is working. Porting task
> include all that
> kind of
> >> debugging, try to look why and how you can resolve it.
>
>
> >> Le 24 d c. 2011 18:03, Nicolas Niemczycki a crit :
>
>
> >> > Hi,
> >> > I follow this instruction.
> >> > I tested to do a package with kivy, android and
> pymunk.
> >> > I have just a problem with ctypes.
> >> > When I launch :

> >> > try ../python-install/bin/python.____host setup.py


>
> build_chipmunk
>
>
> >> > File "setup.py", line 4, in<module>
> >> > import ctypes
> >> > File

> "~/kivy/python-install/lib/____python2.7/ctypes/__init__.py",

> <mailto:m...@kivy.org
> <mailto:m...@kivy.org>><mailto:__m.__..@kivy.org
> <mailto:m.__..@kivy.org>
>
> <mailto:m...@kivy.org <mailto:m...@kivy.org>>>>


> >> >>> Hi Arnaud,
>
>
> >> >>> Good news so far !
> >> >>> I know that Nicolas (attached here) are trying
> to compile
> pymunk for
> >> >>> android. Maybe both of you can work together on
> that point ?
>
>
> >> >>> :)
>
>
> >> >>> Mathieu
>
>
> >> >>> Le 23 d c. 2011 15:35, Arnaud Waels a crit :
>
>
> >> >>>> Hi all
>
>
> >> >>>> Looking for a full python physics engine in
> order to run it
> under
> >> >>>> android as well, i ended up trying pypybox2d :
> the full
> python port of
> >> >>>> pybox2d

> >> >>>>http://pybox2d.blogspot.____com/


>
> <http://pybox2d.blogspot.com/>
>
>
> >> >>>> Source is available here
>
>

> http://code.google.com/p/____pybox2d/source/browse/#svn%____2Fbranches%2Fpure
> <http://code.google.com/p/__pybox2d/source/browse/#svn%__2Fbranches%2Fpure>.
> <http://code.google.com/p/__pybox2d/source/browse/#svn%__2Fbranches%2Fpure
> <http://code.google.com/p/pybox2d/source/browse/#svn%2Fbranches%2Fpure>.>..


>
>
>
> >> >>>> On my laptop it's running very well, still
> slow in case of
> vertical
> >> >>>> stacks, but very fast in case of simple top
> view blocks
> collision
> >> >>>> Top view physics (instead of side view) is
> achievable by
> setting
> >> >>>> gravity to 0 and using a friction joint (see
> apply force
> example
>
>
>
>

> herehttp://pybox2d.googlecode.____com/svn/trunk/examples/test_____ApplyForce.py
> <http://pybox2d.googlecode.__com/svn/trunk/examples/test___ApplyForce.py
> <http://pybox2d.googlecode.com/svn/trunk/examples/test_ApplyForce.py>>
> <http://pybox2d.googlecode.____com/svn/trunk/examples/test_____ApplyForce.py

Antoine Josnin

unread,
Mar 28, 2013, 1:58:37 PM3/28/13
to kivy-...@googlegroups.com
So! one year later, I'm planning to use physics in Kivy

Which physics engine would you recommend to run with Kivy ? 

Has anyone compared performances between pybox2d and pymunk (I don't need to run apps on mobile plateforms) ?

Thanks

Antoine

>         <mailto:m...@kivy.org>><mailto:__m._...@kivy.org
>         <mailto:m._...@kivy.org>

>         <mailto:m...@kivy.org>><mailto:__m._...@kivy.org
>         <mailto:m._...@kivy.org>


>
>         <mailto:m...@kivy.org <mailto:m...@kivy.org>>>>:
>          >  Using schedule_interval with 0 is already calling
>                         the callback
>                              each frame,
>          >  so it will not help.
>          >  I'll try to check about chipmunk or box2d
>                         compilation if that can
>                              help
>
>
>          >  Le 26 d c. 2011 17:49, Arnaud Waels a crit :
>
>
>          >  Hi
>
>
>          >  Integration of pypybox2d inside a kivy app works,
>                         but slowly..
>          >  I tried to improve it using a C extension, but it
>                         doesn 't help
>
>
>          >  So far, i'm scheduling the physics engine stepping (
>                         world.step()
>                              function )
>          >  using Clock.schedule_interval(____function, 0)
>
>          >  I would like to increase that refreshing frequency
>          >  Calling this function every canvas.draw() could help ?
>
>
>          >  A
>
>
>          >  2011/12/24 Mathieu Virbel<m...@kivy.org <mailto:m...@kivy.org>
>         <mailto:m...@kivy.org

>         <mailto:m...@kivy.org>><mailto:__m._...@kivy.org
>         <mailto:m._...@kivy.org>

>         <mailto:m...@kivy.org>><mailto:__m._...@kivy.org
>         <mailto:m._...@kivy.org>

krister viirsaar

unread,
Mar 28, 2013, 2:37:03 PM3/28/13
to kivy-...@googlegroups.com
I was looking into physics just a week ago. I also talked to the devs and concluded that I shall not stick my noob nose in it just yet, because something is being developed as we speak.

Cymunk

Kovak

unread,
Mar 29, 2013, 3:43:06 PM3/29/13
to kivy-...@googlegroups.com
Hi,

I've been using Cymunk in my game. The port is not nearly complete so if you want to enable some of the more advanced features you might have to go in and add some more cython code, but it is really rather straightforward to do so. Mathieu began porting chipmunk about a year ago but since then it didn't seem like anyone was working on the project. You can find his branch here: https://github.com/tito/cymunk

My fork of his code is the one krister linked too, it has a few small bugs fixed and setting the chipmunk collision callbacks with python code is enabled, although there is some work to be done to get it working completely still: https://github.com/Kovak/cymunk/
I am using it in a 2d game I'm working on so I will be updating as I have need of features basically.

I am very happy with the performance of cymunk on android, so you really shouldn't have an issue on desktops.

Mathieu Virbel

unread,
Mar 29, 2013, 6:07:05 PM3/29/13
to kivy-...@googlegroups.com
You should do a PR for thoses changes anyway, because the first repo is
the default one on python-for-android :)

Otherwise, people have to change the url manually :/

Mathieu

Le 29/03/2013 20:43, Kovak a �crit :
> <https://github.com/Kovak/cymunk/blob/master/cymunk/python/space.pxi>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Kivy users support" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to kivy-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Kovak

unread,
Mar 29, 2013, 6:59:40 PM3/29/13
to kivy-...@googlegroups.com
Hi Mathieu,

I will clean my code up a little bit and send you a PR by the end of this weekend, at the moment it is only about half implemented just enough so that I could assure myself cymunk was appropriate for my project.


On Friday, March 29, 2013 4:07:05 PM UTC-6, Mathieu Virbel wrote:
You should do a PR for thoses changes anyway, because the first repo is
the default one on python-for-android :)

Otherwise, people have to change the url manually :/

Mathieu

Le 29/03/2013 20:43, Kovak a �crit :

Antoine Josnin

unread,
Apr 2, 2013, 8:30:18 AM4/2/13
to kivy-...@googlegroups.com
Hi Kovak,

Thanks for your answer, I'll look into your fork!

Kyle Pearson

unread,
May 27, 2014, 11:26:02 PM5/27/14
to kivy-...@googlegroups.com
Hi is there anyway to include this pybox2d package using the buildozer way to compile apps? I am currently trying to test an app but I can't compile it to an android apk because the pip install command is failing when I build with buildozer

This is what I have in my buildozer.spec for the packages:
# (list) Application requirements
requirements = box2d, kivy

Thanks.

Alexander Taylor

unread,
May 28, 2014, 5:58:23 AM5/28/14
to kivy-...@googlegroups.com
The module is pybox2d, not box2d. The latter won't work because it's not just a pure python pip package.

qua non

unread,
May 28, 2014, 11:06:48 AM5/28/14
to kivy-...@googlegroups.com
You should look into using cymunk https://github.com/tito/cymunk this has the advantage of working on mobile devices too just add cymunk as a requirement recipe for this already exists.


--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kyle Pearson

unread,
May 28, 2014, 6:08:50 PM5/28/14
to kivy-...@googlegroups.com
Hi,

I've used cymunk however I found an issue with it that I'm still not able to fix. I just got cymunk working but I had to hack the cython part a little to get it to properly retrieve polygon vertices for me. I recently made a pull request to fix this issue with the main cymunk distribution, so that I can build it with buildozer otherwise I'll have to teach myself how to build my own packages and create an apk with it. 

If you would like to see what the issue was with cymunk, I would like someone to try and run an example piece of code that can be found on https://github.com/theown1/cymunk/tree/master/examples (its the kivy_demo.py)
And see if your distribution of cymunk can properly retrieve vertices. (all you have to do is run it, nothing else)
Reply all
Reply to author
Forward
0 new messages