How to do camera zooming?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

How to do camera zooming?

Post by wsw1231 »

Code: Select all

case EMIE_MOUSE_WHEEL:
					{						
						if (event.MouseInput.Wheel == -1.0f)
							camFOV+=0.1f;
						else if (event.MouseInput.Wheel == 1.0f)
							camFOV-=0.1f;

						camera->setFOV(camFOV);
					} break;
I have used the above code to handle the camera zooming but something weird will happen.

If I wheel up/down too much, the nodes in the scene will be distorted and inverted.

How can I prevent this from happening?
kazymjir
Posts: 727
Joined: Sat Feb 20, 2010 4:05 pm
Location: Munich, Bayern

Post by kazymjir »

I not programmer Irrlicht for long time,
but I can guess that can be something with 0.1 value.

Check this code:
http://ideone.com/d7APU

PC processor have troubles with computing values such as 0.1.
MATLAB can without problem compute those values without problem, but C++ can't without additional math libraries.

I am not sure, but this can be your problem.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: How to do camera zooming?

Post by Seven »

wsw1231 wrote:

Code: Select all

case EMIE_MOUSE_WHEEL:
{						
      if (event.MouseInput.Wheel == -1.0f)  camFOV+=0.1f;
      else if (event.MouseInput.Wheel == 1.0f) camFOV-=0.1f;
 
      // clip the value
      #define maxFOV 10.0f
      #define minFOV 1.0f
      if (camFOV < minFOV) camFOV = minFOV;
      if (camFOV > maxFOV) camFOV = maxFOV;
     
      camera->setFOV(camFOV);
} break;
I have used the above code to handle the camera zooming but something weird will happen.

If I wheel up/down too much, the nodes in the scene will be distorted and inverted.

How can I prevent this from happening?
maybe just set up a min and a max value?
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Post by polylux »

I'll let that guy do the explanation -> :roll:
Oh, and then I'd go with Seven's reply.
beer->setMotivationCallback(this);
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Re: How to do camera zooming?

Post by wsw1231 »

Seven wrote:
wsw1231 wrote:

Code: Select all

case EMIE_MOUSE_WHEEL:
{						
      if (event.MouseInput.Wheel == -1.0f)  camFOV+=0.1f;
      else if (event.MouseInput.Wheel == 1.0f) camFOV-=0.1f;
 
      // clip the value
      #define maxFOV 10.0f
      #define minFOV 1.0f
      if (camFOV < minFOV) camFOV = minFOV;
      if (camFOV > maxFOV) camFOV = maxFOV;
     
      camera->setFOV(camFOV);
} break;
I have used the above code to handle the camera zooming but something weird will happen.

If I wheel up/down too much, the nodes in the scene will be distorted and inverted.

How can I prevent this from happening?
maybe just set up a min and a max value?
When the wheel is up, it is fine.
But when the wheel is down, the view will still turn upside down finally. :(
elfuz
Posts: 14
Joined: Wed Oct 13, 2010 10:20 am

Post by elfuz »

this code should do the trick. I've had a same problem in the past (although not with irrlicht).

Maybe try outputting the zoom variable camFOV to the screen and see at what value it disorts. Put that value as the minvalue and you're set.
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

OK thank you everyone :D
Post Reply