first, thanks for taking the time to read this.
I'm not a pro coder but I've been playing with C++ for a while, and combined that pleasure with Truevision3D for the few past years. I integrated ODE to my projects up until Newton 2.0 was integrated to TV3D's engine, which totally got all the process simplier and left me some more time to study other aspects and go further. I do have some "basic" knowledge of physics, forces, friction, etc... but the vector/matrix/quaternion side of maths still have way too many secrets for me.
I would like a few pointers, or just at least to know if I am in the right direction... Too explain briefly, I'm trying to control a sphere via my analog joystick. So as of now, physics are initialized, sphere body and floor static body are created, gravity is set and materials / interactionfrictions are configured for each body.
After a few tests, I realized that applying torque instead of force would be optimal to move as I'd like to get the slippering effect when switching direction while already moving at a good speed.
So I managed to get the value of the joystick and convert it to a vector to apply a torque:
- Code: Select all
vecTorque.x = clInput->stGamePad.Leftstick.X / 100;
vecTorque.y = 0;
vecTorque.z = clInput->stGamePad.Leftstick.Y / 100;
clShell->SetTorque( vecTorque, true);
Where I struggle next is:
1) The directions are all screwed up! In order to test, I apply to another mesh, as rotations, the same torque vector and the direction of the roration is perfectly corresponding to my joystick position but the torque is going in a different way!
2) I know I have to apply a counter torque to slow my sphere when I don't apply any torque since friction won't make it stop. I tried to get the angular velocity vector, inverse it, normalize it, and apply it back to the sphere as torque to provide a constant slowdown but... I get a constant back n forth movement instead.
- Code: Select all
vec = clShell->GetAngularVelocity(true);
vec = vec * -1;
vec = pTVMaths->VNormalize(&vec);
clShell->AddTorque(vec * iSlowFactor, true);
For your information, I cannot use the controller joint nor the userjoint as it is not implemented in the truevision wrapper, that is why I'm trying to manage all this through applying forces / torques.
So... Am I on a good start or totally in the woods? Are my issues more about materials setting and forces fine tuning or on the maths and techniques aspect?
Any help would be really appreciated!
Thx