Say I am using the below code to setup a projection view :

float aspect = fabsf(self.view.bounds.size.width / self.view.bounds.size.height);
GLKMatrix4 projectionMatrix = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(65.0f),     aspect, 4.0f, 10.0f);    
self.effect.transform.projectionMatrix = projectionMatrix;

If I now wanted to make to camera look at a specific point in my scene, how would I best achieve this ? Currently I am changing the modelViewMatrix to move the object so it is centred in view, but am wondering if I could achieve the same by manipulating the projectionMatrix somehow.

有帮助吗?

解决方案

As any good 3D programming basics tutorial (like maybe this one) will tell you...

  • A Model matrix converts vertex coordinates from model space (the coordinate space in which your mesh is specified, which is usually ignorant of where you want to place the model in the scene) to world space (the conceptual space of your scene).
  • A View matrix converts from world space to eye space (that is, a coordinate system relative to the "camera" that vies your scene).
  • A Projection matrix converts from eye space to clip space (a -1.0 to 1.0 cube representing your screen plus some depth, which the GPU then converts into pixel space).

The Projection matrix already works in terms relative to the viewpoint -- you've already fixed where the eye is and what point it's looking at, so the projection matrix only changes your field of view angle, aspect ratio, and near and far clipping planes. If you want to change the point you're looking at, specify a different LookAt transform for your View matrix.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top