Jump to content

  • Log In with Google      Sign In   
  • Create Account

Moving Camera or Moving objects?


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   -  Reputation: 124

Like
0Likes
Like

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.

 



Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 14258

Like
2Likes
Like

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
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 Kryzon   Prime Members   -  Reputation: 3314

Like
0Likes
Like

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+   -  Reputation: 1204

Like
0Likes
Like

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:

http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/

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:

https://glsl.heroku.com/e#18570.0

https://glsl.heroku.com/e#18559.0

or

https://glsl.heroku.com/e#18500.0


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

Beginner here <- please take any opinions with grain of salt :P





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.



PARTNERS