PDA

View Full Version : How to convert vrml viewpoint to glulookat?



berezin35
04-27-2000, 11:34 PM
Does anyone know how to convert vrml viewpoint which has to following attributes:

fieldOfView fov_angle
orientation x, y, z, angle
position x, y, z

to a gluLookAt, which composes of position,
aim, and up vectors.

Any help or web page link will be much appreciated. Many thanks.

Relic
04-30-2000, 09:17 AM
>fieldOfView fov_angle
>orientation x, y, z, angle
>position x, y, z

Here is what I did in my VRML loader:

void ViewpointDisplay(VIEWPOINT *viewpoint)
{
if (viewpoint != NULL)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(viewpoint->fieldOfView * RAD2DEG, dAspect, zNear, zFar);
glRotatef(-viewpoint->orientation[3] * RAD2DEG, viewpoint->orientation[0], viewpoint->orientation[1], viewpoint->orientation[2]);
glTranslate(-viewpoint->position[0],-viewpoint->position[1], -viewpoint->position[2]);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
}