Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
materials: StringProperty(
name="Material Names",
description="names of materials in the file, autofilled",
default="",
)
shaders: StringProperty(
name="Shaders Used",
description="shaders used in asset, autofilled",
default="",
)
dimensions: FloatVectorProperty(
name="Dimensions",
description="dimensions of the whole asset hierarchy",
default=(0, 0, 0),
)
bbox_min: FloatVectorProperty(
name="Bbox Min",
description="dimensions of the whole asset hierarchy",
default=(-.25, -.25, 0),
)
bbox_max: FloatVectorProperty(
name="Bbox Max",
description="dimensions of the whole asset hierarchy",
default=(.25, .25, .5),
)
texture_resolution_min: IntProperty(name="Texture Resolution Min",
description="texture resolution min, autofilled", default=0)
texture_resolution_max: IntProperty(name="Texture Resolution Max",
description="texture resolution max, autofilled", default=0)
pbr: BoolProperty(name="PBR Compatible", description="Is compatible with PBR standard", default=False)
uv: BoolProperty(name="Has UV", description="has an UV set", default=False)
# printable_3d : BoolProperty( name = "3d printable", description = "can be 3d printed", default = False)
animated: BoolProperty(name="Animated", description="is animated", default=False)
face_count: IntProperty(name="Face count", description="face count, autofilled", default=0)
face_count_render: IntProperty(name="Render Face Count", description="render face count, autofilled", default=0)
object_count: IntProperty(name="Number of Objects", description="how many objects are in the asset, autofilled",
default=0)
mesh_poly_type: EnumProperty(
name='Dominant Poly Type',
items=mesh_poly_types,
default='OTHER',
description='',
)
manifold: BoolProperty(name="Manifold", description="asset is manifold, autofilled", default=False)
rig: BoolProperty(name="Rig", description="asset is rigged, autofilled", default=False)
simulation: BoolProperty(name="Simulation", description="asset uses simulation, autofilled", default=False)
'''
filepath : StringProperty(
name="Filepath",
description="file path",
default="",
)
'''
# THUMBNAIL STATES
is_generating_thumbnail: BoolProperty(name="Generating Thumbnail",
description="True when background process is running", default=False,
update=autothumb.update_upload_model_preview)
has_autotags: BoolProperty(name="Has Autotagging Done", description="True when autotagging done", default=False)
class BlenderKitSceneUploadProps(PropertyGroup, BlenderKitCommonUploadProps):
style: EnumProperty(
name="Style",
items=model_styles,
description="Style of asset",
default="REALISTIC",
)
style_other: StringProperty(
name="Style Other",
description="Style not in the list",
default="",
)
engine: EnumProperty(
name='Engine',
items=engines,
default='CYCLES',
description='Output engine',
)
production_level: EnumProperty(
name='Production Level',
items=(
('FINISHED', 'Finished', 'Render or animation ready asset'),
('TEMPLATE', 'Template', 'Asset intended to help in creation of something else'),
),
default='FINISHED',
description='Production state of the asset, \n also template should be actually finished, \n'
'just the nature of it can be a template, like a thumbnailer scene, \n '
Vilem Duha
committed
'finished mesh topology as start for modelling or similar',
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
)
engine_other: StringProperty(
name="Engine",
description="engine not specified by addon",
default="",
)
engine1: EnumProperty(
name='2nd Engine',
items=engines,
default='NONE',
description='Output engine',
)
engine2: EnumProperty(
name='3rd Engine',
items=engines,
default='NONE',
description='Output engine',
)
engine3: EnumProperty(
name='4th Engine',
items=engines,
default='NONE',
description='Output engine',
)
thumbnail: StringProperty(
name="Thumbnail",
description="Path to the thumbnail - 512x512 .jpg image",
subtype='FILE_PATH',
default="",
update=autothumb.update_upload_scene_preview)
use_design_year: BoolProperty(name="Use Design Year",
description="When this thing came into world for the first time\n"
" e.g. for dinosaur, you set -240 million years ;) ",
default=False)
design_year: IntProperty(name="Design Year", description="when was this item designed", default=1960)
# use_age : BoolProperty( name = "use item age", description = "use item age", default = False)
condition: EnumProperty(
items=conditions,
default='UNSPECIFIED',
description='age of the object',
)
adult: BoolProperty(name="Adult Content", description="adult content", default=False)
work_hours: FloatProperty(name="Work Hours", description="How long did it take you to finish the asset?",
default=0.0, min=0.0, max=8760)
modifiers: StringProperty(
name="Modifiers Used",
description="if you need specific modifiers, autofilled",
default="",
)
materials: StringProperty(
name="Material Names",
description="names of materials in the file, autofilled",
default="",
)
shaders: StringProperty(
name="Shaders Used",
description="shaders used in asset, autofilled",
default="",
)
dimensions: FloatVectorProperty(
name="Dimensions",
description="dimensions of the whole asset hierarchy",
default=(0, 0, 0),
)
bbox_min: FloatVectorProperty(
name="Dimensions",
description="dimensions of the whole asset hierarchy",
default=(-.25, -.25, 0),
)
bbox_max: FloatVectorProperty(
name="Dimensions",
description="dimensions of the whole asset hierarchy",
default=(.25, .25, .5),
)
texture_resolution_min: IntProperty(name="Texture Eesolution Min",
description="texture resolution min, autofilled", default=0)
texture_resolution_max: IntProperty(name="Texture Eesolution Max",
description="texture resolution max, autofilled", default=0)
pbr: BoolProperty(name="PBR Compatible", description="Is compatible with PBR standard", default=False)
uv: BoolProperty(name="Has UV", description="has an UV set", default=False)
# printable_3d : BoolProperty( name = "3d printable", description = "can be 3d printed", default = False)
animated: BoolProperty(name="Animated", description="is animated", default=False)
face_count: IntProperty(name="Face Count", description="face count, autofilled", default=0)
face_count_render: IntProperty(name="Render Face Count", description="render face count, autofilled", default=0)
object_count: IntProperty(name="Number of Objects", description="how many objects are in the asset, autofilled",
default=0)
mesh_poly_type: EnumProperty(
name='Dominant Poly Type',
items=mesh_poly_types,
default='OTHER',
description='',
)
rig: BoolProperty(name="Rig", description="asset is rigged, autofilled", default=False)
simulation: BoolProperty(name="Simulation", description="asset uses simulation, autofilled", default=False)
# THUMBNAIL STATES
is_generating_thumbnail: BoolProperty(name="Generating Thumbnail",
description="True when background process is running", default=False,
update=autothumb.update_upload_model_preview)
has_autotags: BoolProperty(name="Has Autotagging Done", description="True when autotagging done", default=False)
class BlenderKitModelSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
search_keywords: StringProperty(
name="Search",
description="Search for these keywords",
default="",
update=search.search_update
)
search_style: EnumProperty(
name="Style",
items=search_model_styles,
description="Keywords defining style (realistic, painted, polygonal, other)",
default="ANY",
update=search.search_update
)
search_style_other: StringProperty(
name="Style",
description="Search style - other",
default="",
update=search.search_update
)
search_engine: EnumProperty(
items=engines,
default='CYCLES',
description='Output engine',
update=search.search_update
)
search_engine_other: StringProperty(
name="Engine",
default="",
update=search.search_update
)
free_only: BoolProperty(name="Free only", description="Show only free models",
default=False, update=search.search_update)
# CONDITION
search_condition: EnumProperty(
items=conditions,
default='UNSPECIFIED',
update=search.search_update
)
search_adult: BoolProperty(
name="Adult Content",
description="You're adult and agree with searching adult content",
default=False,
update=search.search_update
)
# DESIGN YEAR
search_design_year: BoolProperty(name="Sesigned in Year",
description="When the object was approximately designed",
search_design_year_min: IntProperty(name="Minimum Design Year",
description="Minimum design year",
default=1950, min=-100000000, max=1000000000,
update=search.search_update,
)
search_design_year_max: IntProperty(name="Maximum Design Year",
description="Maximum design year",
# POLYCOUNT
search_polycount: BoolProperty(name="Use Polycount",
description="Use polycount of object search tag",
search_polycount_min: IntProperty(name="Min Polycount",
description="Minimum poly count of the asset",
search_polycount_max: IntProperty(name="Max Polycount",
description="Maximum poly count of the asset",
append_method: EnumProperty(
name="Import Method",
items=(
('LINK_COLLECTION', 'Link', 'Link Collection'),
('APPEND_OBJECTS', 'Append', 'Append as Objects'),
description="Appended objects are editable in your scene. Linked assets are saved in original files, "
"aren't editable but also don't increase your file size",
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
)
append_link: EnumProperty(
name="How to Attach",
items=(
('LINK', 'Link', ''),
('APPEND', 'Append', ''),
),
description="choose if the assets will be linked or appended",
default="LINK"
)
import_as: EnumProperty(
name="Import as",
items=(
('GROUP', 'group', ''),
('INDIVIDUAL', 'objects', ''),
),
description="choose if the assets will be linked or appended",
default="GROUP"
)
randomize_rotation: BoolProperty(name='Randomize Rotation',
description="randomize rotation at placement",
default=False)
randomize_rotation_amount: FloatProperty(name="Randomization Max Angle",
description="maximum angle for random rotation",
default=math.pi / 36,
min=0,
max=2 * math.pi,
subtype='ANGLE')
offset_rotation_amount: FloatProperty(name="Offset Rotation",
description="offset rotation, hidden prop",
default=0,
min=0,
max=360,
subtype='ANGLE')
offset_rotation_step: FloatProperty(name="Offset Rotation Step",
description="offset rotation, hidden prop",
default=math.pi / 2,
min=0,
max=180,
subtype='ANGLE')
class BlenderKitSceneSearchProps(PropertyGroup, BlenderKitCommonSearchProps):
search_keywords: StringProperty(
name="Search",
description="Search for these keywords",
default="",
update=search.search_update
)
search_style: EnumProperty(
name="Style",
items=search_model_styles,
description="keywords defining style (realistic, painted, polygonal, other)",
default="ANY",
update=search.search_update
)
search_style_other: StringProperty(
name="Style",
description="Search style - other",
default="",
update=search.search_update
)
search_engine: EnumProperty(
items=engines,
default='CYCLES',
description='Output engine',
update=search.search_update
)
search_engine_other: StringProperty(
name="Engine",
description="engine not specified by addon",
default="",
update=search.search_update
)
Vilém Duha
committed
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
def fix_subdir(self, context):
'''Fixes project subdicrectory settings if people input invalid path.'''
# pp = pathlib.PurePath(self.project_subdir)
pp = self.project_subdir[:]
pp = pp.replace('\\','')
pp = pp.replace('/','')
pp = pp.replace(':','')
pp = '//' + pp
if self.project_subdir != pp:
self.project_subdir = pp
title = "Fixed to relative path"
message = "This path should be always realative.\n" \
" It's a directory BlenderKit creates where your .blend is \n " \
"and uses it for storing assets."
def draw_message(self, context):
ui_panels.label_multiline(self.layout, text=message, icon='NONE', width=400)
bpy.context.window_manager.popup_menu(draw_message, title=title, icon='INFO')
class BlenderKitAddonPreferences(AddonPreferences):
# this must match the addon name, use '__package__'
# when defining this in a submodule of a python package.
bl_idname = __name__
Vilem Duha
committed
default_global_dict = paths.default_global_dict()
api_key: StringProperty(
name="BlenderKit API Key",
Vilem Duha
committed
description="Your blenderkit API Key. Get it from your page on the website",
default="",
subtype="PASSWORD",
update=utils.save_prefs
)
Vilem Duha
committed
api_key_refresh: StringProperty(
name="BlenderKit refresh API Key",
description="API key used to refresh the token regularly.",
default="",
subtype="PASSWORD",
)
api_key_timeout: IntProperty(
name='api key timeout',
description='time where the api key will need to be refreshed',
default=0,
)
api_key_life: IntProperty(
name='api key life time',
description='maximum lifetime of the api key, in seconds',
default=0,
)
refresh_in_progress: BoolProperty(
name="Api key refresh in progress",
description="Api key is currently being refreshed. Don't refresh it again.",
default=False
)
Vilem Duha
committed
login_attempt: BoolProperty(
name="Login/Signup attempt",
description="When this is on, BlenderKit is trying to connect and login",
Vilem Duha
committed
default=False
)
show_on_start: BoolProperty(
name="Show assetbar when starting blender",
description="Show assetbar when starting blender",
default=False
)
tips_on_start: BoolProperty(
name="Show tips when starting blender",
description="Show tips when starting blender",
)
search_in_header: BoolProperty(
name="Show BlenderKit search in 3D view header",
description="Show BlenderKit search in 3D view header",
global_dir: StringProperty(
name="Global Files Directory",
Vilem Duha
committed
description="Global storage for your assets, will use subdirectories for the contents",
subtype='DIR_PATH',
default=default_global_dict,
update=utils.save_prefs
)
project_subdir: StringProperty(
name="Project Assets Subdirectory",
Vilem Duha
committed
description="where data will be stored for individual projects",
Vilém Duha
committed
# subtype='DIR_PATH',
Vilém Duha
committed
update = fix_subdir
)
directory_behaviour: EnumProperty(
name="Use Directories",
items=(
('BOTH', 'Global and subdir',
'store files both in global lib and subdirectory of current project. '
Vilem Duha
committed
'Warning - each file can be many times on your harddrive, but helps you keep your projects in one piece'),
('GLOBAL', 'Global',
"store downloaded files only in global directory. \n "
"This can bring problems when moving your projects, \n"
"since assets won't be in subdirectory of current project"),
('LOCAL', 'Local',
'store downloaded files only in local directory.\n'
' This can use more bandwidth when you reuse assets in different projects. ')
),
description="Which directories will be used for storing downloaded data",
default="BOTH",
)
thumbnail_use_gpu: BoolProperty(
name="Use GPU for Thumbnails Rendering",
Vilem Duha
committed
description="By default this is off so you can continue your work without any lag",
)
panel_behaviour: EnumProperty(
name="Panels Locations",
items=(
('BOTH', 'Both Types',
''),
""),
('LOCAL', 'Relative to Data',
'')
),
description="Which directories will be used for storing downloaded data",
default="UNIFIED",
)
max_assetbar_rows: IntProperty(name="Max Assetbar Rows",
description="max rows of assetbar in the 3D view",
thumb_size: IntProperty(name="Assetbar thumbnail Size", default=96, min=-1, max=256)
asset_counter: IntProperty(name="Usage Counter",
description="Counts usages so it asks for registration only after reaching a limit",
default=0,
min=0,
max=20000)
Vilem Duha
committed
first_run: BoolProperty(
name="First run",
description="Detects if addon was already registered/run.",
use_timers: BoolProperty(
name="Use timers",
description="Use timers for bkit",
default=True,
update=utils.save_prefs
)
# allow_proximity : BoolProperty(
# name="allow proximity data reports",
# description="This sends anonymized proximity data \n \
# and allows us to make relations between database objects \n \
Vilem Duha
committed
# without user interaction",
# default=False
# )
def draw(self, context):
layout = self.layout
layout.prop(self, "show_on_start")
if self.enable_oauth:
ui_panels.draw_login_buttons(layout)
else:
op = layout.operator("wm.url_open", text="Register online and get your API Key",
icon='QUESTION')
op.url = paths.BLENDERKIT_SIGNUP_URL
else:
if self.enable_oauth:
layout.operator("wm.blenderkit_logout", text="Logout",
icon='URL')
layout.prop(self, "api_key", text='Your API Key')
# layout.label(text='After you paste API Key, categories are downloaded, so blender will freeze for a few seconds.')
layout.prop(self, "global_dir")
layout.prop(self, "project_subdir")
# layout.prop(self, "temp_dir")
layout.prop(self, "directory_behaviour")
layout.prop(self, "thumbnail_use_gpu")
# layout.prop(self, "allow_proximity")
# layout.prop(self, "panel_behaviour")
layout.prop(self, "thumb_size")
layout.prop(self, "tips_on_start")
layout.prop(self, "search_in_header")
if bpy.context.preferences.view.show_developer_ui:
layout.prop(self, "use_timers")
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
# registration
classes = (
BlenderKitAddonPreferences,
BlenderKitUIProps,
BlenderKitModelSearchProps,
BlenderKitModelUploadProps,
BlenderKitSceneSearchProps,
BlenderKitSceneUploadProps,
BlenderKitMaterialUploadProps,
BlenderKitMaterialSearchProps,
BlenderKitTextureUploadProps,
BlenderKitBrushSearchProps,
BlenderKitBrushUploadProps,
BlenderKitRatingProps,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.Scene.blenderkitUI = PointerProperty(
type=BlenderKitUIProps)
# MODELS
bpy.types.Scene.blenderkit_models = PointerProperty(
type=BlenderKitModelSearchProps)
bpy.types.Object.blenderkit = PointerProperty( # for uploads, not now...
type=BlenderKitModelUploadProps)
bpy.types.Object.bkit_ratings = PointerProperty( # for uploads, not now...
type=BlenderKitRatingProps)
# SCENES
bpy.types.Scene.blenderkit_scene = PointerProperty(
type=BlenderKitSceneSearchProps)
bpy.types.Scene.blenderkit = PointerProperty( # for uploads, not now...
type=BlenderKitSceneUploadProps)
bpy.types.Scene.bkit_ratings = PointerProperty( # for uploads, not now...
type=BlenderKitRatingProps)
# MATERIALS
bpy.types.Scene.blenderkit_mat = PointerProperty(
type=BlenderKitMaterialSearchProps)
bpy.types.Material.blenderkit = PointerProperty( # for uploads, not now...
type=BlenderKitMaterialUploadProps)
bpy.types.Material.bkit_ratings = PointerProperty( # for uploads, not now...
type=BlenderKitRatingProps)
# BRUSHES
bpy.types.Scene.blenderkit_brush = PointerProperty(
type=BlenderKitBrushSearchProps)
bpy.types.Brush.blenderkit = PointerProperty( # for uploads, not now...
type=BlenderKitBrushUploadProps)
bpy.types.Brush.bkit_ratings = PointerProperty( # for uploads, not now...
type=BlenderKitRatingProps)
search.register_search()
asset_inspector.register_asset_inspector()
download.register_download()
upload.register_upload()
ratings.register_ratings()
autothumb.register_thumbnailer()
ui.register_ui()
ui_panels.register_ui_panels()
bg_blender.register()
utils.load_prefs()
overrides.register_overrides()
bkit_oauth.register()
Vilem Duha
committed
tasks_queue.register()
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
if user_preferences.use_timers:
bpy.app.timers.register(check_timers_timer, persistent=True)
bpy.app.handlers.load_post.append(scene_load)
if bpy.app.timers.is_registered(check_timers_timer):
bpy.app.timers.unregister(check_timers_timer)
ui_panels.unregister_ui_panels()
search.unregister_search()
asset_inspector.unregister_asset_inspector()
download.unregister_download()
upload.unregister_upload()
ratings.unregister_ratings()
autothumb.unregister_thumbnailer()
bg_blender.unregister()
overrides.unregister_overrides()
bkit_oauth.unregister()
Vilem Duha
committed
tasks_queue.unregister()
del bpy.types.Scene.blenderkit_models
del bpy.types.Scene.blenderkit_scene
del bpy.types.Scene.blenderkit_brush
del bpy.types.Scene.blenderkit_mat
del bpy.types.Scene.blenderkit
del bpy.types.Object.blenderkit
del bpy.types.Material.blenderkit
del bpy.types.Brush.blenderkit
for cls in classes:
bpy.utils.unregister_class(cls)
bpy.app.handlers.load_post.remove(scene_load)