diff --git a/rcg_pipeline/rcg_pipeline/export/obj.py b/rcg_pipeline/rcg_pipeline/export/obj.py new file mode 100644 index 0000000..476d73a --- /dev/null +++ b/rcg_pipeline/rcg_pipeline/export/obj.py @@ -0,0 +1,58 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# Copyright (C) 2024 Ilia Kurochkin +# +# 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 . +# +# ***** 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 diff --git a/rcg_pipeline/rcg_pipeline/libs.py b/rcg_pipeline/rcg_pipeline/libs.py index c01ec89..710b285 100644 --- a/rcg_pipeline/rcg_pipeline/libs.py +++ b/rcg_pipeline/rcg_pipeline/libs.py @@ -46,7 +46,7 @@ from .utils.object_transforms import apply_transforms from .material_generators import material_generator, black_material from .utils.object_converter import mesh_to_mesh from .export import dae, fbx, glb, ply - +import .export.obj as obj_export logger = logging.getLogger(__name__) @@ -188,6 +188,9 @@ def generate_libs_database(project_dir): 'ply': os.path.relpath( ply.export(obj_name=part['name'], file_dir=objects_dir), project_dir), + 'obj': os.path.relpath( + obj_export.export(obj_name=part['name'], file_dir=objects_dir), + project_dir), 'thumbnail': os.path.relpath(img_path, project_dir), } )