Thread: Camera rotation/movement in 3D world

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    93

    Question Camera rotation/movement in 3D world

    hmm.. I seem to be having some troubles with moving a camera in 3D space.. I've read through some tutorials and tried writing some code but I just cannot get the effect I want..

    1) When up or down is pressed on keyboard I want the camera & view to move up or down (like someone is wearing a jetpack and is flying)

    2) When left or right is pressed on the keyboard i want the camera to rotate around a point vertically

    Can someone tell me the steps i need to accomplish this?

    1) Check for keyboard input
    2) Find the direction between camera & view
    3) Find the cross product between direction & upvector
    4) Normalize the cross vector
    5) who knows ???

    Am i even on the right track? I've looked at code that rotates the camera around a point horizontally and strafes the camera left and right but i can't understand the math.. anyone have a good site that explains the math involved with some diagrams or something? I can't picture the upvector or the cross product vector in my mind... its making it difficult to imagine what axises i need to rotate about... thnx for any help

    [EDIT] i've messed around a bit more and i got the camera to act like someone is wearing a jetpack.. though i doubt i did it correctly...
    Code:
    1) Camera view - camera position = camera direction
    2) Camera position = Camera position + camera direction * constant speed
    3) Camera view = Camera view + camera direction * constant speed
    can someone tell me if this is the correct way to go about this? it works though i haven't tried rotating the camera so i don't know if this code will still work since i noticed in camera strafing left/right you find the cross product of the camera's direction and camera's up vector.. though i couldn't get camera to go up/down unless i removed the cross product thing...
    Last edited by tegwin; 01-23-2003 at 01:33 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. camera rotation matrix
    By Vick jr in forum Game Programming
    Replies: 5
    Last Post: 05-26-2009, 08:16 AM
  2. 3D starfields regardless of ship position
    By VirtualAce in forum Game Programming
    Replies: 7
    Last Post: 10-17-2006, 11:49 PM
  3. opengl: moving the light with level
    By bluehead in forum Game Programming
    Replies: 24
    Last Post: 04-13-2005, 02:25 PM
  4. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  5. Replies: 3
    Last Post: 05-12-2003, 05:49 PM