Jump to content
  • Advertisement
Sign in to follow this  
one mind

glortho, zooming

This topic is 5475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have made a simple modeller with 4 vieports and i am trying to figure out how to zoom my cameras. For the perspective view, i just increase or decrease the glulookat eye and origin. I am having a problem with the orthos views. This is what i am doing so far Gl.glOrtho(-100/zoom2, 100/zoom2, -100*half_height/half_width/zoom2, 100*half_height/half_width/zoom2,-100/zoom2,100/zoom2); zoom2 is equal to 1 at the start and changes by 0.001 when the mouse moves up and down. This is working well except, when i zoom in too far everything disappears and when i zoom out to the point everything is tiny, i keep on zooming but everything gets bigger but in reverse. Any help would be great Thanks :)

Share this post


Link to post
Share on other sites
Advertisement
You probably don't need to divide the Z coordinates by zoom2. All this does is restrict the range of visible depths.

Also, beware of what happens when zoom2 goes below 0.

Share this post


Link to post
Share on other sites
This is what I use for zoom:


void SetFov(float aFov)
{
GFXAPI().ResizeScene(GAME.Options().mScreenRes.width, GAME.Options().mScreenRes.height, aFov);
}

void TGfxApi::ResizeScene(int aWidth, int aHeight, float aFov)
{
ASSERT(Invariant());
ASSERT(aHeight>0 && aWidth>0);

glViewport(0, 0, aWidth, aHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// Calculate the aspect ratio of the window:
gluPerspective(aFov, aWidth/(float)aHeight, 1, GAME.Options().mViewDistance);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

ASSERT(Invariant());
}



Where fov of 90 = normal, fov of <90 = zoom in.

Share this post


Link to post
Share on other sites
Its not so much a real zoom i'm looking for, but a way to make the seen bigger and smaller. Perspectvie was easy because u just move the eye forwards and backwards and everything gets biggers or smaller on its own.
I'm looking for the same effect with orth. Moving the eye doesn't effect anything size so i have to scale the whole ortho volume.
Just looking for a good way to do that :)

Thanks for the code

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!