This project has moved and is read-only. For the latest updates, please go here.

How to disable Spring effect

Topics: User Forum
Dec 24, 2007 at 10:34 PM
I'm trying to make an effect of moving photos on the table. I have created rectangle body and use FixedLinearSpring controller to move it around.
But "spring" is makeing movement very unnatural. Is it possible to disable spring effect and rotation?
Dec 25, 2007 at 11:10 AM
A physics engine in itself is only calculating object's position and rotation. If you wan't to ignore the rotation of the objects, just reset the rotation of the objects on every update. (Or edit the farseer engine to not set the rotation on the objects when a condition on the objects are true. You could make an IgnoreRotation property on the physics objects).

About the spring between the mouse and the bodies: Don't use a FixedLinearSpring. The purpose of the FixedLinearSpring object is to make a sprig effect between the physics body and another point. (the mouse in your case).
You could instead set the position on the physics bodies manually by fetching the position of the mouse and set it on the body being controlled by the mouse.
You can check if a body is under the mouse by using the method CollideAt() It get's you the physics body of a specified point.
Dec 25, 2007 at 1:01 PM
Thank you for a fast answer genbox.
If I set the position on the bodies manually will they still have an inertion movement after mouse buttons are released?
With rotation it is complicated. Actualy I want them to rotate, but only if more then one force at a time is applied to body (imagine you use two fingers to rotate a photo).
Dec 25, 2007 at 4:01 PM
No, they will not continue to move in the direction of the movement. A fix to this would be to apply a force to the physic objects. This way they would continue to move, but gradually slow down.
Dec 25, 2007 at 4:57 PM
Yes, I want them to slow down. But I don't know how to correct calculate the force to apply :(
Is there a solution for rotation?
Dec 25, 2007 at 8:28 PM
There is a ApplyTorque() method on the body object. You could increase the value of ApplyTorque() on each update (if there are 2 fingers used to rotate the photo), that would speed up the rotation.
Dec 25, 2007 at 11:58 PM
Excuse me my ignorance but isn't ApplyTorque and ApplyForce are the same as TranslateTransform and RotateTransform?
I have tried first to program movement and rotation myself. But didn't get near-reality effect. I hoped that physic engines can do this for me.
But it seems that I still have to write many code myself.
Or am I wrong?
Dec 26, 2007 at 11:29 AM
Yes, ApplyTorque is for rotation and ApplyForce is for translation.
Application and game development is all about coding. Of course it's easier to develop an application when you get some help from a library as Farseer Physics, but if it does not do 100% what you want, you will need to make it your self.

If you are doing something like this:

farseer can help you in some way, but most of it is custom made.
Dec 26, 2007 at 1:07 PM
Actualy like this:

I don't afraid of code, also from many code :) I like coding. But I'm afraid of physics o:-)