How can I detect (and interpret) mouse wheel events? I would like to use it for zoom in/out, but havent seen a sample that uses it.
Using mouse wheel


You can use input::GetMouseMoveWheel() to capture the wheel delta. For example, set zoom variable to zoom += delta
Alternatively you can use ‘E_MOUSEWHEEL’ event (see
http://urho3d.github.io/documentation/HEAD/_event_list.html
).
You can also check how the Editor handles zoom.

Thanks, worked using input::GetMouseMoveWheel, but got a weird problem, when I zoom in, I can get close to floor, but when zoom out, almost inmediatly I get a black screen.
This is my camera creation code:
[quote]
target = new Urho3D::Node(context
);
_cameraNode =
target->CreateChild(“cam”); //new Urho3D::Node(context
);
camera = _cameraNode->CreateComponent<Camera>();
camera->SetFarClip(300.0f);
camera->SetOrthographic(true);[/quote]
And zoom code, in scene update handler:
delta = GetSubsystem<Urho3D::Input>()->GetMouseMoveWheel();
zoom = camera->GetZoom()+delta;
camera->SetZoom(zoom);
Initially I thought that it was the far clip distance, increased it until 10000, same result.

You might need to ‘scale’ delta to customize zoom speed. Try to multiply delta by 0.01 (or divide by 100).