Announcement

Collapse
No announcement yet.

Let's make UE-friendly config for Blender! (Maya Navigation)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Let's make UE-friendly config for Blender! (Maya Navigation)

    Hello all, I thought it might be a good idea to make a script for Blender that would automatically adjust navigation and some basic settings to make it more compatible with Unreal Editor.

    I think it'd be best to focus on two things:

    1. 3D viewport navigation (only) just like in Unreal Editor / Maya-style
    2. Export settings for Unreal Engine

    I'd rather leave the default keyboard shortcuts as many tutorials rely on them and it'd be very hard to maintain non-default settings in the long run.

    Configuration Script

    Code:
    ##################################################################################################
    # Unreal-friendly configuration for Blender
    #
    # Version: 0.4
    # Last updated: September 30, 2017
    # Forums thread:
    # https://forums.unrealengine.com/development-discussion/content-creation/77422-let-s-make-ue-friendly-config-for-blender-maya-navigation
    ##################################################################################################
    
    import bpy; x = bpy.context.user_preferences
    
    def kmi_props_setattr(kmi_props, attr, value):
        try:
            setattr(kmi_props, attr, value)
        except AttributeError:
            print("Warning: property '%s' not found in keymap item '%s'" %
                  (attr, kmi_props.__class__.__name__))
        except Exception as e:
            print("Warning: %r" % e)
    
    wm = bpy.context.window_manager
    kc = wm.keyconfigs.user
    
    """
    Optional, non-default settings:
    """
    
    x.view.use_auto_perspective = True         # enable: Auto Perspective (auto orthographic views)
    x.system.use_region_overlap = True         # enable: Region Overlap (makes Tool Shelf transparent)
    
    bpy.data.scenes["Scene"].render.engine = 'CYCLES' # switch to Cycles Render
    bpy.data.scenes["Scene"].cycles.device = 'GPU'    # use GPU for rendering
    
    bpy.ops.wm.addon_enable(module="pie_menus_official") # enable addon: "Pie Menu: UI Pie Menu Official"
    bpy.ops.wm.addon_enable(module="mesh_looptools")     # enable addon: "Mesh: LoopTools"
    
    """
    Unreal Editor / Maya navigation
    """
    
    km = kc.keymaps['3D View'] # Map 3D View
    
    kmi = km.keymap_items.new('view3d.rotate', 'LEFTMOUSE', 'PRESS', alt=True)
    kmi = km.keymap_items.new('view3d.move', 'MIDDLEMOUSE', 'PRESS', alt=True)
    kmi = km.keymap_items.new('view3d.dolly', 'RIGHTMOUSE', 'PRESS', alt=True)
    
    x.inputs.invert_mouse_zoom = True
    x.inputs.invert_zoom_wheel = False
    x.inputs.view_rotate_method = 'TURNTABLE'
    x.inputs.select_mouse = 'LEFT'
    
    """
    UE4 export settings
    """
    
    bpy.data.scenes["Scene"].unit_settings.system = 'METRIC'
    bpy.context.scene.render.fps = 30     # 30 FPS
    bpy.context.scene.render.fps_base = 1 # Framerate base
    
    
    """
    Fix for ALT+RIGHTMOUSE (zoom) conflict in Edit Mode.
    Loop Select by double-clicking instead of single-click:
    """
    
    km = kc.keymaps['Mesh'] # Map Mesh
    
    kmi = km.keymap_items.remove(km.keymap_items['mesh.loop_select'])
    kmi = km.keymap_items.new('mesh.loop_select', 'SELECTMOUSE', 'DOUBLE_CLICK', alt=True)
    kmi_props_setattr(kmi.properties, 'extend', False)
    kmi_props_setattr(kmi.properties, 'deselect', False)
    kmi_props_setattr(kmi.properties, 'toggle', False)
    kmi = km.keymap_items.new('mesh.loop_select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True)
    kmi_props_setattr(kmi.properties, 'extend', False)
    kmi_props_setattr(kmi.properties, 'deselect', False)
    kmi_props_setattr(kmi.properties, 'toggle', True)
    
    """
    Fix for ALT+LEFTMOUSE (rotate) conflict in Weight Paint.
    Apply linear and radial gradients by holding additional SHIFT key:
    """
    
    km = kc.keymaps['Weight Paint'] # Map Weight Paint
    
    kmi = km.keymap_items.remove(km.keymap_items['paint.weight_gradient'])
    kmi = km.keymap_items.new('paint.weight_gradient', 'LEFTMOUSE', 'PRESS', shift=True, alt=True)
    kmi_props_setattr(kmi.properties, 'type', 'LINEAR')
    kmi = km.keymap_items.new('paint.weight_gradient', 'LEFTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True)
    kmi_props_setattr(kmi.properties, 'type', 'RADIAL')
    
    """
    Fix for ALT+LEFTMOUSE (rotate) conflict in 3D View (Select Object Menu randomly appearing).
    Activate Select Object Menu by pressing ALT+DOUBLE_CLICK instead:
    """
    
    km = kc.keymaps.new('3D View', space_type='VIEW_3D', region_type='WINDOW', modal=False) # Map 3D View
    
    for val in km.keymap_items:
        if val.idname == 'view3d.select':
            kmi = km.keymap_items.remove(km.keymap_items['view3d.select'])
    
    kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS')
    kmi_props_setattr(kmi.properties, 'extend', False)
    kmi_props_setattr(kmi.properties, 'deselect', False)
    kmi_props_setattr(kmi.properties, 'toggle', False)
    kmi_props_setattr(kmi.properties, 'center', False)
    kmi_props_setattr(kmi.properties, 'enumerate', False)
    kmi_props_setattr(kmi.properties, 'object', False)
    kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True)
    kmi_props_setattr(kmi.properties, 'extend', False)
    kmi_props_setattr(kmi.properties, 'deselect', False)
    kmi_props_setattr(kmi.properties, 'toggle', True)
    kmi_props_setattr(kmi.properties, 'center', False)
    kmi_props_setattr(kmi.properties, 'enumerate', False)
    kmi_props_setattr(kmi.properties, 'object', False)
    kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', ctrl=True)
    kmi_props_setattr(kmi.properties, 'extend', False)
    kmi_props_setattr(kmi.properties, 'deselect', False)
    kmi_props_setattr(kmi.properties, 'toggle', False)
    kmi_props_setattr(kmi.properties, 'center', True)
    kmi_props_setattr(kmi.properties, 'enumerate', False)
    kmi_props_setattr(kmi.properties, 'object', True)
    kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'DOUBLE_CLICK', alt=True) #non-default
    kmi_props_setattr(kmi.properties, 'extend', False)
    kmi_props_setattr(kmi.properties, 'deselect', False)
    kmi_props_setattr(kmi.properties, 'toggle', False)
    kmi_props_setattr(kmi.properties, 'center', False)
    kmi_props_setattr(kmi.properties, 'enumerate', True)
    kmi_props_setattr(kmi.properties, 'object', False)
    kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True)
    kmi_props_setattr(kmi.properties, 'extend', True)
    kmi_props_setattr(kmi.properties, 'deselect', False)
    kmi_props_setattr(kmi.properties, 'toggle', True)
    kmi_props_setattr(kmi.properties, 'center', True)
    kmi_props_setattr(kmi.properties, 'enumerate', False)
    kmi_props_setattr(kmi.properties, 'object', False)
    kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True)
    kmi_props_setattr(kmi.properties, 'extend', False)
    kmi_props_setattr(kmi.properties, 'deselect', False)
    kmi_props_setattr(kmi.properties, 'toggle', False)
    kmi_props_setattr(kmi.properties, 'center', True)
    kmi_props_setattr(kmi.properties, 'enumerate', True)
    kmi_props_setattr(kmi.properties, 'object', False)
    kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True)
    kmi_props_setattr(kmi.properties, 'extend', False)
    kmi_props_setattr(kmi.properties, 'deselect', False)
    kmi_props_setattr(kmi.properties, 'toggle', True)
    kmi_props_setattr(kmi.properties, 'center', False)
    kmi_props_setattr(kmi.properties, 'enumerate', True)
    kmi_props_setattr(kmi.properties, 'object', False)
    kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True)
    kmi_props_setattr(kmi.properties, 'extend', False)
    kmi_props_setattr(kmi.properties, 'deselect', False)
    kmi_props_setattr(kmi.properties, 'toggle', True)
    kmi_props_setattr(kmi.properties, 'center', True)
    kmi_props_setattr(kmi.properties, 'enumerate', True)
    kmi_props_setattr(kmi.properties, 'object', False)
    
    """
    save settings:
    """
    bpy.ops.wm.save_userpref()
    Viewport Controls


    3D viewport navigation - Pan, Orbit, and Zoom

    Unreal Editor / Maya-style - pan, orbit, and zoom viewport controls:
    • Alt + LMB + Drag - Tumbles the viewport around a single pivot or point of interest.
    • Alt + RMB + Drag - Dollies (zooms) the camera toward and away from a single pivot or point of interest.
    • Alt + MMB + Drag - Tracks the camera left, right, up, and down in the direction of mouse movement.


    Game-style (WASD) navigation (already default in Blender, called "Walk Mode")

    Menu: View ‣ Navigation ‣ Walk Navigation
    Hotkey: Shift-F

    Usage
    This navigation mode behaves similar to the first person navigation system available in most 3d world games nowadays. It works with a combination of keyboard keys (WASD) and mouse movement. By default the navigation is in the ‘free’ mode, with no gravity influence. You can toggle between gravity and free mode during the navigation (Tab).

    Shortcuts
    • Move the camera forward/backward (W / S).
    • Strafe left/right (A / D).
    • Move down and up (Q / E) - only in ‘free’ mode.
    • Alternate between ‘free’ and ‘gravity’ modes (Tab).
    • Change the movement speed: WheelUp to increase the movement speed. WheelDown to decrease the movement speed.


    Conflicting shortcuts that have been replaced

    Loop Select
    Mode: Edit Mode
    Original hotkey: Alt-RMB
    New hotkey: Alt-RMB(double-click)

    Linear Weight Gradient
    Mode: Weight Paint
    Original hotkey: Alt-LMB
    New hotkey: Alt-Shift-LMB

    Radial Weight Gradient
    Mode: Weight Paint
    Original hotkey: Alt-Ctrl-LMB
    New hotkey: Alt-Shift-Ctrl-LMB

    Select Object Menu
    Mode: Object Mode
    Original hotkey: Alt-LMB
    New hotkey:Alt-LMB(double-click)


    Important setting in Unreal Engine

    Please note that this script assumes that you have Maya-style "Invert Middle Mouse Pan" option enabled in your Unreal Editor.
    Most 3D applications use this type of navigation (or at least have it as an option). You can enable it in Unreal Editor by going to Edit -> Editor Preferences -> Viewports and then clicking "Invert Middle Mouse Pan" checkbox.

    Click image for larger version  Name:	unreal.png Views:	1 Size:	14.2 KB ID:	1179032


    How to apply the config in Blender

    1. Reset all settings to default (optional)

    Click image for larger version  Name:	00.png Views:	1 Size:	108.8 KB ID:	1179028

    2. Switch from 3D View to Text Editor, then click the "New" button:

    Click image for larger version  Name:	01.png Views:	1 Size:	59.7 KB ID:	1179029

    3. Paste the above config into the editor window and click "Run Script":

    Click image for larger version  Name:	04.png Views:	1 Size:	9.2 KB ID:	1179030

    4. Switch from Text Editor back to 3D View:

    Click image for larger version  Name:	05.png Views:	1 Size:	26.6 KB ID:	1179031

    5. Save everything in default startup file (optional)

    Click image for larger version  Name:	05.png Views:	1 Size:	104.4 KB ID:	1179109

    Any suggestions or contributions are most certainly welcome!
    Last edited by mission; 09-30-2017, 06:19 PM.

    #2
    first update: there was a conflict with Weight Gradient (in Weight Paint mode)

    Comment


      #3
      thats Cool (Y) ......... start learning Blender few days ago, this will help me.
      any new update !!

      Comment


        #4
        This YouTube video (from Feb 2014) takes you through configuring a Maya-like interface in Blender, including how to resolve issues relating to the remapping.

        It's worth a listen just to hear this guy talk anyway!

        Comment


          #5
          New to unreal, I tried it last year and cound not even navigate! Why? Cause I work with blender for 10 years now and the mouse controls have nothing in common with Unreal, is there a way to change UE to behave like blender? I want to give it another try
          PS. Is linux UE working properly or must I use the windows version?
          Thank you

          Comment


            #6
            Update:

            - removed CUDA settings from config as it was causing issues (you can still enable CUDA manually)
            - changed selection to LEFT mouse button

            Comment


              #7
              You should set the unit scale to 0.01 as well (and increase default clipping distance) for skeletal mesh compatibility too.

              Comment


                #8
                Could you please put instructions on where to place that code inside of Blender to make this change work? Thank you for all this.

                Comment


                  #9
                  Originally posted by Synthercat View Post
                  New to unreal, I tried it last year and cound not even navigate! Why? Cause I work with blender for 10 years now and the mouse controls have nothing in common with Unreal, is there a way to change UE to behave like blender? I want to give it another try
                  PS. Is linux UE working properly or must I use the windows version?
                  Thank you
                  I find blender confusing with its UI navigation. It's got several sub menus levels to go through before you can even get to the option you want. some things in Blender are buried several levels down away from the main UI, (resulting in users having to do alot of unnecessary mouse clicking just to get to what they want)... That's a LAYOUT mistake. Unreal Engine is also making the same error taking very simple texture settings like height and width, and size, and scale, and brightness, it takes the very basic settings and locks them away into the NODE MATERIAL EDITOR so that we have to piece together all the simple parameters for the textures from wiring up all these nodes in order to set up the basic texture parameters on the one
                  texture.

                  OR worse, you get people releasing out textures with not just only one texture, but multiple copies of the same texture map for every map setting,
                  so instead of getting just only the graphic texture, you get also the normal map, the roughness map, the scalar map, the dither map
                  and so on. resulting in 5-6 extra copies of the same textures in your assets. And when you have hundreds of textures in the game, all these
                  multiple copies of the same texture maps starts to add up in the file and resource memory space in the game. It looks like to me that Unreal Engine wants you to have to manually wire up all the basic settings through the Material Node Editor as custom settings which is more time consuming.

                  I think THE NODE SYSTEM IN UNREAL ENGINE TAKES LONGER TO SET THINGS UP IN because of all the wiring up you have to do.

                  When I wanted to do a Dialogue Text Subtitle Tutorial but in the epic docs I couldn't set the subtitle system all up because they only showed the settings to just only half of the blueprints and not showed me all of the settings for the other speaker's blueprint config that I needed to know but they didn't include it so I couldn't set it all up properly as a result because I am not an advanced user. So I've got plenty to say about these programs and their poor UI's layouts and the way some of these companies approach the teaching process . Because some of them put the cart before the horse and create a stumbling block in the way of our learning all because or failing to explain things out properly in detail or skipping simple things out in their docs or tuts....And i think Unreal Engine's UI was designed mainly for those who have big DOUBLE SCREENS. But I don't have a double screen. so using the editor is a bit of a pain for me and Blender might be the same because it has a big UI as well..

                  I Don't like Blenders UI. But I don't like Unreal's UI that much either for various reasons. The way Unreal Engine has us doing data table entry at the moment (because my cvs text editor won't load my dialog cvs file anymore so I couldn't use that), so I had to use the Engine's built in row editor instead
                  and I couldn't find where the Auto Function is for me to beable to just auto number the rows so i can just hit enter and just cut 'n' paste my dialog text in and go down row by row very quickly. but because there's no auto numbering I could find, it took me nearly an HOUR just to enter in 400 rows into the data table and when you got over 40 thousand lines to enter in, well that's no fun picnic its gonna take months with this slow system.
                  THE UI ITS TOO SLOW TO refresh itself...

                  Unless you guys know a setting in the Editor I can change to stop the delays I'm getting with the screen refreshing.
                  Last edited by tozan; 09-29-2017, 12:19 AM.

                  Comment


                    #10
                    Update 0.4:

                    1) Fix for ALT+LEFTMOUSE (rotate) conflict in 3D View (Select Object Menu randomly appearing)

                    2) Added addons: "Pie Menu: UI Pie Menu Official" and "Mesh: LoopTools"

                    KNOWN ISSUES:

                    1) CUDA rendering not enabled by default

                    2) including 0.01 unit scale in script (bpy.data.scenes["Scene"].unit_settings.scale_length = 0.01) would also require adjusting the grid scale. Unfortunately I can't figure out how to set the grid scale programmatically...

                    Comment


                      #11
                      trojanfoe : This configuration script already contains all the adjustments from that video and also fixes some additional issues.

                      cyaoeu : I've tried to enable unit scale to 0.01 by default but can't figure out how to do that correctly (see "known issues" above)

                      Comment


                        #12
                        Originally posted by mission View Post
                        cyaoeu : I've tried to enable unit scale to 0.01 by default but can't figure out how to do that correctly (see "known issues" above)
                        I'm not sure what you mean. The scale of the grid is the same in unit scale 1 and unit scale 0.01. The only difference is that the camera view changes slightly, but it's fixed after View Selected on any object.

                        Comment


                          #13
                          cyaoeu : I don't think it works for me. Or maybe I'm just doing something wrong. Please see the 3 screenshots below:

                          Click image for larger version

Name:	1.PNG
Views:	1
Size:	70.0 KB
ID:	1362631

                          Click image for larger version

Name:	2.PNG
Views:	1
Size:	64.9 KB
ID:	1362632

                          Click image for larger version

Name:	3.PNG
Views:	1
Size:	101.2 KB
ID:	1362633

                          Comment


                            #14
                            Originally posted by mission View Post
                            cyaoeu : I don't think it works for me. Or maybe I'm just doing something wrong. Please see the 3 screenshots below:
                            In the 1 unit scale scene you've got a 2m cube. When you change it to 0.01 unit it turns into a 0.02m cube (2cm). You will need to resize it by 100 times (and do View Selected) for your scenes to look the same.
                            Last edited by cyaoeu; 09-30-2017, 09:10 PM.

                            Comment


                              #15
                              Thaks a lot for the script Mission! It makes Blender much more confortable.

                              Only a question: How about NOT to Invert Middle Mouse Pan on Blender with your script? I try change some Booleans but not get lucky.

                              Thanks and happy 2018!


                              Comment

                              Working...
                              X