gluLookAt and CoreMotion - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: gluLookAt and CoreMotion (/thread-7976.html)
gluLookAt and CoreMotion - MikeD - Aug 11, 2010 01:37 PM
I've been interested in having a play with CoreMotion and using it to look around inside a 3D scene. I've used gluPerspective to set up my projection and I'm rendering a number of coloured cubes so that I can see how I can move around the scene using gluLookAt.
What I'm getting stuck on is how to best use the information I'm getting from CoreMotion to change what I'm seeing in my scene. The effect I'm after is that the iPhone screen is like a window into my 3D scene, and as I move the phone around, the scene changes to match i.e. I can look to my left and see the cubes to my left, or above.
My matrix math is rusty and I'm really not sure how to make use of Quaternions, so I'm hoping someone more experienced in this area could give me a nudge in the right direction.
At the moment I'm using the rotationMatrix that CMAttitude provides and multiplying that with the ModelView matrix. The scene is moving, but the movement seems reversed to what I would expect. I started with this approach and once working was planning to move onto using gluLookAt, well, that was the plan anyway.....
What I'd really like to do us use gluLookAt with an eye location of say 0, 0, 0 and for the location I'm looking at to be adjusted by the movement of the device.
My sample project is built on top of the OpenGL ES template in Xcode and my current render method using the matrix approach looks like this:
Any help, suggestions or nudges in the right direction would be really appreciated