I cant get right set of lookat() bec it was inverse. For example, there are rectangle cube and cone: This is my init opengl codes with C#. using init opengl, then it should look like
1 2
/|–/|
3 5 4 |6
/\ |/_ |/
() 7 8
When I am using zoom function,then it should look this:
8 7 ()
/|–/| /
6 4 5 |3
|/_ |/
2 1
public OurView() : base()
{
GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
GL.glShadeModel(GL.GL_SMOOTH);
GL.glClearDepth(1.0f);
GL.glEnable(GL.GL_DEPTH_TEST);
GL.glDepthFunc(GL.GL_LEQUAL);
GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.gluPerspective(0.0f, 1.0f, 3.0f, 10.0f);
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glLoadIdentity();
GL.glScalef(0.6f,0.6f,0.6f);
}
If I use “z” keyboard for zoom in, then
public void glZoomIn()
{
m_fDistance -= 1.0f;
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
//GL.glMatrixMode(GL.GL_MODELVIEW);\ I tried this part but it wont work well
//GL.glLoadIdentity(); /
GL.gluPerspective(m_fDistance , 1.0f, 1.0f, 100.0f);
GL.glScalef(0.6f,0.6f,0.6f);
GL.gluLookAt(0.0f, 0.0f, 2.0f,0.0f, 0.0f, 0.0f,0.0f, 1.0f, 0.0f);
}
If I use “x” keyboard for zoom out, then
public void glZoomOut()
{
m_fDistance -= 1.0f;
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
//GL.glMatrixMode(GL.GL_MODELVIEW);\ I tried this part but it wont work well
//GL.glLoadIdentity();
GL.gluPerspective(m_fDistance , 1.0f, 1.0f, 100.0f);
GL.glScalef(0.6f,0.6f,0.6f);
GL.gluLookAt(0.0f, 0.0f, 2.0f,0.0f, 0.0f, 0.0f,0.0f, 1.0f, 0.0f);
}
If you notice those codes that cause the problems, please correct it.
Thanks in Advance