Results 1 to 9 of 9

Thread: Complete source for moving the camera

  1. #1
    Guest

    Complete source for moving the camera

    I already know that there isn't real a camera in opengl, but you can move the world. Now i want to know the source code to do these things:
    On keypress[n] move v units in direction made up of the angle around the x- y- and zaxes.
    translatef(...)
    rotatef(...)

    Can someone please send me the source code for this? I don't need initialization for lighting such stuff. Thanks - Post the sourcecode would be the best, but you can also send it to lightsabresoftware@yahoo.com (simple copy/paste)
    Thanks in advance - Ls

  2. #2
    Junior Member Newbie
    Join Date
    Nov 2000
    Posts
    15

    Re: Complete source for moving the camera

    Down in your windows message look at where you catch input and put this:

    if(VM_UP) {
    movfwd += 0.25; // this with your own speed
    }
    if(VM_DOWN) {
    movfwd -= 0.25; // notice - instead of +
    }
    if(VM_LEFT) {
    movright -= 0.25;
    }
    if(VM_RIGHT) {
    movright += 0.25;
    }

    Then where you do all of your drawing, before you draw anything to the screen do:
    glRotatef(0.0, movright, 0.0);
    glTranslatef(0.0f, 0.0f, movfwd);

    This will get you moving forward and backwards, left and right. You should be able to figure out the rest on your own.

    Hope this helps.

    wire

  3. #3
    Member Contributor
    Join Date
    Jul 2000
    Location
    Braga, Portugal
    Posts
    97

    Re: Complete source for moving the camera

    If you're using GLUT, I have a complete example at my GLUT tutorial
    http://www.fatech.com/tech/glut

    Antonio
    Antonio Ramires Fernandes www.lighthouse3d.com

  4. #4
    Member Contributor
    Join Date
    Mar 2000
    Location
    Leiden, The Netherlands
    Posts
    58

    Re: Complete source for moving the camera

    Maybe you want to do your own rotations/translations. You can the position the the camera where you want using gluLookAt();. Now is not the world translated but your camera.

    I wrote a tutorial on this matter, called 'a first person camera tutorial for OpenGL'. http://www.liacs.nl/~dpalomo/camtut/camtut.html

    Hope this helps,

    Daniel Palomo van Es

  5. #5
    Guest

    Re: Complete source for moving the camera

    DPalomo: That didn't work. I cant say why, cause I did all how you said. Now, does anyone have working code? I already have my own class, but i will use anyone other's class that works. The best would be, if it's not using glut or glu, i'm only using opengl with mingw32, and sometime use allegro( www.allegro.cc or www.talula.demon.co.uk )
    Thanks in advance.
    Ls

  6. #6
    Guest

    Re: Complete source for moving the camera

    Hey, and wire, I already got that far. My problem is the angle around the z-axes (roll or twist called) and the strafing. Thx in advance.
    Ls

  7. #7
    Junior Member Newbie
    Join Date
    Nov 2000
    Posts
    15

    Re: Complete source for moving the camera

    Ahhhh..., ok...
    just do glTranslatef(slide, 0.0f, 0.0f);
    and in your message loop put something like i showed you above. Just be sure to set everything to zero after each loop unless you want to speed around forever.

    wire

  8. #8
    Guest

    Re: Complete source for moving the camera

    SLIDE??????????????? Are you crazy? Thats as easy as .... uhm... very very easy! It isn't real sliding, cause it's not affected by the zangle - and thats what i need!!!

  9. #9
    Junior Member Newbie
    Join Date
    Nov 2000
    Posts
    15

    Re: Complete source for moving the camera

    Don't yell at me, geez, your the one that didn't make it clear what you needed!

Similar Threads

  1. Moving a Light Source
    By synhyborex in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-05-2012, 07:48 PM
  2. Appropriate way to moving camera
    By Login in forum OpenGL ES
    Replies: 2
    Last Post: 04-18-2012, 11:55 AM
  3. who can offer me complete source code of volume rendering !!!
    By guoxusheng in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 01-14-2003, 06:28 AM
  4. Moving the "Camera"
    By ImpactDNI in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-19-2002, 12:50 PM
  5. moving camera
    By mikemor in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-30-2002, 04:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean