Example #1
0
    def draw(self, context):
        layout = self.layout
        if addon_prefs.has_valid_sdk_path():
            is_started = server.B4WLocalServer.get_server_status() == server.SUB_THREAD_START_SERV_OK
            is_waiting_for_shutdown = server.B4WLocalServer.is_waiting_for_shutdown()
            allow_actions = server.B4WLocalServer.allow_actions()

            if is_started:
                layout.label(text = _("Development server is running."))
            elif is_waiting_for_shutdown:
                layout.label(text = _("Stopping server..."))
            else:
                layout.label(text = _("Development server is off."))

            if allow_actions:
                if is_started:
                    layout.operator("b4w.stop_server", text=p_("Stop Server", "Operator"), icon="PAUSE")
                elif not is_waiting_for_shutdown:
                    layout.operator("b4w.start_server", text=p_("Start Server", "Operator"), icon="PLAY")
            else:
                layout.label(text = _("Server is run by another Blender instance."))

            if is_started:
                layout.operator("b4w.open_sdk", text=p_("SDK Index", "Operator"), icon="URL")
                layout.operator("b4w.open_proj_manager",
                        text=p_("Project Manager", "Operator"), icon="URL")
                layout.operator("b4w.preview",
                        text=p_("Fast Preview", "Operator"), icon_value=render_engine.custom_icons["b4w_icon"].icon_id)

        else:
            row = layout.row()
            row.label(text = _("Development server is unavailable for standalone Blend4Web add-on."))
            row = layout.row()
            row.label(text = _("Remove standalone Blend4Web add-on (if installed) and install Blend4Web SDK."))
Example #2
0
    def draw(self, context):
        layout = self.layout
        if addon_prefs.has_valid_sdk_path():
            is_started = server.B4WLocalServer.get_server_status() == server.SUB_THREAD_START_SERV_OK
            is_waiting_for_shutdown = server.B4WLocalServer.is_waiting_for_shutdown()
            allow_actions = server.B4WLocalServer.allow_actions()

            if is_started:
                layout.label(text = _("Development server is running."))
            elif is_waiting_for_shutdown:
                layout.label(text = _("Stopping server..."))
            else:
                layout.label(text = _("Development server is down."))

            if allow_actions:
                if is_started:
                    layout.operator("b4w.stop_server", text=p_("Stop Server", "Operator"), icon="PAUSE")
                elif not is_waiting_for_shutdown:
                    layout.operator("b4w.start_server", text=p_("Start Server", "Operator"), icon="PLAY")
            else:
                layout.label(text = _("Server actions are available in the other Blender instance."))

            if is_started:
                layout.operator("b4w.open_sdk", text=p_("SDK Index", "Operator"), icon="URL")
                layout.operator("b4w.open_proj_manager",
                        text=p_("Project Manager", "Operator"), icon="URL")
                layout.operator("b4w.preview",
                        text=p_("Fast Preview", "Operator"), icon="ZOOM_ALL")

        else:
            layout.label(text = _("Blend4Web SDK was not found."))
Example #3
0
    def draw(self, context):
        layout = self.layout
        if server.has_valid_sdk_dir():
            is_started = server.B4WLocalServer.get_server_status() == server.SUB_THREAD_START_SERV_OK
            is_waiting_for_shutdown = server.B4WLocalServer.is_waiting_for_shutdown()
            allow_actions = server.B4WLocalServer.allow_actions()

            if is_started:
                layout.label(text = _("Development server is running."))
            elif is_waiting_for_shutdown:
                layout.label(text = _("Stopping server..."))
            else:
                layout.label(text = _("Development server is down."))

            if allow_actions:
                if is_started:
                    layout.operator("b4w.stop_server", text=p_("Stop", "Operator"), icon="PAUSE")
                elif not is_waiting_for_shutdown:
                    layout.operator("b4w.start_server", text=p_("Start", "Operator"), icon="PLAY")
            else:
                layout.label(text = _("Server actions are available in the other Blender instance."))

            if is_started:
                layout.operator("b4w.open_sdk", text=p_("Open SDK", "Operator"), icon="URL")

        else:
            layout.label(text = _("Blend4Web SDK was not found."))
Example #4
0
    def draw(self, context):
        prefs = bpy.context.user_preferences.addons[__package__].preferences

        layout = self.layout

        if prefs.b4w_src_path == "" or not os.path.exists(prefs.b4w_src_path):
            layout.label(text = _("Blend4Web SDK was not found."))
            layout.label(text = _("Please download and configure it before using Mass Reexporter."))
            return

        layout.label(text = _("Check info window for export results."))
        
        row = layout.row()
        row.template_list("UI_UL_reexport_paths", "", prefs,
                "b4w_reexport_paths", prefs, "b4w_reexport_path_index", rows=3)

        col = row.column(align=True)
        col.operator("b4w.reexport_path_append", icon='ZOOMIN', text=_(""))
        col.operator("b4w.reexport_path_remove", icon='ZOOMOUT', text=_(""))

        paths = prefs.b4w_reexport_paths
        path_index = prefs.b4w_reexport_path_index

        # index is not saved each time it's updated to save time so may be incorrect
        if not paths or path_index < 0 or path_index >= len(paths):
            return

        row = layout.row(align=True)
        row.prop(paths[path_index], "path", text=_("Exported Directory"))
        row.operator("buttons.file_browse", text=_(""), icon='FILESEL').relative_path = False

        row = layout.row()
        row.operator("b4w.reexport", text=p_("Reexport", "Operator"))
def b4w_fast_preview(self, context):
    if server.has_valid_sdk_dir():
        is_started = server.B4WLocalServer.get_server_status() == server.SUB_THREAD_START_SERV_OK
        
        if context.scene.render.engine=="BLEND4WEB":
            self.layout.operator("b4w.preview",
                        text=p_("Fast Preview", "Operator"), icon="ZOOM_ALL")
Example #6
0
def b4w_fast_preview(self, context):
    if server.has_valid_sdk_dir():
        is_started = server.B4WLocalServer.get_server_status(
        ) == server.SUB_THREAD_START_SERV_OK

        if context.scene.render.engine == "BLEND4WEB":
            self.layout.operator("b4w.preview",
                                 text=p_("Fast Preview", "Operator"),
                                 icon="ZOOM_ALL")
Example #7
0
class B4WShutdownServer(bpy.types.Operator):
    bl_idname = "b4w.stop_server"
    bl_label = p_("B4W Stop Server", "Operator")
    bl_description = _("Stop server")
    bl_options = {"INTERNAL"}

    def execute(self, context):
        B4WLocalServer.shutdown()
        return {"FINISHED"}
Example #8
0
class B4WStartServer(bpy.types.Operator):
    bl_idname = "b4w.start_server"
    bl_label = p_("B4W Start Server", "Operator")
    bl_description = _("Start development server")
    bl_options = {"INTERNAL"}

    def execute(self, context):
        B4WLocalServer.start()
        return {"FINISHED"}
Example #9
0
class B4W_LogicEditorRefreshAvailableTrees(bpy.types.Operator):
    bl_idname = 'scene.b4w_logic_editor_refresh_available_trees'
    bl_label = p_("Refresh", "Operator")
    bl_description = _("Refresh list of available Trees")

    def invoke(self, context, event):
        b4w_logic_editor_refresh_available_trees()

        return {'FINISHED'}
Example #10
0
class B4W_Camera_Target_Copier(bpy.types.Operator):
    '''Use cursor location as camera target'''
    bl_idname = "b4w.camera_target_copy"
    bl_label = p_("B4W Camera Target Copy", "Operator")
    bl_options = {"INTERNAL"}
   
    def execute(self, context):
        run()
        return {"FINISHED"}
class B4W_Remove_Unused_Vertex_Groups(bpy.types.Operator):
    '''Remove vertex groups which are not being used by any armature'''
    bl_idname = "b4w.remove_unused_vgroups"
    bl_label = p_("B4W Remove Unused VGroups", "Operator")
    bl_options = {"INTERNAL"}

    def execute(self, context):
        run(self)
        return {"FINISHED"}
Example #12
0
class B4W_Vertex_Groups_To_Materials(bpy.types.Operator):
    '''Convert vertex groups to materials'''
    bl_idname = "b4w.vertex_groups_to_materials"
    bl_label = p_("B4W Vertex Groups To Materials", "Operator")
    bl_options = {"INTERNAL"}

    def execute(self, context):
        run()
        return {"FINISHED"}
Example #13
0
    def draw(self, context):
        layout = self.layout
        if addon_prefs.has_valid_sdk_path():
            is_started = bool(server.B4WLocalServer.server_process)
            is_waiting_for_shutdown = server.B4WLocalServer.is_waiting_for_shutdown(
            )

            if is_started:
                layout.label(text=_("Development server is running."))
            elif is_waiting_for_shutdown:
                layout.label(text=_("Stopping server..."))
            else:
                layout.label(text=_("Development server is off."))

            if is_started:
                layout.operator("b4w.stop_server",
                                text=p_("Stop Server", "Operator"),
                                icon="PAUSE")
            elif not is_waiting_for_shutdown:
                layout.operator("b4w.start_server",
                                text=p_("Start Server", "Operator"),
                                icon="PLAY")

            if is_started:
                layout.operator("b4w.open_sdk",
                                text=p_("SDK Index", "Operator"),
                                icon="URL")
                layout.operator("b4w.open_proj_manager",
                                text=p_("Project Manager", "Operator"),
                                icon="URL")
                layout.operator(
                    "b4w.preview",
                    text=p_("Fast Preview", "Operator"),
                    icon_value=render_engine.custom_icons["b4w_icon"].icon_id)

        else:
            row = layout.row()
            row.label(text=_(
                "Development server is unavailable for standalone Blend4Web add-on."
            ))
            row = layout.row()
            row.label(text=_(
                "Remove standalone Blend4Web add-on (if installed) and install Blend4Web SDK."
            ))
Example #14
0
 def draw(self, context):
     layout = self.layout
     scene = context.scene
     layout.operator("b4w.set_recommended_options",
                     text=p_("Set Recommended Options", "Operator"),
                     icon="MAT_SPHERE_SKY")
     if hasattr(scene.render, "use_world_space_shading"):
         layout.prop(scene.render,
                     "use_world_space_shading",
                     text=_("World Space Shading"))
class B4W_ExportHTMLPathGetter(bpy.types.Operator):
    """Get Export Path for blend file"""
    bl_idname = "b4w.get_export_html_path"
    bl_label = p_("B4W Get Export HTML Path", "Operator")
    bl_options = {'INTERNAL'}

    def execute(self, context):
        print("B4W Export HTML Path = " + exporter.get_default_path(True))

        return {"FINISHED"}
Example #16
0
    def draw(self, context):
        layout = self.layout
        if server.has_valid_sdk_dir():
            is_started = server.B4WLocalServer.get_server_status(
            ) == server.SUB_THREAD_START_SERV_OK
            is_waiting_for_shutdown = server.B4WLocalServer.is_waiting_for_shutdown(
            )
            allow_actions = server.B4WLocalServer.allow_actions()

            if is_started:
                layout.label(text=_("Development server is running."))
            elif is_waiting_for_shutdown:
                layout.label(text=_("Stopping server..."))
            else:
                layout.label(text=_("Development server is down."))

            if allow_actions:
                if is_started:
                    layout.operator("b4w.stop_server",
                                    text=p_("Stop Server", "Operator"),
                                    icon="PAUSE")
                elif not is_waiting_for_shutdown:
                    layout.operator("b4w.start_server",
                                    text=p_("Start Server", "Operator"),
                                    icon="PLAY")
            else:
                layout.label(text=_(
                    "Server actions are available in the other Blender instance."
                ))

            if is_started:
                layout.operator("b4w.open_sdk",
                                text=p_("SDK Index", "Operator"),
                                icon="URL")
                layout.operator("b4w.open_proj_manager",
                                text=p_("Project Manager", "Operator"),
                                icon="URL")
                layout.operator("b4w.preview",
                                text=p_("Fast Preview", "Operator"),
                                icon="ZOOM_ALL")

        else:
            layout.label(text=_("Blend4Web SDK was not found."))
Example #17
0
class B4WOpenSDK(bpy.types.Operator):
    bl_idname = "b4w.open_sdk"
    bl_label = p_("B4W Open SDK", "Operator")
    bl_description = _("Open Blend4Web SDK index page")
    bl_options = {"INTERNAL"}

    def execute(self, context):
        port = context.user_preferences.addons[__package__].preferences.b4w_port_number
        B4WLocalServer.open_url("http://" + ADDRESS + ":" + str(port))
        return {"FINISHED"}
Example #18
0
def b4w_fast_preview(self, context):
    if addon_prefs.has_valid_sdk_path():
        is_started = server.B4WLocalServer.get_server_status(
        ) == server.SUB_THREAD_START_SERV_OK

        if (context.scene.render.engine == "BLEND4WEB"
                or context.scene.render.engine == "CYCLES"):
            self.layout.operator(
                "b4w.preview",
                text=p_("Fast Preview", "Operator"),
                icon_value=render_engine.custom_icons["b4w_icon"].icon_id)
Example #19
0
class B4WOpenProjManager(bpy.types.Operator):
    bl_idname = "b4w.open_proj_manager"
    bl_label = p_("B4W Open Project Manager", "Operator")
    bl_description = _("Open Project Manager")
    bl_options = {"INTERNAL"}

    def execute(self, context):
        port = context.user_preferences.addons[__package__].preferences.b4w_port_number
        B4WLocalServer.open_url("http://" + ADDRESS + ":" + str(port) +
                "/project/")
        return {"FINISHED"}
Example #20
0
class OperatorAddShapeKey(bpy.types.Operator):
    bl_idname = "object.b4w_shape_key_add"
    bl_label = p_("Add shape key to the object", "Operator")
    bl_options = {"INTERNAL"}

    def execute(self, context):
        obj = context.active_object
        # auto apply default animaton
        if not "b4w_shape_keys" in obj.keys():
            obj.b4w_shape_keys = True

        return bpy.ops.object.shape_key_add(from_mix=False)
def b4w_fast_preview(self, context):
    is_started = server.B4WLocalServer.is_started()

    if (context.scene.render.engine == "BLEND4WEB"
            or context.scene.render.engine == "CYCLES"):
        if is_started:
            row = self.layout.row(align=True)
            row.operator("b4w.preview",
                        text=p_("Fast Preview", "Operator"), icon_value=render_engine.custom_icons["b4w_icon"].icon_id)
            preferences = addon_prefs.get_prefs()
            icon = "LINKED" if preferences.b4w_sync_with_browser else "UNLINKED"
            row.prop(preferences, "b4w_sync_with_browser", icon=icon, text="", expand=False)
class B4W_CopyNormalsFromMesh(bpy.types.Operator):
    # copy normals from another mesh if |v1 - v2| -> 0

    bl_idname = 'object.copy_normals_from_mesh'
    bl_label = p_("B4W Copy Normals From Mesh (Matched)", "Operator")
    bl_description = _('Copy normals from the selected to the active mesh' +
                       ' for selected vertices')
    bl_options = {"INTERNAL"}

    def execute(self, context):
        prepare(context)
        norm_edited = False
        if len(bpy.context.selected_objects) != 2:
            print('Wrong selection')
        else:
            obj_target = context.active_object
            if context.selected_objects[0].name != obj_target.name:
                obj_source = context.selected_objects[0]
            else:
                obj_source = context.selected_objects[1]

            verts_target = obj_target.data.vertices
            verts_source = obj_source.data.vertices

            src_loops_normals, src_vert_to_loops_map = load_loops_normals(
                obj_source)

            delta = 0.000001
            verts_is_selected = False
            for v in verts_target:
                if v.select:
                    verts_is_selected = True
                    break
            verts_target_count = len(verts_target)
            for i in range(verts_target_count):
                if not verts_is_selected or verts_target[i].select:
                    for j in range(len(verts_source)):
                        if (verts_target[i].co -
                                verts_source[j].co).length < delta:
                            n = mathutils.Vector()
                            for l in src_vert_to_loops_map[j]:
                                n = n + mathutils.Vector(src_loops_normals[l])
                            n = n / len(src_vert_to_loops_map[j])
                            set_vertex_normal(i, (n.x, n.y, n.z))
                            norm_edited = True
        if norm_edited:
            obj_target.data.normals_split_custom_set(b4w_loops_normals)

        context.area.tag_redraw()
        return {'FINISHED'}
Example #23
0
class B4W_OperatorWorldBackgroundHide(bpy.types.Operator):
    bl_idname = "b4w.world_background_hide"
    bl_label = p_("Hide", "Operator")
    bl_description = _(
        'Disable the "World Background" option in 3D VIEW panels')
    bl_options = {"INTERNAL"}

    def invoke(self, context, event):
        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':
                for space in area.spaces:
                    if space.type == "VIEW_3D":
                        space.show_world = False
        return {'FINISHED'}
Example #24
0
class B4WReexportPathAppend(bpy.types.Operator):
    bl_idname = "b4w.reexport_path_append"
    bl_label = p_("Reexport Append", "Operator")
    bl_options = {"INTERNAL"}
    bl_description = _("Append exported directory")

    def invoke(self, context, event):
        prefs = bpy.context.user_preferences.addons[__package__].preferences

        prefs.b4w_reexport_paths.add()
        prefs.b4w_reexport_path_index = len(prefs.b4w_reexport_paths) - 1

        addon_prefs.save_reexport_paths()

        return {"FINISHED"}
Example #25
0
class B4W_AnimAddOperator(bpy.types.Operator):
    bl_idname = 'b4w.anim_add'
    bl_label = p_("Add animation", "Operator")
    bl_description = _("Add animation")
    bl_options = {"INTERNAL"}

    def invoke(self, context, event):
        obj = context.active_object

        anim = obj.b4w_anim

        anim.add()
        anim[-1].name = ""

        return {'FINISHED'}
Example #26
0
class B4WPreviewScene(bpy.types.Operator):
    bl_idname = "b4w.preview"
    bl_label = p_("B4W Preview", "Operator")
    bl_description = _("Preview the current scene in the Viewer")
    bl_options = {"INTERNAL"}

    def execute(self, context):
        root = bpy.context.user_preferences.addons[__package__].preferences.b4w_src_path
        tmpdir = join(root, "tmp")
        if not exists(tmpdir):
            os.mkdir(tmpdir)
        bpy.ops.export_scene.b4w_json(do_autosave = False, run_in_viewer = True,
                override_filepath=join(tmpdir, "preview.json"),
                save_export_path = False)
        return {"FINISHED"}
Example #27
0
class B4W_LogicEditorAddNodeTree(bpy.types.Operator):
    bl_idname      = 'scene.b4w_logic_editor_add_tree'
    bl_label       = p_("Add", "Operator")
    bl_description = _("Add new logic node tree")

    def invoke(self, context, event):
        ntree = bpy.data.node_groups.new("B4WLogicNodeTree", "B4WLogicNodeTreeType")
        ntree.use_fake_user = True
        node = ntree.nodes.new("B4W_logic_node")
        node.type = "ENTRYPOINT"
        node.location = (-500, 0)
        context.scene.b4w_active_logic_node_tree = ntree.name
        b4w_logic_editor_refresh_available_trees()

        return {'FINISHED'}
class B4W_ShoreDistanceBaker(bpy.types.Operator):
    '''Generate distance field to the nearest shore vertex'''
    bl_idname = "b4w.shore_distance_baker"
    bl_label = p_("B4W Shore Distance Baker", "Operator")
    bl_options = {"INTERNAL"}

    def execute(self, context):
        try:
            run()
        except BakeError as error:
            global _shore_bake_error
            _shore_bake_error = error
            bpy.ops.b4w.bake_error_dialog('INVOKE_DEFAULT')

        return {"FINISHED"}
Example #29
0
class B4W_AnimRemOperator(bpy.types.Operator):
    bl_idname = 'b4w.anim_remove'
    bl_label = p_("Remove animation", "Operator")
    bl_description = _("Remove animation")
    bl_options = {"INTERNAL"}

    def invoke(self, context, event):
        obj = context.active_object

        anim = obj.b4w_anim

        if obj.b4w_anim_index >= 0:
            anim.remove(obj.b4w_anim_index)
            obj.b4w_anim_index -= 1

        return {'FINISHED'}
class B4W_VertexAnimAddOperator(bpy.types.Operator):
    bl_idname      = 'b4w.vertex_anim_add'
    bl_label       = p_("Add vertex animation", "Operator")
    bl_description = _("Add new vertex animation")
    bl_options = {"INTERNAL"}

    def invoke(self, context, event):
        obj = context.active_object

        va = obj.b4w_vertex_anim

        va.add()
        va[-1].name= _("New Anim")
        va[-1].frame_start = context.scene.frame_start
        va[-1].frame_end = context.scene.frame_end

        return{'FINISHED'}
Example #31
0
class B4WUpdateMessage(bpy.types.Operator):
    bl_idname = "b4w.update_message"
    bl_label = p_("Message", "Context")

    def execute(self, context):
        return {'FINISHED'}

    def invoke(self, context, event):
        wm = context.window_manager
        return wm.invoke_popup(self, width=400, height=200)

    def draw(self, context):
        pref = bpy.context.user_preferences.addons[__package__].preferences
        version_message = bpy.app.translations.pgettext_tip(_("New version of Blend4Web is available: %s"))
        self.layout.label(version_message % \
            (pref.b4w_available_for_update_version))
        self.layout.operator("wm.url_open", text=_("Download"), icon='URL').url = "https://www.blend4web.com/en/downloads/"
Example #32
0
class B4WServerMessage(bpy.types.Operator):
    bl_idname = "b4w.server_message"
    bl_label = p_("Warning: Server error.", "Operator")
    bl_options = {"INTERNAL"}

    message = StringProperty(name=_("Message string"))

    def execute(self, context):
        return {'FINISHED'}

    def invoke(self, context, event):
        wm = context.window_manager
        context.window.cursor_set("DEFAULT")
        return wm.invoke_props_dialog(self, 450)

    def draw(self, context):
        self.layout.label(self.message, icon="ERROR")
Example #33
0
class B4W_Constraints_UnMuter(bpy.types.Operator):
    '''Unmute bone constraints for selected armature object'''

    bl_idname = "b4w.constraints_unmute"
    bl_label = p_("B4W Constraints UnMute", "Operator")
    bl_options = {"INTERNAL"}

    def execute(self, context):
        armobj = context.active_object
        if not (armobj and armobj.type == "ARMATURE"):
            self.report({'INFO'}, _("Not an armature object"))
            return {'CANCELLED'}

        for bone in armobj.pose.bones:
            for c in bone.constraints:
                c.mute = False

        return {"FINISHED"}
def b4w_fast_preview(self, context):
    is_started = server.B4WLocalServer.is_started()

    if (context.scene.render.engine == "BLEND4WEB"
            or context.scene.render.engine == "CYCLES"):
        if is_started:
            row = self.layout.row(align=True)
            row.operator(
                "b4w.preview",
                text=p_("Fast Preview", "Operator"),
                icon_value=render_engine.custom_icons["b4w_icon"].icon_id)
            preferences = addon_prefs.get_prefs()
            icon = "LINKED" if preferences.b4w_sync_with_browser else "UNLINKED"
            row.prop(preferences,
                     "b4w_sync_with_browser",
                     icon=icon,
                     text="",
                     expand=False)
class B4WDeprecatedPathToScriptsMessage(bpy.types.Operator):
    bl_idname = "b4w.deprecated_path_to_script"
    bl_label = p_("Warning: Deprecated path to scripts.", "Operator")
    bl_options = {"INTERNAL"}

    path = StringProperty(name=_("Path to SDK"))

    def execute(self, context):
        return {'FINISHED'}

    def invoke(self, context, event):
        wm = context.window_manager
        context.window.cursor_set("DEFAULT")
        return wm.invoke_props_dialog(self, 450)

    def draw(self, context):
        self.layout.label("Deprecated path to scripts. The correct path is "
                + self.path, icon="ERROR")
Example #36
0
class B4W_FaceVertexNormals(bpy.types.Operator):
    # face orientation
    bl_idname = 'object.face_vertex_normals'
    bl_label = p_('Vertex Normal Face', "Operator")
    bl_description = _('Copy face normal')
    bl_options = {"INTERNAL"}

    def execute(self, context):
        bpy.ops.object.mode_set(mode='OBJECT')
        bpy.ops.object.mode_set(mode='EDIT')
        prepare(context)
        obj = context.active_object
        mesh = obj.data

        bpy.ops.object.mode_set(mode='OBJECT')

        sel_indices = []

        for i in range(len(mesh.vertices)):
            if mesh.vertices[i].select == True:
                sel_indices.append(i)

        if len(sel_indices) < 3:
            self.report({'INFO'}, _('Please select at least 3 vertices'))
            return {"FINISHED"}

        for p in mesh.polygons:
            all_in = True

            for i in sel_indices:
                if mesh.vertices[i].index not in p.vertices:
                    all_in = False
                    break

            if all_in:
                for i in sel_indices:
                    set_vertex_normal(i, (p.normal.x, p.normal.y, p.normal.z))

        bpy.ops.object.mode_set(mode='OBJECT')
        obj.data.normals_split_custom_set(b4w_loops_normals)
        bpy.ops.object.mode_set(mode='EDIT')

        context.area.tag_redraw()
        return {'FINISHED'}
Example #37
0
 def draw(self, context):
     layout = self.layout
     scene = context.scene
     layout.operator("b4w.set_recommended_options", text=p_("Set Recommended Options", "Operator"), icon="MAT_SPHERE_SKY")
     if hasattr(scene.render, "use_world_space_shading"):
         layout.prop(scene.render, "use_world_space_shading", text=_("World Space Shading"))
Example #38
0
    def draw(self, context):
        is_edit_mode = context.active_object.mode == 'EDIT'

        layout = self.layout
        row = layout.row(align=True)
        row.prop(context.active_object.data, 'use_auto_smooth',
            text=_('Activate'), toggle=True, icon='MOD_NORMALEDIT')

        sep = layout.separator()

        # draw normals
        row = layout.row(align=True)
        row.active = context.active_object.data.use_auto_smooth
        row.prop(context.active_object.data, 'show_normal_loop', text=_('Show Normals'),
            toggle=True, icon='LOOPSEL')
        row.enabled = is_edit_mode
        row.prop(bpy.context.scene.tool_settings, 'normal_size', text=_('Size'))
        row.enabled = is_edit_mode

        # Split normals
        row = layout.row()
        row.prop(context.window_manager, 'b4w_split', text = _('Split Mode'),
                 toggle=True)
        row.enabled = is_edit_mode
        row.active = context.active_object.data.use_auto_smooth
        # selection tools
        # selected single vertex index
        row.prop(context.active_object, 'b4w_select', text=_('Index'))

        sep = layout.separator()

        row = layout.row()
        row.active = context.active_object.data.use_auto_smooth
        row.operator('object.b4w_normal_rotate', text = p_('Rotate', "Operator"))
        row.enabled = is_edit_mode

        row = layout.row()
        row.active = context.active_object.data.use_auto_smooth
        row.prop(context.window_manager, 'b4w_normal_edit_mode', expand=True)

        if context.window_manager.b4w_normal_edit_mode == "ABSOLUTE":
            # manipulate normals
            row = layout.row()
            row.active = context.active_object.data.use_auto_smooth
            row.column().prop(context.window_manager, 'b4w_vn_customnormal2',
                expand=True, text='')
            row.enabled = is_edit_mode
            # ball
            row.prop(context.window_manager, 'b4w_vn_customnormal1', text='')
            row.enabled = is_edit_mode
        else:
            row = layout.row(align=True)
            row.column(align=True).prop(context.window_manager, 'b4w_customnormal_offset', text='', expand=True)

            row = layout.row(align=True)
            row.operator("object.b4w_apply_offset", text="Sub", icon='ZOOMOUT').sign = -1
            row.operator("object.b4w_apply_offset", text="Add", icon='ZOOMIN').sign = 1

        layout.separator()

        # average
        row = layout.row(align=True)
        row.enabled = is_edit_mode
        row.active = context.active_object.data.use_auto_smooth
        row.operator('object.b4w_smooth_normals', text = p_('Average', "Operator"))

        # restore/smooth
        row = layout.row(align=True)
        row.active = context.active_object.data.use_auto_smooth
        row.operator('object.b4w_restore_normals', text = p_('Restore', "Operator"))
        row.enabled = is_edit_mode

        # copy and paste
        row = layout.row(align=True)
        row.active = context.active_object.data.use_auto_smooth
        row.operator('object.copy_normal', text = p_('Copy', "Operator"), icon='COPYDOWN')
        row.operator('object.paste_normal', text = p_('Paste', "Operator"), icon='PASTEDOWN')
        row.enabled = is_edit_mode

        sep = layout.separator()

        # other edit operations
        row = layout.row(align=True)
        row.active = context.active_object.data.use_auto_smooth
        row.operator('object.tree_vertex_normals', text = p_('Tree', "Operator"))
        row.operator('object.foliage_vertex_normals', text = p_('Foliage', "Operator"))
        row.operator('object.face_vertex_normals', text = p_('Face', "Operator"))
        row.enabled = not context.window_manager.b4w_split and is_edit_mode

        row = layout.row(align=True)
        row.active = context.active_object.data.use_auto_smooth
        if context.window_manager.b4w_copy_normal_method == "MATCHED":
            row.operator('object.copy_normals_from_mesh', text = p_('Copy From Mesh', "Operator"))
        else:
            row.operator('b4w.approx_normals_from_mesh', text = p_('Copy From Mesh', "Operator"))
        row.prop(context.window_manager, 'b4w_copy_normal_method', text='')
        row.enabled = not is_edit_mode