View Single Post
Old 31 December 2019, 15:28   #14
deimos
Registered User

 
Join Date: Jul 2018
Location: France
Posts: 545
Well, gravity seemed easy enough:

Code:
    LONG elapsedTime = GetElapsedTime();

    if (elapsedTime != 0) {
        for (Model * model = scene.firstModel; model; model = model->nextModel) {
            LONG weight = 10 << 8;
            LONG acceleration = -(weight * elapsedTime >> 10);
            ((Entity *) model)->velocity.value[Y] += acceleration;
            LONG delta = (((Entity *) model)->velocity.value[Y] * elapsedTime) >> 10;
            ((Entity *) model)->position.value[Y] += delta;

            if (((Entity *) model)->position.value[Y] <= 0) {
                ((Entity *) model)->position.value[Y] = 0;
                ((Entity *) model)->velocity.value[Y] = -((Entity *) model)->velocity.value[Y] / 2;
            }
        }
    }
Edit:

I've now completed this code for all the forces. It doesn't work very well, I think the major reasons are 1) that the drag formula doesn't take into account the orientation of the aircraft - it should increase greatly during a turn, and 2) that my turning isn't implemented as forces or even with any relationship to the rest of the aircraft's motion. I can see that the only way to do it properly would be to model a lot more forces including angular ones, but as I'm trying keep this as something an 8MHz 68000 can do I'm going to keep looking for ways to simplify and approximate, maybe by creating a look up table of the plane's cross section from different angles to feed into the drag formula, for a start.

Last edited by deimos; 02 January 2020 at 11:10.
deimos is offline  
 
Page generated in 0.06176 seconds with 12 queries