PDA

View Full Version : Using Camera from 3ds



Seidel
02-13-2008, 07:15 AM
Im loading frames from a .VUE file (Old formats from 3ds4 for dos, as i dont know sdlfk about max).

gettjamem(objnr,i);
printf("================================================== ======================\n");
sscanf(line,"%s %f %f %f %f %f %f",&tmpline,&cameras[objnr].source_x[i],&cameras[objnr].source_y[i],&cameras[objnr].source_z[i],
&cameras[objnr].target_x[i],&cameras[objnr].target_y[i],&cameras[objnr].target_z[i]);

as I now have the cordinates to the camera, i wish to imlpement these in OpenGL. Do anyone have tip for me? Or do i need to do all the matrix calculations for these, as i did in dos?

camera info is:
Camera (48.235291mm)
Position: X:-94.481041 Y:-85.396332 Z:36.338867
Target: X:-9.084715 Y:-188.962082 Z:154.440155
Bank angle: 0 degrees
Near 0 Far 1000

- Seidel

songho
02-14-2008, 07:15 PM
I don't know how to translate a camera's focal length to OpenGL's FOV. But, the viewing angle and near/far values of camera can be set by using glFrustum(), or gluPerspective(). These calls will modify the "GL_PROJECTION" matrix for you.
For example;


glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (float)(w)/h, 1.0f, 1000.0f); // FOV, AspectRatio, NearClip, FarClip
The first param is the Field Of View (FOV) of the camera.

For the camera position and target, you need to call gluLookAt(). This call will modify "GL_MODELVIEW" matrix for you, for example;


glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(-94.5, -85.4, 36.3, -9.1, -189.0, 154.4, 0, 1, 0); // eye(x,y,z), focal(x,y,z), up(x,y,z)