We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Manually moving objects in Jbox2D
Page Index Toggle Pages: 1
Manually moving objects in Jbox2D (Read 718 times)
Manually moving objects in Jbox2D
Mar 20th, 2009, 9:40pm
 
Jbox2D (and the wrapper BoxWrap2D) is looking very impressive. I'm a physicist, and I think I can make some fun demos with these tools.

I want to simulate a scenario with a vibrating floor - a rectangle that moves vertically in a sinusoidal manner. I can manually control the velocity of an object with 'setLinearVelocity', but I can't find an equivalent to let me set the object position.

Any ideas? This seems like a pretty standard thing to do.
Re: Manually moving objects in Jbox2D
Reply #1 - Mar 21st, 2009, 3:29pm
 
Hi,
i only worked with pure JBox2D, so i don't know if there is some difference in the BoxWrap2D lib.
The Body-class has a method setXForm(Vec2 position, float angle)  where you can set the position of a Body by code. (You must also specify the angle of the body !).
Here some example:
bodyX.setXForm(new Vec2(x,y), bodyX.getAngle());
Page Index Toggle Pages: 1