1 (edited by baboon 2017-08-24 22:57:33)

Topic: Help reversing Neverball motion logic

I wonder... would it be too difficult to implement a game mode where the ball would move  because a force was being applied to it rather than tillting the floor? In this game mode basically the camera would remain fixed at a nice wide angled view(s) and the player would move the ball through the scenary by applying a force to it (the ball would gain momentum inertia). The floor would remain fixed. Would this be difficult to implement? What would it take? Which part of the nevercode would you start poking?

2 (edited by baboon 2017-05-25 23:52:27)

Re: Help reversing Neverball motion logic

Getting there! I have managed to stop the perceived tilting of the floor:

Line 153 and154 of code in game_draw.c:

    glRotatef(-tilt->rz * d, tilt->z[0], tilt->z[1], tilt->z[2]);
    glRotatef(-tilt->rx * d, tilt->x[0], tilt->x[1], tilt->x[2]);

need to be changed into

    glRotatef(-tilt->rz * d, 0, 0, 0);
    glRotatef(-tilt->rx * d, 0, 0, 0);

For me, the game is better now. The tilting of the floor gives me nausea and now it feels like you are appling a force to the ball to make it move. Now I just need to find a way of putting the view camera fixed in variety of corner(s) with a wide angle view. Any ideas on how to do this?

It would be great to feature this game mode in Neverball options menu.

3

Re: Help reversing Neverball motion logic

I find this idea interesting smile

I don't know anything about the Neverball code though, so I hope that somebody else can help you.

4 (edited by baboon 2017-05-25 23:58:13)

Re: Help reversing Neverball motion logic

Thanks GunChleoc!

I've been poking the nevercode and, so far, this is the best i came up with:

change lines 152, 153 and 154 of the code in the game_draw.c:

    glRotatef(0.0f, tilt->z[0], tilt->z[1], 0);
    glRotatef(0.0f, 0, tilt->x[1], tilt->x[2]);
    glTranslatef(-ball_p[0], -ball_p[1] * d - 1.0, -ball_p[2] - 2.0);

This not perfect but does give an idea of what we're trying to achieve here!

It would be good if we could tilt the camera view angle, or change to an arbitrary direction to which the camera is pointing. Does anyone know where in the nevercode the camera view rotation is implemented?

5 (edited by baboon 2017-08-25 06:54:28)

Re: Help reversing Neverball motion logic

So far, the best progress I made is by setting the lines 153 and 154 of game_draw.c to

   
glRotatef(-tilt->rz * d, 0, 0, 0);
glRotatef(-tilt->rx * d, 0, 0, 0);

This results in making the ball move by applying a force to it rather than tilting the floor.
However, I would like to position the camera in a corner of the platform and pointing to the middle of it, remaining fixed and not rotating.

In the nevercode, I suspect that  I need to look at the

struct game_view

defined in file game_common.h by:

struct game_view
{
    float dc;                           /* Ideal view distance above ball    */
    float dp;                           /* Ideal view distance above ball    */
    float dz;                           /* Ideal view distance behind ball   */

    float c[3];                         /* Current view center               */
    float p[3];                         /* Current view position             */
    float e[3][3];                      /* Current view reference frame      */

    float a;                            /* Ideal view rotation about Y axis  */
};

I would think that the fields I need to change are the float c[3] and float p[3].
In game_draw.h, there is an instance of struct game_view called view declared in line 19. So, I set all the fields to

view->c[0] = 1.0;
view->c[1] = 1.0;
view->c[2] = 1.0;
view->p[0] = 0.0;
view->p[1] = 0.0;
view->p[2] = 0.0;

everywhere the struct view is defined in the files game_common.c and game_client.c. However that did not seem to work and the camera still runs behind the ball instead of being fixed.

How do I get the camera to remain at a fixed position and looking at a fixed direction?

6

Re: Help reversing Neverball motion logic

You want to control the simulation, not the graphics. See game_update_view in ball/game_server.c. Read the comments in that function for some guidance.

Your glRotatef hack is wrong, also. 0, 0, 0 is a degenerate rotation axis. You will find that the same result can be achieved by removing the two glRotatef calls entirely.