Camera Default Settings

Anonymous 9 years ago 0
This discussion was imported from CodePlex

przem321 wrote at 2012-01-15 07:03:


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?

ddklo wrote at 2012-01-15 12:07:

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.

przem321 wrote at 2012-01-15 22:39:

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.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?


objo wrote at 2012-01-16 05:55:

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?

przem321 wrote at 2012-01-16 07:43:

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. 

objo wrote at 2012-01-16 08:39:

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!

objo wrote at 2012-01-19 11:01:

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.