[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] pixel-perfect physics?
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] pixel-perfect physics?
- From: "Nirav Patel" <olpc@xxxxxxxxxxxxxx>
- Date: Sun, 26 Oct 2008 10:04:26 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sun, 26 Oct 2008 10:04:30 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=8EqsyCiR04o1eLbw3RdmDzxrT+bMaFUGoT7mCWd1fOA=; b=RxMxJAIH6CHxnUv4GNuDvC0iFp2pOV1WKoJBdW90wYanXhYJi8pUFk08P4CqWcg+yZ J508KRiL1FzGJ8a0yFQxowVrHHVHqIPQKoc1UEmuGiUFr8d/0r1m8/1DoxRcIxWmLWv7 H19IipyLS7/ktK6ml2UXJHytP/Pqo9synKeck=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=AWUafC4y9sHL4PqiFxHrmZXpa6VxC2d0jRVT5gBpaLAY8Nr7+W5KN1iFBP6rtuK91Y RjHMTWaSq47iHpuUVFvpGB7Ti8kWJ4MqpwRaeX8ApW9nqchldBfT2ESh7zFjvuc0cC9w +mxkW0Gz7UuUBm96VeAc1zH8gs/WGU45rHtnc=
- In-reply-to: <49023526.4090109@xxxxxxxxxxxxxx>
- References: <49023526.4090109@xxxxxxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Certainly not an easy problem, especially if the shapes are convex. A
sort of hackish way to do this in PyBox2D, if the shapes aren't
already known polygons, is to use Mask.outline() to get some points on
the outline of your object and create a Box2D Poly out of a bunch of
thin connected rects shaped like your object. This is a really bad
description, but check out this thread:
http://www.box2d.org/forum/viewtopic.php?f=8&t=563 .
Elements, a wrapper for PyBox2D, has functions similar to this written
that you may also want to look at. Take a look at complexPoly and
concavePoly in http://dev.laptop.org/git?p=activities/physics;a=blob;f=elements/add_objects.py;h=3842b750a8dfe46d9400bab1c6ff5d6206dc718f;hb=HEAD
This still isn't pixel perfect, but accurate physics and pixel perfect
collision do not go together.
Nirav
On Fri, Oct 24, 2008 at 4:50 PM, Michael George <mdgeorge@xxxxxxxxxxxxxx> wrote:
> Has anyone had experience using pixel-perfect collision detection with a 2d
> physics engine? I've looked into pymunk, but that seems to have baked-in
> collision detection so I don't see how to do it. ODE has rudimentary python
> bindings and has separate collision detection, but it's intended for 3d and
> the 2d support hasn't been added to the python port yet. There's the GSOC
> pygame physics project, but I don't see docs for that and can't tell if it
> would be suitable.
>
> Also, as far as doing the collision detection, AFAICT there isn't a way to
> rotate a mask, or to do collision detection on rotated objects. Are there
> plans for something like this, or am I stuck with using an image, rotating
> it with the transform package and then using Mask.from_surface?
>
> Thanks.
>
> --Mike
>