Where can I find the gluLookAtf function for OpenGL ES?

I have searched for the gluLookAtf function,but can not find it. Does anyone know where it is?

There is no such method in ES, either in standard Open GL spec either. However, maybe this can help you
void LookAt(TVector aPosition, TVector aLookAt, GLfloat aRoll)
{
TVector up, forward, right;
TReal trg = 0;
Math::Sin(trg, aRoll);
up.iX = trg;
Math::Cos(trg, aRoll);
up.iY = -trg;
up.iZ = 0;

``````forward.iX = aLookAt.iX - aPosition.iX;
forward.iY = aLookAt.iY - aPosition.iY;
forward.iZ = aLookAt.iZ - aPosition.iZ;

forward.Normalize();

right = TVector::CrossProduct(up, forward);
right.Normalize();

up = TVector::CrossProduct(right, forward);
up.Normalize();

// Start building the matrix. The first three rows contain the
// basis vectors used to rotate the view to point at the look-at point.
MakeIdentity(&iViewMatrix[0][0]);

iViewMatrix[0][0] =  right.iX;
iViewMatrix[1][0] =  right.iY;
iViewMatrix[2][0] =  right.iZ;
``````

// iViewMatrix[3][0] = -aPosition.iX;

``````iViewMatrix[0][1] =  up.iX;
iViewMatrix[1][1] =  up.iY;
iViewMatrix[2][1] =  up.iZ;
``````

// iViewMatrix[3][1] = -aPosition.iY;

``````iViewMatrix[0][2] = -forward.iX;
iViewMatrix[1][2] = -forward.iY;
iViewMatrix[2][2] = -forward.iZ;
``````

// iViewMatrix[3][2] = -aPosition.iZ;
}

Thanks, do you think I can use this method to solve the problem that I have with implementing a movement ,which makes it possible to find the position in 3d space? My problem is described in detail here:

http://www.newlc.com/en/forum/how-get-p … -opengl-es

Here is my porting for objective C.
Hope you enjoy it:

static void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez,
GLfloat centerx, GLfloat centery, GLfloat centerz,
GLfloat upx, GLfloat upy, GLfloat upz)
{
GLfloat m[16];
GLfloat x[3], y[3], z[3];
GLfloat mag;

``````/* Make rotation matrix */

/* Z vector */
z[0] = eyex - centerx;
z[1] = eyey - centery;
z[2] = eyez - centerz;
mag = sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
if (mag) {          /* mpichler, 19950515 */
z[0] /= mag;
z[1] /= mag;
z[2] /= mag;
}

/* Y vector */
y[0] = upx;
y[1] = upy;
y[2] = upz;

/* X vector = Y cross Z */
x[0] = y[1] * z[2] - y[2] * z[1];
x[1] = -y[0] * z[2] + y[2] * z[0];
x[2] = y[0] * z[1] - y[1] * z[0];

/* Recompute Y = Z cross X */
y[0] = z[1] * x[2] - z[2] * x[1];
y[1] = -z[0] * x[2] + z[2] * x[0];
y[2] = z[0] * x[1] - z[1] * x[0];

/* mpichler, 19950515 */
/* cross product gives area of parallelogram, which is &lt; 1.0 for
* non-perpendicular unit-length vectors; so normalize x, y here
*/

mag = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
if (mag) {
x[0] /= mag;
x[1] /= mag;
x[2] /= mag;
}

mag = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
if (mag) {
y[0] /= mag;
y[1] /= mag;
y[2] /= mag;
}
``````

#define M(row,col) m[col*4+row]
M(0, 0) = x[0];
M(0, 1) = x[1];
M(0, 2) = x[2];
M(0, 3) = 0.0;
M(1, 0) = y[0];
M(1, 1) = y[1];
M(1, 2) = y[2];
M(1, 3) = 0.0;
M(2, 0) = z[0];
M(2, 1) = z[1];
M(2, 2) = z[2];
M(2, 3) = 0.0;
M(3, 0) = 0.0;
M(3, 1) = 0.0;
M(3, 2) = 0.0;
M(3, 3) = 1.0;
#undef M
glMultMatrixf(m);

``````/* Translate Eye to Origin */
glTranslatef(-eyex, -eyey, -eyez);
``````

}

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.