Vector3 Question

victorio
Posts: 4
Joined: Wed Jan 16, 2008 10:48 pm

Vector3 Question

Post by victorio »

Hello, on mouse move I am calculating the old mouse position vector3 and the new mouse position vector3. I want to then take those two values and get a new Vector3 of where the object should go based upon those two values. I am currently using the Vector3.Add method but that is clearly the wrong approach. Can anyone help? Thanks in advance!
victorio
Posts: 4
Joined: Wed Jan 16, 2008 10:48 pm

Re: Vector3 Question

Post by victorio »

I am trying this in a PhysicsWorld with gravity on Z:

Vector3 newVector3Pos = pp.Pos2DToPos3D((int)newMousePos.X, (int)newMousePos.Y);
newVector3Pos.Normalize();
newVector3Pos *= 7.0f;
Vector3 relPos = newVector3Pos - pb.Body.CenterOfMassPosition;
relPos.Normalize();

pb.Body.ApplyImpulse(newVector3Pos, relPos);

the results are funky but it is moving. Not in the direction my mouse is moving. Any help would be greatly appreciated as I am REALLY NEW to Bullet. Thanks!
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Vector3 Question

Post by Erwin Coumans »

Is this really Bullet C++ version?

It looks more like a port or other physics engine. Where is this 'Pos2DToPos3D' method implemented?

Thanks,
Erwin
victorio
Posts: 4
Joined: Wed Jan 16, 2008 10:48 pm

Re: Vector3 Question

Post by victorio »

Good point, I should have mentioned, this is the C# port and Pos2dToPos3D is just the ReyTo method refactored. So it just takes a point and returns a point in 3D space, if I am correct.