Re: Aggressive tracking in a newtonian simulation
Will Vale <[email protected]> Thu, 02 Dec 2010 18:51:24 +1300
| Newsgroups | gmane.games.devel.sweng |
|---|---|
| Organization | Second Intention Limited |
| Message-ID | <op.vm2nvyjo6q9wgg@pimmetje> |
Hi Darren, On Tue, 30 Nov 2010 22:48:55 +1300, Darren Grant <[email protected]> wrote: >> I am a programmer tasked with developing a newtonian simulation of >> high performance spacecraft. For I-War 2, we had what sounds like a similar setup of rigid bodies and requirements. We used a very simple follower for each (local space) angular velocity component, basically the same as the linear velocity component. I just looked up the code and it was something like: for each component i: dv[i] = target[i] * max_speed[i] - current[i] torque[i] = clamp_to_max_torque( dv[i] * moment[i] / dt ) (moment is the diagonal of the MoI matrix - all our stuff was in this form) Pretty horrible stuff - especially dividing by dt - but it worked OK in practice. We didn't allow ridiculous speeds or torques. Our integrator was straight Euler, and while I thought it had some bespoke stuff in to stop it hunting or blowing up, I looked and couldn't find it. I'm sure I remember playing with this at some point, but maybe we ended up constraining the inputs such that it would remain stable. For the NPC ships, our AI coder (Brett Laming) drove the same simulation by setting max angular/linear speeds. He went into more kinematic depth to figure out what inputs to use so that a ship would arrive at a particular place at a particular time (acceleration, coasting, braking). I suspect these days both of us might consider a less pure approach whereby the AI can get at the simulation at a lower level than the pilot interface so we wouldn't have to second-guess it so much. Heh. While looking for this, I found the marvellously-named iiSim::DetachAndFlingChild. As a parent, I have to say I disapprove! HTH, Will _______________________________________________ Sweng-Gamedev mailing list [email protected] http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com