PDA

View Full Version : using gluLookup to zoom



macsam
06-14-2017, 02:12 AM
Hi

I am trying to Zoom in and out of the model using the mouse wheel. Nothing happens except when the camera position Z coordinate changes from positive to negative when the model swaps from front to back and vice versa. I would expect to see the model getting smaller as the camera moves away from the model.

Any help gratefully appreciated





BOOL bError ;
unsigned int ui;
GLfloat fXc, fYc, fZc,
fXt, fYt, fZt,
fXu, fYu, fZu,//up vector
fHorizOntalDistance;;


#define PI 3.14159265358979323846

bError = 0;
ui = 1;


glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);


glPushMatrix(); //this must have a corresponding glPopMatrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();


fHorizOntalDistance = glfZoom;// *(GLfloat)cos(rad(flatitude));
= fHorizOntalDistance * (GLfloat)cos(rad(flongitude));//this is opengl equivilant to the y axis in normal coords

fXc = 0.0;
fYc = 0.0;
fZc = fHorizOntalDistance;

fXt = 0.0f;
fYt = 0.0f;
fZt = 0.0f;

fXu = 0.0f;
fYu = 1.0f;
fZu = 0.0f;


gluLookAt(fXc, fYc, fZc, fXt, fYt, fZt, 0.0f, 1.0f, 0.0f);




if (uiTriPointer > 1)//(&& cDisplayRockFace == 'y')// && cUsePointCloud == 'n')
{
glIndexi(BLUE_INDEX);
do
{
//glPushMatrix();//apr 14
glCallList((GLuint)(icTrianglesConstant + 100 + ui++));// icTrianglesConstant[ui]);//MMGLTRIANGLE);
//glPopMatrix();//apr 14
} while (((UINT)ui - 1) * 30000 < uiTriPointer);
}




glIndexi(RED_INDEX);

glCallList(MMGLPOINTCLOUD);






glFlush();
bError = SwapBuffers(ghDC);// SWAPBUFFERS;
//if (bError == FALSE)
// bError = FALSE;
cDrawingInProgress = 'n';

mhagain
06-14-2017, 03:03 AM
What's your projection matrix?

macsam
06-14-2017, 03:13 AM
What's your projection matrix?

Thanks:




GLdouble gdEmin,
gdEmax,
gdNmin,
gdNmax,
gdZmin,
gdZmax,
gdMaxDim;

OrthoLimitsM(&gdEmin, &gdEmax, &gdNmin, &gdNmax, &gdZmin, &gdZmax);
gdMaxDim = 1.0f * SetZoom();


gdEmin = gdEmin - gdMaxDim;
gdEmax = gdEmax + gdMaxDim
gdNmin = gdNmin - gdMaxDim
gdNmax = gdNmax + gdMaxDim;
gdZmin = gdZmin - gdMaxDim;
gdZmax = gdZmax + gdMaxDim

glOrtho(gdEmin, gdEmax, gdNmin, gdNmax, gdZmin, gdZmax);

macsam
06-14-2017, 04:34 AM
The silence is deafening :)

mhagain
06-14-2017, 04:36 AM
After only an hour and a half? Sorry, I have a job to be doing as well.

macsam
06-14-2017, 05:06 AM
Thanks, I appreciate your help.

macsam
06-14-2017, 05:19 AM
I should have said, glfZoom increases and decreases with the mouse wheel.

GClements
06-14-2017, 07:03 AM
glOrtho(gdEmin, gdEmax, gdNmin, gdNmax, gdZmin, gdZmax);


The phenomenon of objects appearing to grow larger as they move closer to the viewer is specific to perspective projections. It doesn't occur with an orthographic projection.

macsam
06-14-2017, 08:11 AM
The phenomenon of objects appearing to grow larger as they move closer to the viewer is specific to perspective projections. It doesn't occur with an orthographic projection.

Thank you. Can an orthographic view be zoomed into using another method? I do not want perspective in the view, hence me using ortho.

Regards

MacSam

mhagain
06-14-2017, 09:16 AM
You can add a glScalef to your projection matrix. Since you're using old OpenGL with it's matrix stack this would be an appropriate way of doing it.

macsam
06-14-2017, 10:46 AM
You can add a glScalef to your projection matrix. Since you're using old OpenGL with it's matrix stack this would be an appropriate way of doing it.

Thank you. I will be using VBO's in the near future because of memory problems I am having.

mhagain
06-14-2017, 12:27 PM
You can use VBOs with the matrix stack. Or add scaling to your own custom matrices. Or use your own custom matrices with glBegin/glEnd code. Or various combinations of some, all or none of these, any of which may or may not also include shaders.

For some reason the idea seems to exist (and it's not just you, I've seen this elsewhere) that VBOs and shaders are modern OpenGL features, and that if you use them you have to go 100% modern OpenGL with everything.

That's not actually the case at all. Both are actually very very old features, and you're free to mix-and-match them with other old features as you see fit.

macsam
06-16-2017, 12:13 PM
You can use VBOs with the matrix stack. Or add scaling to your own custom matrices. Or use your own custom matrices with glBegin/glEnd code. Or various combinations of some, all or none of these, any of which may or may not also include shaders.

For some reason the idea seems to exist (and it's not just you, I've seen this elsewhere) that VBOs and shaders are modern OpenGL features, and that if you use them you have to go 100% modern OpenGL with everything.

That's not actually the case at all. Both are actually very very old features, and you're free to mix-and-match them with other old features as you see fit.

Thank you. I am sure it will not be the last time I am here.