PDA

View Full Version : camera or something like that?



06-25-2000, 04:28 AM
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

Bob
06-25-2000, 08:26 AM
Erm, was a bit too complicated for me http://www.opengl.org/discussion_boards/ubb/tongue.gif

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.

06-25-2000, 11:00 AM
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 http://www.opengl.org/discussion_boards/ubb/smile.gif 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

Bob
06-27-2000, 08:06 AM
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.

Shadow1
06-27-2000, 11:46 PM
Ok i will have a look at there thanks
cu

Shadow