[ODE] ODE & Motion Sensors??

Nate W coding at natew.com
Sat Nov 22 08:31:06 MST 2003


On Sat, 22 Nov 2003, Manohar B.S wrote:

> I know that directly setting the position using
> dBodySetPosition is like violating the physics, and
> hence I am using an alternative method. Where the
> measured position pos(x,y,z) and the actual body which
> has to be moved in ODE space are connected by a stiff
> spring & damper. Of course this works but produces
> vibrations.. damping wont happen..

I have this working in my application, you can click on things with the
mouse and pull them around.  Here's some of the code...

// Get the position of the object being pulled
VectorXYZ vecStartPosition;
m_pPullOn->vGetPosition (vecStartPosition);

// Get the position of the cursor
VectorXYZ vecPullFrom;
m_Scene.vGetCursorPosition (vecPullFrom);

// Compute the pull vector
m_vecPull = vecPullFrom + -vecStartPosition;

VectorXYZ vecVelocity;
m_pPullOn->vGetVelocity (vecVelocity);

// Get pull force (these constants might need some tuning)
m_vecPull = m_vecPull * (200 * rTotalMass);
m_vecPull -= vecVelocity * 20; // <--- THAT'S THE DAMPING

// Apply the pull force
m_pPullOn->vAddForce (m_vecPull);

-- 

Nate Waddoups
Redmond WA USA
http://www.natew.com/




More information about the ODE mailing list