0

I have a nice scene set up, and everything is rendering fine, and now I want to pan over the world, similar to how I'd adjust the origin of a UIScrollView or a CAScrollLayer with scrollToPoint(). I have determined that I can continually adjust the projectionMatrix on a GLKBaseEffect to change what I see, but I'm not sure if this is the appropriate way to do things.

In other code I see calls to glViewport and such, and that sounds like something that might be the proper thing to use, but I have no idea what this call actually does, so maybe it's just a red herring.

What's the typical way to do something like this?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Mason Cloud
  • 1,266
  • 1
  • 15
  • 20

1 Answers1

-1

You have to use you transformation matrices for this purpose. In other words, Projection and View matrices are kind of fake camera in your scene, so, if youi want to scroll your scene you have to apply translate transformation to either World (to move the objects in your scene) or View (to move the camera) matrix.

I recommend you this free on-line book about OpengLS ES: http://ofps.oreilly.com/titles/9780596804824/chmath.html

Tutankhamen
  • 3,532
  • 1
  • 30
  • 38
  • Ok, so it sounds like moving around the projectionMatrix is indeed the the appropriate way to move the camera around, is that correct? – Mason Cloud Aug 16 '12 at 19:03
  • 1
    Not exactly, you have to work with view matrix. There are three matrices in OpenGLE ES 1 - model (or world) matrix is used for transforming an individual node or object within the world. View matrix is for transforming the world relative to the camera view, so that the objects that are supposed to be visible as determined by the camera are transformed into the view frustum. The projection matrix is responsible for "flattening" the visible frustum and fitting it to the device coordinates of the screen. – Tutankhamen Aug 17 '12 at 03:44
  • Not everyone has time to read an online book, offer an example. – michaelsnowden Mar 03 '14 at 03:43