Results 1 to 7 of 7

Thread: Camera Relativity (and other stories)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Location
    Yorkshire, UK
    Posts
    21

    Exclamation Camera Relativity (and other stories)

    OK, this is really annoying me now.

    I thought I'd fixed the problem, but I haven't. Here's what's up:

    I have a nice full screen 3D world thing. I'm trying to move a camera around it - kinda like free-look mode in Counterstrike (when you get dead). We fixed up some keyboard input to move the camera up the axis, like strafing, forwards etc. Fine.

    But then you put the mouse on.

    When you do this, and press forwards, you CONTINUE TO MOVE ALONG THE Z AXIS, and NOT in the direction you're facing. Same for if you try strafing, you just move along the X axis regardless of the way you're looking.

    This is pants.

    So If someone could point us towards a tutorial or something we'd be VERY grateful.

    Firejack
    100% of drink driving incidents are alcohol related.

  2. #2
    Zaei
    Guest
    You have to find the angle that you are facing on the XZ plane, and the XY/ZY plane (left/right, and up/down). Then, instead of simple adding a value to the Z camera value, you have to figure out a vector that defines the direction you are looking at, and move along that vector.

    Also, If you are using the D3DXMatrixLookAtLH or ..RH functions, you can create a vector by adding (or subtracting, dont remember) the current camera position, and the point it is looking at, normalize that vector, and move along it.

    Z.

  3. #3
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    The Dark Side of the Moon
    Posts
    448
    That's in the realm of 3D game theory.

  4. #4
    Zaei
    Guest
    Thats what he's talking about...

    Z.

  5. #5
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    The Dark Side of the Moon
    Posts
    448
    I know, I just felt like posting.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Location
    Yorkshire, UK
    Posts
    21

    Thanks

    Thanks.

    Methinks I'll have a look at the DX8 SDK and see if/how they've done it. We tried numerous methods for the camera. One was the D3DXCameraLookAtRH or something, but that goes pants when you start looking around. You keep looking down the X axis rather than swithching to the Z axis as you turn.

    Then we tried re writing the matrix ourselves, which is great for the strafing, but again goes to pot when you try to look around.

    Not quite sure why...

    Latest idea is to set the X, Y, Z, W properties of a quaternion for the rotation, and then turn it into a matrix and combine it with the position matrix of the camera.

    Not tried it yet. Thanks for the help anyways.

    FJ
    100% of drink driving incidents are alcohol related.

  7. #7
    Zaei
    Guest
    Think of it this way. Your object is facing in a certain direction on a circle. If you keep track of this value, you can change this to a look at point:
    Code:
    .x = cos(facing);
    .y = cam.y;
    .z = sin(facing);
    Where y is in the up direction. That should solve the looking around part. When you move, simply move in the direction you are facing, instead of simply adding 1 to .x, or .z, etc.

    Z.

Posting Permissions

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



Click Here to Expand Forum to Full Width