AB4D Forum
how to reset mouse or camera control changes - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.PowerToys (https://forum.ab4d.com/forumdisplay.php?fid=9)
+--- Thread: how to reset mouse or camera control changes (/showthread.php?tid=4210)



how to reset mouse or camera control changes - jasza - 08-31-2020

I have a bunch of boxes which i programatically select, and move my _targetPositionCamera to focus on using this line of code: 


        _targetPositionCamera.MoveTargetPositionTo(obox.CenterPosition, 1000)


It works really well and the animation helps the user understand where they are jumping to.

However when the user manually scrolls the view left or right using the mouse or the control panel, the line of code above doesn't bring the selected box into view because the control panel or mouse has shifted the focus so its no longer central. 

There is no " .MoveTargetPositionTo" on the mouse and control panel cameras. how do I reset them to align with the  _targetPositionCamera?

Note: In my constructor I have assigned:
 _cameraControlPanel.TargetCamera = _targetPositionCamera        
_mouseCameraController.TargetCamera = _targetPositionCamera


RE: how to reset mouse or camera control changes - abenedik - 09-01-2020

Each camera also has an Offset property that is changed when the camera is moved - it also changes the actual target position.

To fix your problem, before calling "MoveTargetPositionTo" add Offset to TargetPosition and reset the Offset:

_targetPositionCamera.TargetPosition += _targetPositionCamera.Offset;
_targetPositionCamera.Offset = new Vector3D(0, 0, 0);