Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Moving Camera or Moving objects?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Mondain   Members   


Posted 30 July 2014 - 09:52 AM


I want to program a "star wars" starfield with objects moving towards the screen.

What would be the OpenGL principle behind this? How does it work in principle with OpenGL?

- Do I have stationary objects and move the camera?
- Do I have a stationary camera and move the objects towards the camera?

Thanks for help.


#2 L. Spiro   Members   


Posted 30 July 2014 - 11:08 AM

Which way makes sense?

Do you want to have a stationary camera with things flying past or do you want the camera to fly through a field of stationary objects?
If you are talking about Star Trek and the little star-like dots that fly past, it’s the camera moving through a field of stationary objects (if you reference Star Wars it could be anything flying by the camera).

This has nothing to do with OpenGL. Whatever graphics API you are using, do whatever makes sense.

L. Spiro

#3 Kryzon   Prime Members   


Posted 30 July 2014 - 04:59 PM

The farther that you go from the origin, the greater the float imprecision.

Moving the view point is the most natural choice, but you will have to change the way that you compute positions to lessen the effect.
- http://stackoverflow.com/questions/1930421/seamless-transitions-of-scale-over-large-distances-3d-rendering
- http://stackoverflow.com/questions/5010612/increase-precision-in-directx-with-high-range-positions
- http://www.gamedev.net/topic/208532-big-coordinate-values-in-direct3d/

#4 Misantes   GDNet+   


Posted 31 July 2014 - 12:25 AM

As a beginner myself, I was also little confused on this. So, I thought I'd pipe in with a sort of simple explanation here. But, it really comes down to a semantic problem. You have two basic ways of moving things. You can translate the ModelMatrix, which moves the object's position in "worldspace," or you can change the ViewMatrix. translating the ViewMatrix is kind of equivalent to moving the entire world (you're essentially moving the "world center." Whether you want to think of it as moving the "camera" or moving the entire world is kind of a moot point(in my opinion, feel free to correct me on this).


For my own little space simulator, I essentially alter the ViewMatrix to "fly" my character's ship through the world, and translate the ModelMatrix of the stars/planets and such for their own orbits around their stars, etc(it's a little more complicated, but that's the general gist of the movement).


I highly recommend:


as it offers a pretty good explanation of matrix translations. If you're like me, you'll need to read it more than once tongue.png

But, it all boils down to your relationship between your Model and your View matrices (and also the projection matrix, but that's only tangentially related to your question).


For the "star trek" effect, I personally use a particle system to just make tons of little particle debris that flies toward the camera (while altering the VIewMatrix to fly) as my ship doesn't fly nearly fast enough through the planets and such to really give that effect. If you're really travelling that fast in the game you might want to consider something along those lines as depending on how large your object class is, as you may find yourself running into problems generating that many entities (unless you have a clever workaround, I'm sure there is one). A particle system is way beyond the scope of this explanation though. But, again, If you're travelling that fast, you may need to look at alternative methods rather than just creating objects and moving by them.


And my sincerest apologies if this isn't quite what you were asking. I don't mean to be condescending at all. I just got the impression you may have been looking for a more basic explanation of things. If you totally understand all this already, feel free to disregard my comment smile.png


If you're truly just looking for the effect, doing this through a glsl shader might be your best bet.

I didn't search that hard, but something along the lines of:





Edited by Misantes, 31 July 2014 - 12:44 AM.

Beginner here <- please take any opinions with grain of salt Posted Image

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.