Hi everyone,
I am trying to create a composite body made up of a large box with several small circles sitting on each of its edges.
What I'm currently doing is creating one static body, and attaching shapes to it (1 polygon and several circles).
The problem is I can't seem to figure out the whole offset from the center of the body thing, and the circles end up in the wrong places...
Can some one point me at the right direction here? just a few lines of code that create one poly with one circle on the center of one of its edges would be
really helpful.
Also, later on how do i get the location each circle from its shape? I have the static body its attached to and offset (a member named "c" if i understand correctly).
But what's the manipulation i need to do here?
Obviously I'm missing something here, so any help for someone more experienced would be great.
Thanks,
Ehud
Converting from world to local coordinates
-
- Posts: 17
- Joined: Fri Oct 12, 2007 8:59 pm
- Contact:
-
- Posts: 17
- Joined: Fri Oct 12, 2007 8:59 pm
- Contact:
Re: Converting from world to local coordinates
Never mind, figured it out myself.
The only problem I have now is that changing the rotation angle of the static object (which contains several dynamic bodies inside its walls) does not
seem to affect collision detection. The object's vertices do change their position and the object seem to be actually rotated as far as coordinates go, but all
the object contained within it seem to still be confined by the old object (the unrotated one) and unaffected by the static object's rotation.
Any ideas what could be causing this?
Thanks
The only problem I have now is that changing the rotation angle of the static object (which contains several dynamic bodies inside its walls) does not
seem to affect collision detection. The object's vertices do change their position and the object seem to be actually rotated as far as coordinates go, but all
the object contained within it seem to still be confined by the old object (the unrotated one) and unaffected by the static object's rotation.
Any ideas what could be causing this?
Thanks
-
- Posts: 157
- Joined: Mon Aug 20, 2007 12:53 pm
- Location: London, UK
- Contact:
Re: Converting from world to local coordinates
As I found out recently, you have to move/rotate the body before you add it to the space.
-
- Posts: 17
- Joined: Fri Oct 12, 2007 8:59 pm
- Contact:
Re: Converting from world to local coordinates
Yeah, that's what i'm figuring out step by step here as well.
It seems that changing the rotation/position of a static object does not have any effect on collision detection.
Is this a bug or a design thing? Is there anything i can do to fake this? I would think moving static objects is something people need quite often, so i'm guessing
there's another way of doing it?
It seems that changing the rotation/position of a static object does not have any effect on collision detection.
Is this a bug or a design thing? Is there anything i can do to fake this? I would think moving static objects is something people need quite often, so i'm guessing
there's another way of doing it?
-
- Posts: 157
- Joined: Mon Aug 20, 2007 12:53 pm
- Location: London, UK
- Contact:
Re: Converting from world to local coordinates
I was getting the exact same symptoms as you - shapes were drawing in the right place, but things were bouncing off them as if they had not been moved. The fix for me was to move the bodies before adding them to the space. I'm surprised it doesn't work for you.
In this thread slembcke mentions "updating its collision data", but I didn't have to do that.
In this thread slembcke mentions "updating its collision data", but I didn't have to do that.
-
- Posts: 17
- Joined: Fri Oct 12, 2007 8:59 pm
- Contact:
Re: Converting from world to local coordinates
Ok, found it in demo4 (which is exacly what im looking for):
cpSpaceRehashStatic(space) is the answer.
it's even documented correctly, but I somehow missed it...
cpSpaceRehashStatic(space) is the answer.
it's even documented correctly, but I somehow missed it...
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Converting from world to local coordinates
Yes, the objects in the static hash are assumed not to move. That way the collision data doesn't need to be recalculated and rehashed every step.
I'm not sure if I understood the original question, but there are cpBody function for converting between body local and global coordinates. Most offsets are specified as a relative offset in global cordinates.
I'm not sure if I understood the original question, but there are cpBody function for converting between body local and global coordinates. Most offsets are specified as a relative offset in global cordinates.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: Heise IT-Markt [Crawler] and 5 guests