You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers. No questions about C++ programming or topics which are answered in the tutorials!
hi all. I'm building an OOP framework to integrate newton with irrlicht. When i add a force before the loop, it's all ok. But when i add a force in the loop or in a IEventReceiver derived class, the force is not added. i suspect that Newton call NewtonApllyForceAndTorqueEvent function one time. Why? here are a part of my code:
Its been a while since I've used Newton, but it could be like you said, it might only allow you to call AddForce once per AddForceAndTorqueEvent. I think you would be better off adding up all your forces(just add the vectors) into a total force vector in your loop, then calling NewtonBodySetForce() with the total force. Also, it looks like to me in your code you're only applying the x direction force ? Anyways, adding up the forces then using SetForce() would be the cleanest way to do it from what I remember of Newton. Something to remember with your system you've got going is that you're gonna need a way to remove forces from your force vector, so you might wanna take that into consideration.
The add force function only takes effect from the callback function.....read the manual
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
I think you would be better off adding up all your forces(just add the vectors) into a total force vector in your loop, then calling NewtonBodySetForce() with the total force
very good idea. Thanks
Also, it looks like to me in your code you're only applying the x direction force ?
The add force function only takes effect from the callback function.....read the manual
yes, I read the newton tutorial. in fact i add force with the callback function raf::Newt::SceneNode::PhisicsSetForceAndTorqueEvent. This function read from a vector (std::vector<irr::core::vector3df> forces) all forces applied to a body and applied them sequentially. The problem is that i don't want that a force is applied to a body immediately when the body is created, but when i click a key. in this case the callback function PhisicsSetForceAndTorqueEvent is not called (because it is called one time, when the body is created), so the force is not applied. Maybe i need remove and recreate the body in the same position\rotation and applie the force, but it is not a great metod. Is there a metod to force Newton to call PhisicsSetForceAndTorqueEvent every time NewtonUpdate is called?
thanks,
Raffaele ( Ares FPS )