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:
- 3D viewport navigation (only) just like in Unreal Editor / Maya-style
- 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
##################################################################################################
# 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.
How to apply the config in Blender
- Reset all settings to default (optional)
- Switch from 3D View to Text Editor, then click the “New” button:
- Paste the above config into the editor window and click “Run Script”:
- Switch from Text Editor back to 3D View:
- Save everything in default startup file (optional)
Any suggestions or contributions are most certainly welcome!