Newer
Older
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"author": "Vilem Duha, Petr Dlouhy",
"version": (2, 93, 0),
"blender": (2, 93, 0),
"description": "Online BlenderKit library (materials, models, brushes and more). Connects to the internet.",
"doc_url": "{BLENDER_MANUAL_URL}/addons/3d_view/blenderkit.html",
# alphabetically sorted all add-on modules since reload only happens from __init__.
# modules with _bg are used for background computations in separate blender instance and that's why they don't need reload.
asset_inspector = reload(asset_inspector)
autothumb = reload(autothumb)
bg_blender = reload(bg_blender)
bkit_oauth = reload(bkit_oauth)
categories = reload(categories)
colors = reload(colors)
download = reload(download)
icons = reload(icons)
image_utils = reload(image_utils)
oauth = reload(oauth)
overrides = reload(overrides)
paths = reload(paths)
ratings = reload(ratings)
search = reload(search)
tasks_queue = reload(tasks_queue)
ui = reload(ui)
ui_bgl = reload(ui_bgl)
ui_panels = reload(ui_panels)
upload = reload(upload)
upload_bg = reload(upload_bg)
bl_ui_label = reload(bl_ui_label)
bl_ui_button = reload(bl_ui_button)
# bl_ui_checkbox = reload(bl_ui_checkbox)
# bl_ui_slider = reload(bl_ui_slider)
# bl_ui_up_down = reload(bl_ui_up_down)
bl_ui_drag_panel = reload(bl_ui_drag_panel)
bl_ui_draw_op = reload(bl_ui_draw_op)
# bl_ui_textbox = reload(bl_ui_textbox)
from blenderkit import asset_inspector
from blenderkit import autothumb
from blenderkit import bg_blender
from blenderkit import bkit_oauth
from blenderkit import categories
from blenderkit import colors
from blenderkit import download
from blenderkit import icons
from blenderkit import image_utils
from blenderkit import oauth
from blenderkit import overrides
from blenderkit import paths
from blenderkit import ratings
from blenderkit import resolutions
from blenderkit import search
from blenderkit import tasks_queue
from blenderkit import ui
from blenderkit import ui_bgl
from blenderkit import ui_panels
from blenderkit import upload
from blenderkit import upload_bg
from blenderkit.bl_ui_widgets import bl_ui_label
from blenderkit.bl_ui_widgets import bl_ui_button
# from blenderkit.bl_ui_widgets import bl_ui_checkbox
# from blenderkit.bl_ui_widgets import bl_ui_slider
# from blenderkit.bl_ui_widgets import bl_ui_up_down
from blenderkit.bl_ui_widgets import bl_ui_drag_panel
from blenderkit.bl_ui_widgets import bl_ui_draw_op
# from blenderkit.bl_ui_widgets import bl_ui_textbox
Vilém Duha
committed
import pathlib
log = logging.getLogger(__name__)
from bpy.app.handlers import persistent
import bpy.utils.previews
import mathutils
from mathutils import Vector
from bpy.props import (
IntProperty,
FloatProperty,
FloatVectorProperty,
StringProperty,
EnumProperty,
BoolProperty,
PointerProperty,
)
from bpy.types import (
Operator,
Panel,
AddonPreferences,
PropertyGroup,
)
# logging.basicConfig(filename = 'blenderkit.log', level = logging.INFO,
# format = ' %(asctime)s:%(filename)s:%(funcName)s:%(lineno)d:%(message)s')
@persistent
def scene_load(context):
if not bpy.app.background:
search.load_previews()
ui_props = bpy.context.scene.blenderkitUI
ui_props.assetbar_on = False
ui_props.turn_off = False
preferences = bpy.context.preferences.addons['blenderkit'].preferences
preferences.login_attempt = False
def check_timers_timer():
''' checks if all timers are registered regularly. Prevents possible bugs from stopping the addon.'''
if not bpy.app.timers.is_registered(search.search_timer):
bpy.app.timers.register(search.search_timer)
if not bpy.app.timers.is_registered(download.download_timer):
bpy.app.timers.register(download.download_timer)
if not (bpy.app.timers.is_registered(tasks_queue.queue_worker)):
bpy.app.timers.register(tasks_queue.queue_worker)
if not bpy.app.timers.is_registered(bg_blender.bg_update):
bpy.app.timers.register(bg_blender.bg_update)
return 5.0
('NEW', 'New', 'Shiny new item'),
('USED', 'Used', 'Casually used item'),
('OLD', 'Old', 'Old item'),
('DESOLATE', 'Desolate', 'Desolate item - dusty & rusty'),
)
model_styles = (
('REALISTIC', 'Realistic', "Photo realistic model"),
('PAINTERLY', 'Painterly', 'Hand painted with visible strokes'),
('LOWPOLY', 'Lowpoly', "Lowpoly art -don't mix up with polycount!"),
('ANIME', 'Anime', 'Anime style'),
('2D_VECTOR', '2D Vector', '2D vector'),
('3D_GRAPHICS', '3D Graphics', '3D graphics'),
('REALISTIC', 'Realistic', "Photo realistic model"),
('PAINTERLY', 'Painterly', 'Hand painted with visible strokes'),
('LOWPOLY', 'Lowpoly', "Lowpoly art -don't mix up with polycount!"),
('ANIME', 'Anime', 'Anime style'),
('2D_VECTOR', '2D Vector', '2D vector'),
('3D_GRAPHICS', '3D Graphics', '3D graphics'),
('OTHER', 'Other', 'Other Style'),
('ANY', 'Any', 'Any Style'),
)
material_styles = (
('REALISTIC', 'Realistic', "Photo realistic model"),
('NPR', 'Non photorealistic', 'Hand painted with visible strokes'),
('OTHER', 'Other', 'Other style'),
)
search_material_styles = (
('REALISTIC', 'Realistic', "Photo realistic model"),
('NPR', 'Non photorealistic', 'Hand painted with visible strokes'),
('CYCLES', 'Cycles', 'Blender Cycles'),
('EEVEE', 'Eevee', 'Blender eevee renderer'),
('OCTANE', 'Octane', 'Octane render enginge'),
('ARNOLD', 'Arnold', 'Arnold render engine'),
('V-RAY', 'V-Ray', 'V-Ray renderer'),
('UNREAL', 'Unreal', 'Unreal engine'),
('UNITY', 'Unity', 'Unity engine'),
('GODOT', 'Godot', 'Godot engine'),
('3D-PRINT', '3D printer', 'object can be 3D printed'),
Vilem Duha
committed
('NONE', 'None', 'no more engine block'),
)
pbr_types = (
('METALLIC', 'Metallic-Roughness', 'Metallic/Roughness PBR material type'),
('SPECULAR', 'Specular Glossy', ''),
)
mesh_poly_types = (
('QUAD', 'quad', ''),
('QUAD_DOMINANT', 'quad_dominant', ''),
('TRI_DOMINANT', 'tri_dominant', ''),
('TRI', 'tri', ''),
('NGON', 'ngon_dominant', ''),
('OTHER', 'other', ''),
)
def udate_down_up(self, context):
"""Perform a search if results are empty."""
s = context.scene
if wm.get('search results') == None and props.down_up == 'SEARCH':
def switch_search_results(self, context):
s = bpy.context.scene
props = s.blenderkitUI
if props.asset_type == 'MODEL':
wm['search results'] = wm.get('bkit model search')
wm['search results orig'] = wm.get('bkit model search orig')
wm['search results'] = wm.get('bkit scene search')
wm['search results orig'] = wm.get('bkit scene search orig')
wm['search results'] = wm.get('bkit hdr search')
wm['search results orig'] = wm.get('bkit hdr search orig')
wm['search results'] = wm.get('bkit material search')
wm['search results orig'] = wm.get('bkit material search orig')
wm['search results'] = wm.get('bkit texture search')
wm['search results orig'] = wm.get('bkit texture search orig')
wm['search results'] = wm.get('bkit brush search')
wm['search results orig'] = wm.get('bkit brush search orig')
if not (context.sculpt_object or context.image_paint_object):
ui.add_report(
'Switch to paint or sculpt mode to search in BlenderKit brushes.')
if wm['search results'] == None and props.down_up == 'SEARCH':
'''
Returns
items for Enum property, depending on the down_up property - BlenderKit is either in search or in upload mode.
'''
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
if self.down_up == 'SEARCH':
items = (
('MODEL', 'Models', 'Find models', 'OBJECT_DATAMODE', 0),
('MATERIAL', 'Materials', 'Find materials', 'MATERIAL', 2),
# ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
('SCENE', 'Scenes', 'Find scenes', 'SCENE_DATA', 3),
('HDR', 'HDRs', 'Find HDRs', 'WORLD', 4),
('BRUSH', 'Brushes', 'Find brushes', 'BRUSH_DATA', 5)
('MODEL', 'Model', 'Upload a model', 'OBJECT_DATAMODE', 0),
# ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
('MATERIAL', 'Material', 'Upload a material', 'MATERIAL', 2),
# ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
('SCENE', 'Scene', 'Upload a scene', 'SCENE_DATA', 3),
('HDR', 'HDR', 'Upload a HDR', 'WORLD', 4),
('BRUSH', 'Brush', 'Upload a brush', 'BRUSH_DATA', 5)
class BlenderKitUIProps(PropertyGroup):
down_up: EnumProperty(
name="Download vs Upload",
items=(
('SEARCH', 'Search', 'Activate searching', 'VIEWZOOM', 0),
('UPLOAD', 'Upload', 'Activate uploading', 'COPYDOWN', 1),
# ('RATING', 'Rating', 'Activate rating', 'SOLO_ON', 2)
Loading
Loading full blame...