Flight Simulator Viewing System

This is a discussion on Flight Simulator Viewing System within the Game Programming forums, part of the General Programming Boards category; I am currently writing a Flight simulator, using OpenGL and Glut in c I have found some dificulty in getting ...

  1. #1
    Registered User Anarchist's Avatar
    Join Date
    Jan 2002
    Posts
    12

    Question Flight Simulator Viewing System

    I am currently writing a Flight simulator, using OpenGL and Glut in c
    I have found some dificulty in getting the rotations of the view to function how I hoped they would
    I know each rotation must occure in the coordinate system of the planes mothion rather than the world coordinate system.
    to explain as I adont think I'm making any sense, to pitch forward or back, this is a rotation in the axis defined by the wings (possably tip to tip). to roll the plane it must be rotated about the axis defined by the direction the plane is pointing, so from nose to tail. and to yaw or use the rudder the rotation must occure about the upward direction of the plane, these axis would be centered at the center of the plane

    I have a choice of rotating either the up and direction vectors of the plane and then using glulookat() to position the plane in the world where it should be
    or leave the camera at the center and rotate the world about it

    at the current state I'm performing the rotations on the world, using my own matrix for the planes rotations, with a new rotation added each time
    however to display the world I I use gltranslate to position the objects and load the matrix to do the rotations

    glLoadMatrixf(m); //loads my matrix

    glTranslatef(-plane.position.Vals[0],-plane.position.Vals[1],-plane.position.Vals[2]); // translates it
    glCallList(landtile); // loads the landscape

    I have also tried using glmultmatrix after the gl translate call but this made no visable difference

    I hope some one can help me with this

    I'm attaching the current system so you can see whats happening
    use your numberpad to controll the rotations 2+8 pitch, 4+6 roll, 1+3 yaw. this is coded to the numbers.

    PS I cant ask anyone to write me the code to fix this as its for a uni project, but pointers in the right direction or algorithms will be greatly appreciated
    Attached Files Attached Files

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    ok i would recommend moveing the camera and the plane NOT the world.


    So exactly whats the error?

    is the plane rotating and not the camera?
    is the world moving with the plane?
    is the camera not moving right or what?
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Registered User Anarchist's Avatar
    Join Date
    Jan 2002
    Posts
    12
    The problem is its not rotating how it should

    if the first thing you do is turn with the rudder then if you try to pitch it doesnt rotate about the right axis it rotates diagnally instead of virtically, I'm not very good at explaining things wich is why I've included the program in the original post, so you can see for yourself, you will find that the glut libraries need to be installed, but the dll that was needed was too big to add to the zip

  4. #4
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    ok i think i know what your problem is...

    you need to us gl(Push/Pop)Matrix() around your transformations, like so.

    Code:
    glPushMatrix();
    
        TransformObject();
        DrawObject();
    
    glPopMatrix();
    
    //rinse and repeat
    you can also nest them for complex moving objects.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  5. #5
    Registered User Anarchist's Avatar
    Join Date
    Jan 2002
    Posts
    12
    Originally posted by no-one
    ok i would recommend moveing the camera and the plane NOT the world.

    So exactly whats the error?

    is the plane rotating and not the camera?
    is the world moving with the plane?
    is the camera not moving right or what?
    thanks for the advise but I'm not sure how to pull that off, as the camera is the plane and for the rotations to work propery for each rotation I'd have to rotate about a new axis as it would have changed

    in answere to the second question I'm actually ignoring any motion apart from the rotation of the plane(camera)

  6. #6
    Registered User Anarchist's Avatar
    Join Date
    Jan 2002
    Posts
    12
    Originally posted by no-one

    Code:
    glPushMatrix();
    
        TransformObject();
        DrawObject();
    
    glPopMatrix();
    
    //rinse and repeat
    I wish I'd got to a stage where that would be usefull, but my proplems in the transformations
    I'm sure its probably something stupid that I've done it usually is

  7. #7
    Registered User Anarchist's Avatar
    Join Date
    Jan 2002
    Posts
    12
    thanks for the suggestions, I think I've solved it now, like I said in my last post its probably something stupid, I was right it was, I was rotating matricies backwards so the rotations went wrong, no I can start work on making it actually worth all the effort

  8. #8
    Budding Synth Programmer samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Trefforest
    Posts
    368
    Are you sure you want to be putting your entire landscape into a display list? Or is your landscape very repetitive?
    MSVC++ 6.0

  9. #9
    Registered User Anarchist's Avatar
    Join Date
    Jan 2002
    Posts
    12
    I'm not really that sure no, but as it stands the landscpae is just a flat grid of dots, as I have no intention of the landscape changing the book I was using said that was a good optimisation, I am having second thoughts about this though as most the landscape will end up out of site and be wasting time being plotted, I just havent got asfar as working out a quick visablity check
    I am planning a level of deatail check so that if your high up it doesnt plot a high detail landscape, but I havnt got that far yet and only have 4 weeks left to finish ad document it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem With My Box
    By HaVoX in forum Tech Board
    Replies: 9
    Last Post: 10-15-2005, 07:38 AM
  2. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  3. Replies: 6
    Last Post: 03-02-2005, 01:45 AM
  4. stuck with file system ....
    By stalker in forum C++ Programming
    Replies: 3
    Last Post: 10-27-2003, 11:28 AM
  5. Number system base M, print numbers N digits wide...
    By biterman in forum C Programming
    Replies: 12
    Last Post: 11-19-2001, 03:31 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21