how to make zoom in with mouse ?

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
umen
Posts: 54
Joined: Fri Aug 08, 2008 11:10 am

how to make zoom in with mouse ?

Post by umen »

Hi
im really begginer , how can i do simple zoom in out with the mouse ?
im reading the document and the fourm with out any example about simple zoom in / out
soulless
Posts: 25
Joined: Mon Jan 11, 2010 6:06 am

Post by soulless »

In the mouse event just change the field of view of the camera.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

or you could just move your camera towards its target with a certain offset based on the delta-value of your scrolling wheel
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

soulless wrote:In the mouse event just change the field of view of the camera.
Copy this into your event receiver:

Code: Select all

//check mouse events
if(irr::EET_MOUSE_INPUT_EVENT == event.EventType)
{
	//check mouse wheel
	if (irr::EMIE_MOUSE_WHEEL == event.MouseInput.Event)
	{
		irr::scene::ICameraSceneNode* const camera = smgr->getActiveCamera();

		//zoom camera
		irr::f32 newFOV = camera->getFOV();

		if (event.MouseInput.Wheel < 0)
			newFOV = irr::core::min_(newFOV + irr::core::DEGTORAD, irr::core::PI*0.5f);
		else
			newFOV = irr::core::max_(newFOV - irr::core::DEGTORAD, irr::core::PI*0.0125f);

		camera->setFOV(newFOV);

		return true;
	}
}
"Whoops..."
Post Reply