[ODE] dBodyAddForce problem

jnilson_99@yahoo.com jnilson_99 at yahoo.com
Thu Dec 5 03:33:02 2002


I'm having a problem setting the force on a body
using:

dBodyAddForce (body[0],fx,fy,fx);//see more code below

BACKGROUND:
At a high level I'm trying to 
- place a body at the origin
- then typing the 'f' key to increase the force scalar
- move around the origin with the 'a','s','d','w' keys
and look left,right,up,down using the mouse
(this is just like in any First Person Shooter)
- when I click the Left Mouse button, I grab the
camera/view vectors and use them to detirmine the
force vector(ie the direction to apply force in, I
scale the vector by the force scalar incremented with
the 'f' key.

PROBLEM:
When I hit the Left Mouse button, the object ONLY
travels down the Z axis. No matter where I position
the camera, thus generating a different force vector,
no joy. The body always move only down the Z axis. I'm
now stuck....



if(button == 0 && state == 1)
{
    dVector3 view =
{AppCamera::instance().m_vView[0],AppCamera::instance().m_vView[1],AppCamera::instance().m_vView[3],0};
    dNormalize3 (view);

    double fx = force*view[0];
    double fy = force*view[1];
    double fz = force*view[2];
    dBodyAddForce (body[0],fx,fy,fz);
    dBodyAddForce (body[0],0,-GRAVITY,0);
}

if(button == 2)
{
    dBodyDestroy(body[0]);
    dMass m;
    dMassSetBox (&m,1,SIDE,SIDE,SIDE);
    dMassAdjust (&m,MASS);
    body[0] = dBodyCreate (mworld);
    dBodySetMass (body[0],&m);
    dBodySetPosition (body[0],0.5*SIDE,0.5*SIDE,1);
}

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com