How can I change view or camera by using mouseMove?

Hi,
I want to change view or camera by mouse movement with mouse button pressing.Moreover I want to make pan/ zoom by mouse movement. Could you please give me detail or share any example about this subject?

The ability to do that is available on the MouseSceneControl component, although by default it usually only gets enabled when switching into the Debug mode via the d key. If you have the control available just callling control->setEnabled(true) will turn it on.

Depending on your code the MouseSceneControl might already be in your scene. If not it can be added via

auto mouseControl = std::make_shared<MouseSceneControl>();
mouseControl->setDevice(viewer->getMouseDevice());
mouseControl->setSceneManager(sceneManager);
mouseControl->setEnabled(true);
scene->addControl(mouseControl);

Or it also gets created in the via “SimulationUtils::createDefaultSceneControl()” you’d have to extract it from there with something like

auto manager = std::make_shared<SimulationManager>();
...
std::shared_ptr<Entity> controls = 
        SimulationUtils::createDefaultSceneControl(manager);
if (auto mouseControl = mouseAndKeyControls->getComponent<MouseSceneControl>()) {
	mouseControl->setEnabled(true);
}

Hope this helps

1 Like

Harald,
Thank you. Second option worked.