Files
multi-user/multi_user/io_bpy/bl_texture.py

76 lines
2.0 KiB
Python
Raw Normal View History

2020-12-02 11:24:26 +01:00
# ##### 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 3 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, see <https://www.gnu.org/licenses/>.
#
# ##### END GPL LICENSE BLOCK #####
import bpy
import mathutils
from .dump_anything import Loader, Dumper
from .bl_datablock import BlDatablock
class BlTexture(BlDatablock):
bl_id = "textures"
bl_class = bpy.types.Texture
bl_check_common = False
bl_icon = 'TEXTURE'
bl_reload_parent = False
2020-12-02 11:24:26 +01:00
def load(data: dict, datablock: object):
2020-12-02 11:24:26 +01:00
loader = Loader()
loader.load(target, data)
def construct(data: dict) -> object:
2020-12-02 11:24:26 +01:00
return bpy.data.textures.new(data["name"], data["type"])
def dump(datablock: object) -> dict:
2020-12-02 11:24:26 +01:00
assert(instance)
dumper = Dumper()
dumper.depth = 1
2020-12-02 16:25:40 +01:00
dumper.exclude_filter = [
'tag',
'original',
2020-12-02 18:13:11 +01:00
'users',
2020-12-02 16:25:40 +01:00
'uuid',
'is_embedded_data',
'is_evaluated',
'name_full'
]
2020-12-02 11:24:26 +01:00
data = dumper.dump(instance)
color_ramp = getattr(instance, 'color_ramp', None)
if color_ramp:
dumper.depth = 4
data['color_ramp'] = dumper.dump(color_ramp)
return data
@staticmethod
def resolve_deps(datablock: object) -> [object]:
2020-12-02 11:24:26 +01:00
deps = []
image = getattr(datablock,"image", None)
2020-12-02 11:24:26 +01:00
if image:
deps.append(image)
return deps