Modeling a tank
Posted: Tue Dec 09, 2008 2:18 pm
How would one go about modeling a tank effectively using BEPU, in my current but somewhat akward method I create 3 bodies (boxes), one for the body, turret and gun barrel. I make the body a dynamic object while the turret and barrel are simple static. All 3 bodies are told to not collide against any of the other three and every frame in the Tank.Update() I manually set the positions of the barrel and turret to match the tanks current orientation and world position. The problems I have with this setup is moving the tank, I'm using applyLinearImpulse but the tank will require alot of impulse units before being set into motion, I also have to control the max velocity each frame, constraining the XZ velocity to a certain magnitude while preserving the horizontal velocity. Using large weights for the tank is also a problem, since a modern tank weigh about 50.000 tons, in my simulation I have to set the tank to weigh about 500 kg instead, otherwise applying impulse will not result in any motion until very very high values and once that value is reached the frame rate will drop to 10 for some time and then the tank will recieve an incridible speed. So my basic questions are:
1. How would one setup the parts that make up the tank in an effecient and easy way, or am I using the corect method?
2. Is there a better way to control a bodies motion while still getting correct collision response, i.e. move() does exactly what I want except the collision response will not be performed. applyLinearImpulse is not very intuitive and I really cant seem to convert the expression move(Forward * X) into applyLinearImpulse(Forward * X * ConversionFactor). Im not that into physics but from what I can tell impulse should allow me to change the momentum of an object, momentum being mass * velocity, shouldnt I be able to apply an impulse that would result in a requested speed if I know the mass of my object?
3. Would it be better to use constraints to attach the turret and barrel over my manual method, although I guess this would mean I would have to make both the
turret and barrel dynamic objects.
Thankful for any advice on this subject.
1. How would one setup the parts that make up the tank in an effecient and easy way, or am I using the corect method?
2. Is there a better way to control a bodies motion while still getting correct collision response, i.e. move() does exactly what I want except the collision response will not be performed. applyLinearImpulse is not very intuitive and I really cant seem to convert the expression move(Forward * X) into applyLinearImpulse(Forward * X * ConversionFactor). Im not that into physics but from what I can tell impulse should allow me to change the momentum of an object, momentum being mass * velocity, shouldnt I be able to apply an impulse that would result in a requested speed if I know the mass of my object?
3. Would it be better to use constraints to attach the turret and barrel over my manual method, although I guess this would mean I would have to make both the
turret and barrel dynamic objects.
Thankful for any advice on this subject.