Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualJoey P

Posted 30 June 2012 - 03:15 PM

Hi all,

First post here.In my Renderer class I have these vars:

[source lang="java"]   // Direction of camera   private float lookX = 0.0f;   private float lookY = 1.0f;   private float lookZ = 0.0f;     // Camera tilt   private float upX = 0.0f;   private float upY = 0.0f;   private float upZ = 1.0f;     // Position of camera   private float eyeX = 0.0f;   private float eyeY = 0.0f;   private float eyeZ = 0.0f;[/source]
Then to set the view matrix I use:

[source lang="java"]Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);[/source]

This all works perfectly well if eyeX, eyeY, and eyeZ are all set to 0.  I can change the look vector and up vector when I want to rotate the camera position around and view the world.  Works beautiful.

The problem is once I change the eyeX, eyeY, and eyeZ to some other arbitrary values so I can view my meshes from some place other than the origin, the rotations no longer work as expected.  When I rotate the camera, all the meshes stay in view in front of me and just follow me.

What is it I need to do differently?

Thanks for any insights.

#1Joey P

Posted 30 June 2012 - 03:14 PM

Hi all,

First post here.In my Renderer class I have these vars:

[source lang="java"]   // Direction of camera   private float lookX = 0.0f;   private float lookY = 1.0f;   private float lookZ = 0.0f;      // Camera tilt   private float upX = 0.0f;   private float upY = 0.0f;   private float upZ = 1.0f;      // Position of camera   private float eyeX = 0.0f;   private float eyeY = 0.0f;   private float eyeZ = 0.0f;[/source]
Then to set the view matrix I use:

[source lang="java"]Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);[/source]

This all works perfectly well if eyeX, eyeY, and eyeZ are all set to 0.  I can change the look vector and up vector when I want to rotate the camera position around and view the world.  Works beautiful.

The problem is once I change the eyeX, eyeY, and eyeZ to some other arbitrary values so I can view my meshes from some place other than the origin, the rotations no longer work as expected.  When I rotate the camera, all the meshes stay in view and just follow me.

What is it I need to do differently?

Thanks for any insights.

PARTNERS