How to prevent the camera distance from resetting when using mouse orbiting

9 views (last 30 days)
I have a set of 3 dimensional voxel data that I am currently visualizing using isosurface. Unfortunately, it is hard to get a sense of depth of the data with the default 'orthographic' projection. Therefore my goal is to use the 'perspective'projection with a relatively high FOV. Unfortunately though, matlab seems to not properly support this video game style projection. With the Commands
camproj('perspective')
camva('manual')
camva(50);
I am able to get a perspective projection, Matlab doesn't adjust the distance to the plot, so I have to manually get the camera closer by using
zoom=7;
axd=gca;
axd.CameraPosition=axd.CameraTarget+(axd.CameraPosition-axd.CameraTarget)/zoom;
Now I have the image I wanted, but as soon as I start panning using the mouse tools, matlab immediately resets the camera position to default. If I set it to 'manual', I am not able to use the mouse panning at all. So far the only workaround I have come up with is setting up a callback after the mouse rotation:
h = rotate3d;
h.ActionPostCallback = @mycallback;
h.Enable = 'on';
where mycallback looks like this:
function mycallback(obj,event_obj)
axd=gca;
axd.CameraPosition=axd.CameraTarget+(axd.CameraPosition-axd.CameraTarget)/7;
axd.CameraTarget=axd.CameraTarget.*[1 1 0];
But this is really not great since the camera positition already resets during mouse orbiting, so you have a tiny plot in the center of the screen that is barely visible during orbiting, which resets only after you finished . Is there any way to fix this properly?
What I want:
What it looks like during orbiting:

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!