Camera Default Settings

Developer
Jan 15, 2012 at 7:03 AM

Hi,

one more issue: it would be nice to provide a way to set up own defaults for the camera which can be then called by the ResetCamera function. Of course, one can write an own Reset function just by setting the camera Props. So far so good, nice, but since the CameraResetGesture always calls the CameraHelper.ResetCamera(...) and these values are hard coded, there is no way to use the gesture for an own default camera. Or am I wrong and there is a way to do that?

Jan 15, 2012 at 12:07 PM

I'm not that familiar with the Gestures, but currently we are solving this by removing all input bindings from the CameraController class and adding our own in code (for some reason mouse wheel scrolling is still active). You can find the default ones in the Generic.xaml resource dictionary. Not sure if there is a better way, but it appears to be working.

Developer
Jan 15, 2012 at 10:39 PM

Well, removing all bindings and adding own functions is a solution... which causes a lot of overhead to a in general very well defined camera. I wish one could replace particular bindings, such like that:

            view.CameraController.CommandBindings.RemoveAt(5);
            view.CameraController.CommandBindings.Add(new CommandBinding(CameraController.ResetCameraCommand,
             (s, ea) =>
             {
                 view.Camera.Position = new Point3D(4, 2, 16);
                 view.Camera.LookDirection = new Vector3D(-4, -2, -16);
                 view.Camera.UpDirection = new Vector3D(0, 1, 0);
             }
             ));

This only works well if one replaces the binding for CameraController.ResetCameraCommand, but in order to do so one has to know that it is at index #5 in the list. Well, this is not the nicest solution I guess... Is there any way to do it better?

 

Coordinator
Jan 16, 2012 at 5:55 AM

Should find a solution where it is not necessary to change the command bindings.

Idea: could we add a "DefaultCamera" property in the CameraController and HelixViewport3D. The Reset command could then copy the properties of the "DefaultCamera" to the current camera (or clone the default camera and assign it to the current camera).

do you see other solutions?

Developer
Jan 16, 2012 at 7:43 AM

Yes, a DefaultCamera property was the first thing I was thinking about too. This is a reasonable solution. 

On the other hand, replacing bindings might be also a useful solutions for those who really know what they are doing and wish to customize their camera controller. But I am not enough into the commanding to say how to do that properly. I will first need to read all this stuff here: http://msdn.microsoft.com/en-us/library/ms752308.aspx which I have no time for at the moment. 

Coordinator
Jan 16, 2012 at 8:39 AM

the current implementation makes it easy to change the gestures, but more work to change the command bindings.  

Let us know if you can find a better architecture/pattern to use here!

Coordinator
Jan 19, 2012 at 11:01 AM

added a "DefaultCamera" property in the HelixViewport3D. If this is defined, it will be used for the initial camera position and to reset the camera.