[QUOTE=Dark Photon;1241542]Picture what you’re trying to do, and then it becomes much simpler.
Where can the object be in EYE-SPACE? How big is it in EYE-SPACE? That tells you the volume of space you need to make sure you have in your view frustum, right?
Think about how you can use the makeFrustum() function on the Song Ho Ann page I mentioned (this is essentially gluPerspective). How can you compute those parameters? Write a formula in terms of the size of the object.[/QUOTE]
I have a project that must set the cam automatically for adapting to only dataset that i fix.
I think that the problem was how define the parameter of glPerspective or glFrustum, in particular the parameter “near” and “far”. Is it right?
I have searched on the web, on forum and on books but i haven’t find a solution for my problem.
I also read * OpenGL Transformation (Song Ho Ahn)…could you help me to resolve my problem?if i don’t resolve that, i can’t go to next request of the project.
If you want, i could send you information and documentation by mail.
the function MAKEFRUSTUM is
void makeFrustum(double fovY, double aspectRatio, double front, double back)
{
const double DEG2RAD = 3.14159265 / 180;
double tangent = tan(fovY/2 * DEG2RAD); // tangent of half fovY
double height = front * tangent; // half height of near plane
double width = height * aspectRatio; // half width of near plane
// params: left, right, bottom, top, near, far
glFrustum(-width, width, -height, height, front, back);
}
the parameter FRONT & BACK are the same of NEAR & FAR? I use glFrustum and i center my object with these parameters:
glFrustum(heightMap->minX-heightMap->xcenter, heightMap->maxX-heightMap->xcenter, heightMap->minY-heightMap->ycenter, heightMap->maxY-heightMap->ycenter, heightMap->near, heightMap->far);
minX=0.0;
maxX=nrowscellsize;
minY=0.0;
maxY=ncolscellsize;
far = 500;
near = 100;
xcenter = (minX + maxX)/2;
ycenter = (minY + maxY)/2;
zcenter = (far+near)/2;
as you could watch, i fix the parameter near & far manually…but the project expressly ask that the camera’sparameters must set automatically.
Help me please.
Thanks