multiple inputs acting on a polygon

Official forum for the Chipmunk2D Physics Library.
Post Reply
chmille3
Posts: 3
Joined: Thu Apr 30, 2009 3:34 pm
Contact:

multiple inputs acting on a polygon

Post by chmille3 »

I am working on a project that uses multiple inputs (i.e. finger tracked input) to interaction with polygons. Right now I am emulating the multiple inputs by capturing separate mouse clicks as their own input object (joint and all to a polygon) and the current mouse object being the only input that can move, the others are static (sometimes I have a moving function to simulate movement for the capture input(s)).

With this I am trying to simulate a rotation of a polygon using two inputs where one input acts like an anchor and the other determines the rotation direction or the two inputs rotate causing the polygon to rotate (much like when you rotate an object on a table with 2 fingers). At first I thought I would just have to have two inputs in which one or both perform a drag operation. But this does not work. The polygon stays with my moving mouse and leaves behind the captured point and when the captured point has a move function to simulate independent movement, the polygon still does not rotate as I would expect - it stays with my moving mouse input.

I just want to try and get rotation for free from the physics engine using two inputs without having to do much of my own calculations. Any ideas? Thanks
FYI: I am using Pymunk, the python wrapper for Chipmunk.
PeskyJ
Posts: 19
Joined: Fri Apr 24, 2009 4:24 pm
Location: Reading, UK
Contact:

Re: multiple inputs acting on a polygon

Post by PeskyJ »

I think I understand what you want to do from your explanation. It seems to me you should add two pivot joints at each location attached to your shape's body object, and each attached to their own body (one each) of infinite mass and inertia, put the joints in the space but not the bodies, then set the body positions manually.
Games games games... I love games. Check out my games: [url]http://www.tinyplay.com/games.html[/url]
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: multiple inputs acting on a polygon

Post by slembcke »

Attaching multiple joints to multiple infinite mass bodies is going to be problematic with the 4.1.x version of the library. The trunk code has much improved joint code because among other things you can set the maximum joint correction force on a per joint basis. This would allow you to attach joints that would oppose each other without the joint correction forces fighting and climbing out control.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests