beginner question

Official forum for the Chipmunk2D Physics Library.
Post Reply
rocker2000
Posts: 4
Joined: Fri Nov 09, 2012 6:09 pm
Contact:

beginner question

Post by rocker2000 »

hi,

im writing a little app using sparrow for iOS & chipmunk.

basically have a few balls flying around that i want to bounce of some wall areas.

i wonder if someone could clarify some chipmunk concepts for me.

here's a summary of my gleanings so far -

* background in sparrow

(a) sparrows x,y origin is 0,0 top left of screen and increases along x,y to bottom right.
(b) x,y for a sprite is the top left hand corner of that sprite, but can also specify a centre "pivot point".

* in chipmunks world - and this what id like to clarify if my understanding is correct.

(c) chipmunks x,y origin is 0,0 bottom left of screen and increases along x,y to top right?
(d) when you place a body in chipmunk world, its x,y coordinate is basically its centre?
(e) when you place say a chipmunk circle in that body you can specify its x,y offset from the bodies centre & a radius.
so my question is how is the circle laid out using that offset in chipmunk land i.e. is the circle's centre the bodies specified x,y?

i hope that makes sense, thanks.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: beginner question

Post by slembcke »

So Chipmunk doesn't really care which way your coordinates go, but some things are good to keep in mind. First is that Chipmunk was designed with a "regular" (y-axis points up) coordinate system. It's just more natural to me, and most hardware rendering APIs default to working that way. So for instance, when I say that a polygon should have a (counter)clockwise winding, you'll have to keep in mind that it's defined the other way around if your coordinates are flipped. Bounding boxes are also flipped as the "top" stores the max-y value and the "bottom" stores the min-y value. I think those are the only two things you have to care about really.

Other than that, Chipmunk doesn't care where your origin is (Chipmunk spaces don't have a size or bounds), and it doesn't care which way is down (which is really just defined by which way gravity points), nor does it care where your ground is located (to Chipmunk it's just a collision shape placed somewhere). If you set gravity to have a positive y-value, objects will fall by causing their y-value to increase.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: beginner question

Post by slembcke »

Oh, and the position of a body is the position of it's center of gravity (the point it will rotate around). When adding shapes to a body, their coordinates are relative to a body's center of gravity as well. Think of it as being similar to the anchor point of a sprite. You'll probably want to make it be at the center of the object visually unless you have a good reason not to or it's a weirdly shaped object.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
rocker2000
Posts: 4
Joined: Fri Nov 09, 2012 6:09 pm
Contact:

Re: beginner question

Post by rocker2000 »

hi thanks for your reply. most helpful.
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests