Results 1 to 5 of 5

Thread: camera or something like that?

  1. #1
    Guest

    camera or something like that?

    hi
    i have a problem: i want to make a space game and you can see the world in first person view like in wing commander or freespace. So i've coded that i can shoot but the shoots doesnt fly correct. When i rotate about myself the shoots rotete with me cause i must first rotate how the player has rotated. I've then calculatet the shoots relatively to the "camera" that doesn't really exists. Then the shoots fly correct. But if i move my spaceship theres the next problem i must calculate the shoots another time relatively to the camera. This can't be the way to program games or? Is it so complicated? So my question: is in OpenGL a camera like in DirectX that i can use? Or is there another trick like putting all objects in a matrix then rotate and translate the matrix and THEN render the whole matrix at once? Thanks

    Cu

    Shadow

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: camera or something like that?

    Erm, was a bit too complicated for me

    First i wanna way one thing. There is no camera in either OpenGL or Direct3D. Just functions for creating/modifying translationmatrices that acts like a camera.

    Anyways, you should NEVER place objects like missiles and stuff relative to the ship. ALWAYS relative to the world origin (when I think about it, this applies to almost everything). When you do like this, all you have to do is the following:

    * activate modelview matrix
    * load identity matrix
    * set viewpoint/viewdirection (a.k.a. camera)
    * push matrix to stack
    * translate and rotate first object, then draw it
    * pop matrix from stack
    * push it again
    * translate and rotate the second object, then draw it
    * pop the matrix
    .
    .
    .
    and so on.

    In this case, all you have to do is store each object in local coordinates, and a separate values for global position/rotation.

    Say you have a missile, then you store all vertices in local coordinates, a vector holding the current position and a vector for current direction.
    When you fire a missile, the missile gets the same worldposition and direction as the gun (or whatever). Then you are free to move your ship, and it doesn't affect the missile at all.

  3. #3
    Guest

    Re: camera or something like that?

    thanks thanks thanks to you Bob, what i made false was that i don't understood how to use the glPushMatrix and glPopMatrix right, i've used the worldcoordinates for the shoot, with relative i meant it a little bit differently but its equal. Now it goes. I'm really happy cause i've tried weeks over weeks to get it run and this is the solution. Much thanks. I don't use models for my shoots now, i use simple bitmaps but they are flat if you see them from the side. Is there any command so that you can see them always from the front so its from every direction the same?

    cu

    Shadow

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: camera or something like that?

    What you are looking for is called billboarding. Honestly, i don't know exactly how it works, but you can have a look at the major programmingsites, they sureley have information about billboarding.
    http://www.flipcode.com/ http://www.gamedev.net/ http://www.demonews.com/
    ... for example.

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2000
    Location
    Nürnberg,Bayern,Germany
    Posts
    3

    Re: camera or something like that?

    Ok i will have a look at there thanks
    cu

    Shadow

Similar Threads

  1. Looking with Camera?
    By GhostMonkey in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-24-2012, 11:42 AM
  2. [Camera] Can't make the camera move appropriately
    By onion_bread in forum OpenGL ES
    Replies: 0
    Last Post: 12-01-2011, 07:36 PM
  3. Camera Position / Camera Angle / Camera Target Position
    By bobGL in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-02-2007, 09:28 AM
  4. Camera looking thru camera - can it be done?
    By KShots in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 11-17-2002, 12:44 PM
  5. Camera
    By wrelgamal in forum OpenGL: User Software
    Replies: 0
    Last Post: 04-29-2001, 02:36 AM

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