I'm having some trouble creating Polygons in Pymunk.
import pymunk
space = pymunk.Space()
space.gravity = (0.0, 900.0)
box_points=[(-100,-100), (100,-100), (100,100), (-100, 100)]
body = pymunk.Body(10.0, 1000.0)
body.position = pymunk.Vec2d(300.0,300.0)
shape = pymunk.Poly(body, box_points, (0,0))
space.add(body, shape)
print shape.get_points()
# Outputs: [Vec2d(300.0, 300.0), Vec2d(300.0, 300.0), Vec2d(300.0, 300.0), Vec2d(300.0, 300.0)]
The vertices of the shape are all at the center of the body! (i.e. at (0, 0)). I think they shouldn't be, or am I skipping some step?
I'm running Mac OS 10.7.4, using Chipmunk v6.0.2 and Pymunk 2.1.0.. Is this a bug?
Looks like you stumbled on the 32bit compilation bug in chipmunk. Starting with 10.6 Apple changed the predefined defines in its header files which created a bug only on 32 bit python on OSX. Good news is it is already fixed in the latest pymunk svn trunk.
Full details in the chipmunk forum here: http://chipmunk-physics.net/forum/viewtopic.php?f=1&t=2265
get_points should return the points in world-coordinates, meaning the output in your example should be:
[Vec2d(200.0, 400.0), Vec2d(400.0, 400.0), Vec2d(400.0, 200.0), Vec2d(200.0, 200.0)]
(I hope to release a new version of pymunk soon. Im currently converting over to sphinx for the documentation, but most of it is already done)