[Bf-committers] Camera view navigation rant

Campbell Barton ideasman42 at gmail.com
Fri May 13 20:23:02 CEST 2011


Patch for camera view locking.
Access from View panel under the "Lock to Cursor" button,

http://codereview.appspot.com/4528068/

On Wed, Apr 27, 2011 at 6:22 AM, Damir Prebeg <blend.factory at gmail.com> wrote:
> Actually, IMHO Blender has the best 3D view navigation on the market
> and I simply love it. I realize that and I cry every time when I have
> to manipulate some other 3D App views.
> I don't mind to have a set of widgets that would help, but current
> shortcut key based navigation is priceless.
> Only thing that I would like to have is ability to manipulate with cam
> (or object) view in the same way as I manipulate with every other
> view.
>
> On 27 April 2011 08:01, Daniel Salazar - 3Developer.com
> <zanqdo at gmail.com> wrote:
>> Yes Ive been thinking in something like that, I think the navigation
>> is overall too hard and hotkey oriented, lots of local rotations and
>> grabs without the widgets there to help. I wonder if we could design a
>> set of in camera view widgets?
>>
>> Daniel Salazar
>> 3Developer.com
>>
>>
>>
>> On Tue, Apr 26, 2011 at 11:59 PM, Damir Prebeg <blend.factory at gmail.com> wrote:
>>> How bout a pin icon in one corner of camera view so when activated,
>>> cam view (or any object view) would act as regular view?
>>> And ALT could be a shortcut key that would temporary glue cam to the
>>> view (Alt+MMB would rotate cam, CTRL+ALT+MMB would move camera forward
>>> or backward and SHIFT+ALT+MMB would pan camera?)
>>>
>>> On 27 April 2011 07:36, Mats Holmberg <mats.holmberg at 2me.fi> wrote:
>>>> And if this would work for the camera, then it should also work for anything else (lamps mainly). The script didn't work for me on osx - the view is not locked to the camera view and trackballing around loses the camera lock alltogether =)
>>>>
>>>> Cheers,
>>>> -mats
>>>>
>>>> On 27.4.2011, at 1.39, Daniel Salazar - 3Developer.com wrote:
>>>>
>>>>> @dfelinto(pto): nope, it would need to *stay* in camera view when panning
>>>>> and dollying around :)
>>>>>
>>>>> Daniel Salazar
>>>>> 3Developer.com
>>>>>
>>>>>
>>>>>
>>>>> On Tue, Apr 26, 2011 at 12:58 PM, Dalai Felinto <dfelinto at gmail.com> wrote:
>>>>>>> Below you can find some code for (...) Lock camera to view.
>>>>>> Isn't this what Ctrl+Alt+Numpad0 do? (align camera to view -- which
>>>>>> even takes care of non-perspective views)
>>>>>>
>>>>>> On my understanding what people are ranting is for the lack of options
>>>>>> to move while "inside" the camera mode.
>>>>>>
>>>>>> --
>>>>>> Dalai
>>>>>>
>>>>>> 2011/4/26 bartius crouch <bartius.crouch at gmail.com>:
>>>>>>>> Also a lock camera to view option would be great so we can just move
>>>>>>>> the camera like we move any other viewport
>>>>>>>
>>>>>>> Like Campbell said, that isn't very hard to do in python. Below you can find
>>>>>>> some code for it.
>>>>>>> Copy the text below into the text-editor, Run Script (alt+P), go to 3d-view,
>>>>>>> search (spacebar) for Lock camera to view.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> import bpy
>>>>>>> import mathutils
>>>>>>>
>>>>>>>
>>>>>>> class ModalOperator(bpy.types.Operator):
>>>>>>>    '''Move camera along with the viewport'''
>>>>>>>    bl_idname = "view3d.lock_camera"
>>>>>>>    bl_label = "Lock camera to view"
>>>>>>>
>>>>>>>    @classmethod
>>>>>>>    def poll(cls, context):
>>>>>>>        camera = context.scene.camera
>>>>>>>        if not camera:
>>>>>>>            return(False)
>>>>>>>        return(camera.name in context.scene.objects)
>>>>>>>
>>>>>>>    def modal(self, context, event):
>>>>>>>        camera = context.scene.camera
>>>>>>>        rv3d = context.space_data.region_3d
>>>>>>>
>>>>>>>        # rotation + location
>>>>>>>        camera.matrix_world = rv3d.view_matrix.copy().inverted()
>>>>>>>
>>>>>>>        # override location to take view_distance into account
>>>>>>>        rotation = rv3d.view_matrix.copy().to_3x3().inverted()
>>>>>>>        z_normal = mathutils.Vector([0.0, 0.0, 1.0]) * rotation
>>>>>>>        camera.location = rv3d.view_location + (rv3d.view_distance *
>>>>>>> z_normal)
>>>>>>>
>>>>>>>        # handle events
>>>>>>>        if event.type in ['LEFTMOUSE', 'NUMPAD_ENTER', 'RET']:
>>>>>>>            context.area.header_text_set()
>>>>>>>            return {'FINISHED'}
>>>>>>>        elif event.type == 'ESC':
>>>>>>>            camera.matrix_world = self.camera_matrix
>>>>>>>            context.area.header_text_set()
>>>>>>>            return {'CANCELLED'}
>>>>>>>
>>>>>>>        return {'PASS_THROUGH'}
>>>>>>>
>>>>>>>    def invoke(self, context, event):
>>>>>>>        context.window_manager.modal_handler_add(self)
>>>>>>>        self.camera_matrix = context.scene.camera.matrix_world.copy()
>>>>>>>        context.space_data.region_3d.view_perspective = 'PERSP'
>>>>>>>        context.area.header_text_set("ESC to cancel, ENTER or LMB to
>>>>>>> confirm")
>>>>>>>        return {'RUNNING_MODAL'}
>>>>>>>
>>>>>>>
>>>>>>> def register():
>>>>>>>    bpy.utils.register_class(ModalOperator)
>>>>>>>
>>>>>>>
>>>>>>> def unregister():
>>>>>>>    bpy.utils.unregister_class(ModalOperator)
>>>>>>>
>>>>>>>
>>>>>>> if __name__ == "__main__":
>>>>>>>    register()
>>>>>> _______________________________________________
>>>>>> Bf-committers mailing list
>>>>>> Bf-committers at blender.org
>>>>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>>>>
>>>>> _______________________________________________
>>>>> Bf-committers mailing list
>>>>> Bf-committers at blender.org
>>>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>>
>>>> _______________________________________________
>>>> Bf-committers mailing list
>>>> Bf-committers at blender.org
>>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>>
>>> _______________________________________________
>>> Bf-committers mailing list
>>> Bf-committers at blender.org
>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers
>>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>



-- 
- Campbell


More information about the Bf-committers mailing list