Box2D Forums

It is currently Wed Oct 22, 2014 12:58 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
PostPosted: Sat May 31, 2008 10:49 pm 
Offline

Joined: Mon Feb 18, 2008 12:30 am
Posts: 88
Python Bindings 2.0.1b4 Released

Download: http://code.google.com/p/pybox2d/ (Python 2.4 and 2.5 win32 installers available)
Getting started manual: http://www.box2d.org/wiki/index.php?title=Python_Manual
Usage: http://www.box2d.org/wiki/index.php?tit ... ith_Python

Changes from b3:
  • Supports comparing shapes, joints, bodies. Doesn't require using userData anymore.
  • Major clean ups with Box2D.i
  • Added some docstrings to Box2D.i functions
  • Added b2PolygonDef.checkValues(): checks the Polygon definition to see if upon creation it will cause an assertion to fail (raises ValueError)
  • Wrapped shape.GetCoreVertices() like GetVertices() (for test_TimeOfImpact)
  • test_Web fixed
  • All stuff prettily printed by a semi-automated process now
  • Updated test_Bridge.py to SVN rev 156
  • Added many comments to test_main

Changes from b2:
  • Updated the interface to allow SetUserData() (absolutely necessary for setting the ground's userdata)
  • Fixed b2PolygonShape (.vertexCount is now private, so the accessor is used instead)
  • Linux (possibly OS X) support with setup.py
  • Release for Python 2.4


Top
 Profile  
 
PostPosted: Thu Jun 19, 2008 8:52 am 
Offline

Joined: Thu Jun 19, 2008 8:37 am
Posts: 3
Hi

I've been useing your python port for box2d(Just grabbed the Box2D-2.0.1b4.win32-py2.5.exe). Today I tried to simulate some water by creating a bunch of small ballls, it all worked great untill I created more then 512 bodies(or shapes not sure wich one it was that triggered it). No lag whatso ever and since I have really small balls I naturally want to have more balls = more "water".

My question is if it's possible to change the variable that controlls the maximum amount of bodies from python or do I need to rebuild Box2d to do that? (The variable is in settings.h and is called b2_max_something_I_can't_remember_atm). From what I've figured I need to recomplie it, I tried that and failed miserably so if anyone got some pointers on how to do it (I'm programming at a new installed vista machine) I would be more then happy.


Top
 Profile  
 
PostPosted: Fri Jun 20, 2008 12:17 am 
Offline

Joined: Mon Feb 18, 2008 12:30 am
Posts: 88
Glad to hear you're using the port, thanks, little comments keep me going. :)

Unfortunately, if you want to change the b2_maxProxies and such, it does require recompilation. After having read your request, though, I came up with a patch to the source (well, latest SVN) such that it can be set on the creation of the world. I'm not sure Erin (the author of Box2D) will go along with it. If he does, well, then you can expect it in the next version.

As far as recompiling goes, I guess it's a bit more difficult for Win32 than it is for Linux (which is pretty easy at the moment). You'll need MinGW and MSYS (for compiling), and SWIG to generate the interface. You'll need to add the SWIG path to your PATH after extracting it. Read the top of 'setup.py' for a few notes about MinGW. If you have those three things and read the notes at the top of setup.py, installation *should* be as simple as running 'python setup.py build', then if that worked properly, you can install from there. If you let me know exactly where you're having problems, I'll try and help you from there.


Top
 Profile  
 
PostPosted: Fri Jul 11, 2008 2:13 am 
Offline

Joined: Thu Jun 19, 2008 8:37 am
Posts: 3
I finally got around to trying to recomile Box2d. I've installed MinGW(MinGW-5.1.4.exe) and MSYS(MSYS-1.0.10.exe) and downloaded SWIG (swigwin-1.3.36.zip).

I installed MSYS after MinGW. MSYS found MinGW and seemed happy enugh.

I've started MSYS then
cd c:/temp/pyBox2d/pyBox2D/Box2d/Source (the path to the source folder I got from pyBox2D-2.0.1b4-Source.zip )

when I try make I get the following error:

$ make
c++ -MM -MT Gen/fixed/./Collision/b2BroadPhase.o -g -O2 -DTARGET_FLOAT32_IS_FIXED -o Gen/fixed/./Collision/b2BroadPhase.d ./Collision/b2BroadPhase.cpp
c++.exe: installation problem, cannot exec `cc1plus': No such file or directory
make[1]: *** [Gen/fixed/./Collision/b2BroadPhase.d] Error 1
make: *** [all] Error 2

I have no idea what it means and I'm tiered of banging my head against the c/c++ wall, any idea what I'm doing wrong?

ps. I'll be back when I'm not getting SWIG to work 0o


Top
 Profile  
 
PostPosted: Sun Jul 13, 2008 6:35 am 
Offline

Joined: Wed Jul 09, 2008 5:56 am
Posts: 4
Hi, im using your python bindings (great work) with quite some success.

Now to my question. Im trying to modify the b2_maxLinearVelocity and b2_maxLinearVelocitySquared, however i had no success until now. Is this not possible or is it me doing it wrong?

Code:
import Box2D2 as box2d
box2d.b2_maxLinearVelocity = 1000.0
box2d.b2_maxLinearVelocitySquared = 1000000.0


i have now changed it manually in the sourcecode, however if it's changeable from python. it could prevent a custom build.

btw: i think when calling python setup.py clean, you should also remove _Box2D2.so .


Top
 Profile  
 
PostPosted: Mon Jul 14, 2008 10:57 pm 
Offline

Joined: Mon Feb 18, 2008 12:30 am
Posts: 88
getekha wrote:
$ make
c++ -MM -MT Gen/fixed/./Collision/b2BroadPhase.o -g -O2 -DTARGET_FLOAT32_IS_FIXED -o Gen/fixed/./Collision/b2BroadPhase.d ./Collision/b2BroadPhase.cpp
c++.exe: installation problem, cannot exec `cc1plus': No such file or directory
make[1]: *** [Gen/fixed/./Collision/b2BroadPhase.d] Error 1
make: *** [all] Error 2


I'm afraid I don't know what the problem there is. I'd assume it relates to how you have MinGW setup. The only related error I could find by googling was this: http://www.ultimatepp.org/forum/index.p ... goto=9997& . Following the link gives us a bit more info about MinGW and Vista: http://wiki.codeblocks.org/index.php?ti ... with_Vista . Are you running Vista?

Hypnos wrote:
Hi, im using your python bindings (great work) with quite some success.

Now to my question. Im trying to modify the b2_maxLinearVelocity and b2_maxLinearVelocitySquared, however i had no success until now. Is this not possible or is it me doing it wrong?
...
i have now changed it manually in the sourcecode, however if it's changeable from python. it could prevent a custom build.


Thanks, glad to hear you're enjoying using them. Unfortunately, yes, you are doing it wrong. You shouldn't be modifying these values, as they are very large and constants from the C++ portion of the library. This isn't really a pybox2d limitation as much as it is a box2d one.

If you still want to modify the values, look at the comment Erin placed in the code (Box2D/Source/Common/b2Settings.h):

Code:
/// The maximum linear velocity of a body. This limit is very large and is used
/// to prevent numerical problems. You shouldn't need to adjust this.


Top
 Profile  
 
PostPosted: Tue Jul 15, 2008 12:12 pm 
Offline

Joined: Wed Jul 09, 2008 5:56 am
Posts: 4
Thanks for your help, i've still modified the value and it's going very well for my game. Actually i have increased the value to 10000 and i have not experienced any type of problems (except if i reach some floatingpoint unaccurancy), i really dont understand why there is such a low limit for the maximum velocity.


However i have encountered a new problem:
Code:
import Box2D2 as box2d

worldAABB = box2d.b2AABB()
worldAABB.lowerBound.Set( -10, -10 )
worldAABB.upperBound.Set( 10, 10 )
gravity = box2d.b2Vec2(0.0, 0.0)
doSleep = True
world = box2d.b2World( worldAABB, gravity, doSleep)

class c:
  def __init__( self ):
    print "c.__init__"
    bodyDef = box2d.b2BodyDef()
    self.body = world.CreateBody( bodyDef )
    self.body.pySetUserData( self )
    shapeDef = box2d.b2CircleDef()
    shapeDef.radius = 0.5
    shapeDef.density = 1.0
    self.shape = self.body.CreateShape( shapeDef )
    self.shape.pySetUserData( self )
 
  def __del__( self ):
    print "c.__del__"
 
  def destroy( self ):
    print "c.destroy"
    self.body.pySetUserData( None )
    self.shape.pySetUserData( None )

a = c()

for i in xrange(100):
  world.Step( 0.1, 1 )
  world.Validate()

a.destroy()
del a


will never print "c.__del__", meaning the class is never freed. it's no problem to work around this error, but a solution would be great.


Top
 Profile  
 
PostPosted: Tue Jul 15, 2008 3:13 pm 
Offline

Joined: Mon Feb 18, 2008 12:30 am
Posts: 88
Hypnos wrote:
Code:
  def __del__( self ):
    print "c.__del__"
 
  def destroy( self ):
    print "c.destroy"
    self.body.pySetUserData( None )
    self.shape.pySetUserData( None )



(1) You don't need to call pySetUserData directly, just call SetUserData().

(2) You set the userdata of your shape/body to 'self', which increases the ref count of your object 'a'. The garbage collector won't call the destructor until that refcount goes to zero.
... And now I realize what you're saying. Good find! As far as fixing it goes, though. Hmm.


Top
 Profile  
 
PostPosted: Wed Feb 25, 2009 11:51 am 
Offline

Joined: Mon Feb 18, 2008 12:30 am
Posts: 88
pybox2d 2.0.2b1 Released

All sorts of usability changes, bug fixes, and additional features from the previous versions, so give it a shot. There are packages for most Python versions on win32/linux/osx on the homepage http://code.google.com/p/pybox2d/.

The full changelog, and important code updates, are listed on the blog http://pybox2d.blogspot.com/.

I hope you enjoy it!

Image


Top
 Profile  
 
PostPosted: Thu Nov 18, 2010 2:29 pm 
Offline

Joined: Tue Nov 16, 2010 4:19 pm
Posts: 5
I know it's 2 years old topic, but I've got an error...
Code:
Traceback (most recent call last):
  File "main.py", line 211, in <module>
    if __name__ == '__main__': Main()
  File "main.py", line 35, in __init__
    self.world.SetListener(self.contactListener)
AttributeError: 'b2World' object has no attribute 'SetListener'

I've got pyBox2D 2.0.2 from Ubuntu 10.10 repository. Also I couldn't find FixtureDef object...


edit - ok, I checked Box2D.py and found that it should be SetContactListener(). But still there weren't any Fixture definition.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group