RCG Init: migration from gitlab:robossembler/framework

This commit is contained in:
Игорь Брылёв 2024-12-10 16:25:56 +03:00
parent dc41dd5ab9
commit 768f372edc
94 changed files with 2126 additions and 84 deletions

View file

@ -0,0 +1,77 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2024 Ilia Kurochkin <brothermechanic@yandex.com>
#
# Created by Ilia Kurochkin (brothermechanic)
# contact: brothermechanic@yandex.com
#
# This 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 *****
#
# coding: utf-8
'''
DESCRIPTION.
Decorator for export functions.
'''
import os
import bpy
import mathutils
def export_decorator(func):
def wrapper(**kwargs):
bpy.ops.object.select_all(action='DESELECT')
# add defaults
kwargs.setdefault('global_scale', 1000)
kwargs.setdefault('axis_forward', 'Y')
kwargs.setdefault('axis_up', 'Z')
kwargs.setdefault('file_dir', '//')
kwargs.setdefault('sub_dir', '')
kwargs.setdefault('reset_transforms', False)
if kwargs['reset_transforms']:
obj = bpy.data.objects.get(kwargs['obj_name'])
obj.name = kwargs['obj_name'] + '_orig'
obj_data = obj.data.copy()
obj_tmp = obj.copy()
obj_tmp.data = obj_data
obj_tmp.name = kwargs['obj_name']
bpy.context.collection.objects.link(obj_tmp)
obj_tmp.parent = None
obj_tmp.matrix_world = mathutils.Matrix()
obj = bpy.data.objects.get(kwargs['obj_name'])
# deselect all but just one object and make it active
bpy.ops.object.select_all(action='DESELECT')
obj.select_set(state=True)
bpy.context.view_layer.objects.active = obj
file_dir = os.path.join(kwargs['file_dir'], kwargs['sub_dir'])
os.makedirs(file_dir, exist_ok=True)
kwargs['outpath'] = os.path.join(file_dir, kwargs['obj_name'])
# return export function
file_path = func(**kwargs)
#cleanup temporary object
if kwargs['reset_transforms']:
bpy.data.objects.remove(obj, do_unlink=True)
obj = bpy.data.objects.get(kwargs['obj_name'] + '_orig')
obj.name = kwargs['obj_name']
return file_path
return wrapper

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,75 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2024 Ilia Kurochkin <brothermechanic@yandex.com>
#
# Created by Ilia Kurochkin (brothermechanic)
# contact: brothermechanic@yandex.com
#
# This 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 *****
#
# coding: utf-8
'''
DESCRIPTION.
Collada object exporter.
'''
__version__ = '0.3'
import bpy
from . import export_decorator
@export_decorator
def export(**kwargs):
file_path = ('{}.dae'.format(kwargs['outpath']))
bpy.ops.wm.collada_export(
filepath=file_path,
check_existing=False,
apply_modifiers=True,
export_mesh_type=0,
export_mesh_type_selection='view',
export_global_forward_selection=kwargs['axis_forward'],
export_global_up_selection=kwargs['axis_up'],
apply_global_orientation=False,
selected=True,
include_children=False,
include_armatures=False,
include_shapekeys=False,
deform_bones_only=False,
include_animations=False,
include_all_actions=True,
export_animation_type_selection='sample',
sampling_rate=1,
keep_smooth_curves=False,
keep_keyframes=False,
keep_flat_curves=False,
active_uv_only=False,
use_texture_copies=True,
triangulate=True,
use_object_instantiation=True,
use_blender_profile=True,
sort_by_name=False,
export_object_transformation_type=0,
export_object_transformation_type_selection='matrix',
export_animation_transformation_type=0,
export_animation_transformation_type_selection='matrix',
open_sim=False,
limit_precision=False,
keep_bind_info=False)
return file_path

View file

@ -0,0 +1,84 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2024 Ilia Kurochkin <brothermechanic@yandex.com>
#
# Created by Ilia Kurochkin (brothermechanic)
# contact: brothermechanic@yandex.com
#
# This 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 *****
#
# coding: utf-8
'''
DESCRIPTION.
FBX object exporter.
'''
__version__ = "0.3"
import bpy
from . import export_decorator
@export_decorator
def export(**kwargs):
file_path = ('{}.fbx'.format(kwargs['outpath']))
bpy.ops.export_scene.fbx(
filepath=file_path,
check_existing=False,
filter_glob="*.fbx",
use_selection=True,
use_visible=False,
use_active_collection=False,
global_scale=1,
apply_unit_scale=True,
apply_scale_options='FBX_SCALE_NONE',
use_space_transform=True,
bake_space_transform=False,
object_types={'MESH'},
use_mesh_modifiers=True,
use_mesh_modifiers_render=True,
mesh_smooth_type='FACE',
colors_type='SRGB',
use_subsurf=False,
use_mesh_edges=False,
use_tspace=False,
use_triangles=True,
use_custom_props=False,
add_leaf_bones=True,
primary_bone_axis='Y',
secondary_bone_axis='X',
use_armature_deform_only=False,
armature_nodetype='NULL',
bake_anim=False,
bake_anim_use_all_bones=True,
bake_anim_use_nla_strips=True,
bake_anim_use_all_actions=True,
bake_anim_force_startend_keying=True,
bake_anim_step=1,
bake_anim_simplify_factor=1,
path_mode='AUTO',
embed_textures=False,
batch_mode='OFF',
use_batch_own_dir=True,
use_metadata=True,
# '-Z'
axis_forward=kwargs['axis_forward'],
# 'Y'
axis_up=kwargs['axis_up'])
return file_path

View file

@ -0,0 +1,84 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2024 Ilia Kurochkin <brothermechanic@yandex.com>
#
# Created by Ilia Kurochkin (brothermechanic)
# contact: brothermechanic@yandex.com
#
# This 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 *****
#
# coding: utf-8
'''
DESCRIPTION.
glTF object exporter.
'''
__version__ = "0.3"
import bpy
from . import export_decorator
@export_decorator
def export(**kwargs):
file_path = ('{}.glb'.format(kwargs['outpath']))
bpy.ops.export_scene.gltf(
filepath=file_path,
check_existing=False,
gltf_export_id="",
export_use_gltfpack=False,
export_format='GLB',
export_copyright="glTF object exporter",
export_image_format='AUTO',
export_image_add_webp=False,
export_image_webp_fallback=False,
export_texture_dir="",
export_jpeg_quality=75,
export_image_quality=75,
export_keep_originals=False,
export_texcoords=True,
export_normals=True,
# no custom
export_draco_mesh_compression_enable=False,
export_tangents=False,
export_materials='EXPORT',
export_unused_images=False,
export_unused_textures=False,
export_attributes=False,
# custom
use_selection=True,
use_visible=False,
use_renderable=False,
use_active_collection_with_nested=True,
use_active_collection=False,
use_active_scene=False,
export_extras=False,
# no custom
export_yup=True,
export_apply=False,
# custom
export_animations=False,
# custom
export_morph=False,
export_skins=False,
export_hierarchy_flatten_bones=False,
export_original_specular=False,
will_save_settings=False,
export_hierarchy_full_collections=False)
return file_path

View file

@ -0,0 +1,58 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2024 Ilia Kurochkin <brothermechanic@yandex.com>
#
# Created by Ilia Kurochkin (brothermechanic)
# contact: brothermechanic@yandex.com
#
# This 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 *****
#
# coding: utf-8
'''
DESCRIPTION.
obj object exporter.
'''
__version__ = "0.1"
import bpy
from . import export_decorator
@export_decorator
def export(**kwargs):
file_path = ('{}.obj'.format(kwargs['outpath']))
bpy.ops.wm.obj_export(
filepath=file_path,
check_existing=False,
export_animation=False,
forward_axis='NEGATIVE_Z',
up_axis='Y',
global_scale=1,
apply_modifiers=True,
export_selected_objects=True,
export_uv=True,
export_normals=True,
export_colors=True,
export_materials=True,
export_pbr_extensions=False,
path_mode='AUTO',
export_triangulated_mesh=True,
export_smooth_groups=True)
return file_path

View file

@ -0,0 +1,55 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2024 Ilia Kurochkin <brothermechanic@yandex.com>
#
# Created by Ilia Kurochkin (brothermechanic)
# contact: brothermechanic@yandex.com
#
# This 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 *****
#
# coding: utf-8
'''
DESCRIPTION.
PLY object exporter.
'''
__version__ = "0.3"
import bpy
from . import export_decorator
@export_decorator
def export(**kwargs):
file_path = ('{}.ply'.format(kwargs['outpath']))
bpy.ops.wm.ply_export(
filepath=file_path,
check_existing=False,
forward_axis=kwargs['axis_forward'],
up_axis=kwargs['axis_up'],
global_scale=kwargs['global_scale'],
apply_modifiers=True,
export_selected_objects=True,
export_uv=True,
export_normals=True,
export_colors='SRGB',
export_attributes=True,
export_triangulated_mesh=True,
ascii_format=True)
return file_path

View file

@ -0,0 +1,52 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2024 Ilia Kurochkin <brothermechanic@yandex.com>
#
# Created by Ilia Kurochkin (brothermechanic)
# contact: brothermechanic@yandex.com
#
# This 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 *****
#
# coding: utf-8
'''
DESCRIPTION.
STL object exporter.
'''
__version__ = '0.3'
import bpy
from . import export_decorator
@export_decorator
def export(**kwargs):
file_path = ('{}.stl'.format(kwargs['outpath']))
bpy.ops.wm.stl_export(
filepath=file_path,
check_existing=False,
ascii_format=False,
use_batch=False,
export_selected_objects=True,
global_scale=kwargs['global_scale'],
use_scene_unit=False,
forward_axis=kwargs['axis_forward'],
up_axis=kwargs['axis_up'],
apply_modifiers=True)
return file_path