Results 1 to 5 of 5

Thread: FPS View

  1. #1
    Join Date
    Jun 2006

    FPS View

    Hi All

    How do you code your view so its in fps view?

    Help would be very nice thankz in advance

  2. #2
    Join Date
    Feb 2004
    Shirebrook, England
    Just to clarify, you mean First Person View, As in the view used in games like Half-Life and Doom?

    As in, as you move your mouse right, the world moves around you to the left.

    What API are you using or plan to use?


    Last edited by thing2k; 06-06-2006 at 04:14 AM.

    Wii Friendcode: 6478 2149 1540 7684

  3. #3
    Join Date
    Aug 2005
    You need to know how to set and get the mouse position.

    You check the distance the mouse have moved from the middle of the screen, change the "camera's" rotation depending on how far the mouse have gotten, and then you reset the mouse position to the middle of the screen.

    It's pritty easy, accually, I've done an FPS-view sometime myself...

  4. #4
    Join Date
    Aug 2003
    Madrid - Spain
    You have to know the position of the head for example, say it's:
    int posX, posY, posZ;
    Then you have to move the world like this:
    moveFunction(-posx, -posY, -posZ); // The move function depends on the API you're using
    Hope it helped

    EDIT: And of course you've gotta do what EvilCookie said too
    n4x0 -- C++ Programmer
    Tank Game - Progress: 11%

  5. #5
    Join Date
    Dec 2003
    Adelaide, Australia
    If you are programming in OpenGL or DirectX (although I think DirectX already has a camera abstraction but I'm ignoring it for this post ) the world is drawn in relation to the origin. The view points either in +Z for a left hand coordinate system (DirectX) or -Z for a right hand coordinate system. When you want to "move the camera" you actually move the world to the correct position so that it is rendered from the view point that you want. Note: that it's quite common to create an abstract concept of a camera so that it can be positioned in the world.

    So in actual fact you have a transform group above everything in the the world which you can manipulate like a camera (except you perform all operations on it in the opposite direction to what you would with the camera). To move forward you translate the world backward, to strafe left you translate the world right (and so on). This can be a little confusing at first especially because you need to move your character's geometry in the opposite direction to the world so that it stays synchronised with the camera.

    Getting to the point:
    Anyway, you need to put the world in the correct place so that your render view will be looking out of your characters eyes. Moving and looking around is as easy as connecting the mouse and keyboard input to the opposite directions that you want to move / look.

    Abstracting the camera (6DOF):
    I'm pretty sure this would work (but I haven't tried it so don't shoot me if it doesn't ). If in your scenegraph you have a transform group at the position / orientation that you want the camera. Multiply all your geometry transforms by the inverse of the "camera's" final transformation matrix.

    If you have this "special" transform node marked in the scenegraph as a camera, you should be able to render from any of the camera nodes in your scenegraph whenever you want. What's more, you don't have to do the negative rotates and translates, you only need to the move the camera transform to the correct place in the world. The multiplication by the inverse of the camera transform matrix means that everything should be in that transforms coordinate system.

    BTW, if anything wasn't clear please ask
    Last edited by TheDrakeMan; 06-08-2006 at 05:29 AM.
    Mark - TheDrakeMan
    "The anatomical juxtaposition of two orbicularis oris muscles in a state of contraction."
    - Dr. Henry Gibbons, definition of a kiss
    "All parts should go together without forcing. You must remember that the parts you are reassembling were disassembled by you. Therefore, if you can't get them together again, there must be a reason. By all means, do not use a hammer." - IBM maintenance manual (1925)

Posting Permissions

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