Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: 3d flight-simulator-like movement

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2011
    Location
    UK
    Posts
    1

    3d flight-simulator-like movement

    Ok, so I am very new at coding opengl, and after getting partway through lighthouse 3d's tutorial for glut, I think it might be pretty easy to modify the code to allow me to remake a game I had made before in 3d (stupid stupid stupid...).

    My basic idea was to add in a 3rd dimension of movement to the lighthouse movement code. So, I quickly copy the movement code, change the variables so they relate to Y, and think everything is dandy. Right up until I test it fully. Then I keep running into problems, which I think I have solved, only to find that it still is not working.

    I'm not actually sure if this should be in this section of the forum, or another, since I think the fundermental problem is my maths.

    The main problem areas of code are:
    Code :
    void computeDir(float deltaAngle) 
    {
    	angle += deltaAngle;
    	lx = sin(angle);
    	lz = -cos(angle);
    	//ly = -sin(angleY);
    }
    void computeY (float deltaY)
    {
    	angleY+= deltaY;
    	ly = -sin(angleY);
    	lz = -cos(angleY);
    	//lx = sin(angle);
    }
    I am pretty sure that I should either be doing something with ly when calculating X, and lx when calculating Y. These functions are only called when there is a change to either deltaAngle or deltaY.

    The code itself is to calculate the direction that the camera is pointing. Since I am trying to keep it nice and simple and am thus using gluLookAt, which I'm pretty sure is a glut function.

    This code is used to display the camera. x, y, z are the coords of the camera, while the second row is the direction that the camara is facing.
    Code :
    	gluLookAt( x, y, z,
    		x+lx, y+ly,  z+lz,
    		0.0f, 1.0f,  0.0f);

    ly, lx and lz represent the vector representing the camera's direction. They are also used in calculating the speed of the camera and drawing the "player" at the location of the camera.

    Can someone please either tell me where my maths is wrong, or where my entire method is wrong and/or point me in the direction of a handy tutorial I can browse through at lesiure.

  2. #2
    Newbie Newbie
    Join Date
    Dec 2012
    Posts
    1

    hi

    hey, did you find a solution to your problem. well I was just going through random forums to help me for my game too. My project is somewhere similar to yours I'm making a dogfight sort of a game.... I'm running into problems too. If you would like to discuss and complete our projects or if you have completed yours please help me.
    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •