2023-12-21 08:45:25 +00: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 <http://www.gnu.org/licenses/>
|
|
|
|
# and write to the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
# Fifth Floor, Boston, MA 02110-1301, USA..
|
|
|
|
#
|
|
|
|
# The Original Code is Copyright (C) 2023 by Kurochkin Ilia ###
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Contact: brothermechanic@yandex.com ###
|
|
|
|
# Information: https://gitlab.com/robossembler ###
|
|
|
|
#
|
|
|
|
# The Original Code is: all of this file.
|
|
|
|
#
|
|
|
|
# ***** END GPL LICENSE BLOCK *****
|
|
|
|
#
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
import bpy
|
|
|
|
|
|
|
|
from bpy.types import (
|
|
|
|
Panel,
|
|
|
|
Operator,
|
|
|
|
PropertyGroup)
|
|
|
|
|
|
|
|
from bpy.props import (
|
|
|
|
StringProperty,
|
|
|
|
EnumProperty,
|
|
|
|
PointerProperty)
|
|
|
|
|
2024-02-24 14:11:29 +03:00
|
|
|
from .io_scene_json import export_json
|
|
|
|
from .io_anim_ros2bag import set_animation_data
|
2023-12-21 08:45:25 +00:00
|
|
|
|
|
|
|
bl_info = {
|
|
|
|
'name': 'Robossembler Tools',
|
|
|
|
'author': 'brothermechanic@gmail.com',
|
2024-02-24 14:11:29 +03:00
|
|
|
'version': (0, 2),
|
|
|
|
'blender': (4, 2, 0),
|
2023-12-21 08:45:25 +00:00
|
|
|
'location': '3D View > Toolbox',
|
|
|
|
'description': 'Robossembler pipeline tools',
|
|
|
|
'warning': '',
|
|
|
|
'wiki_url': '',
|
|
|
|
'tracker_url': 'https://gitlab.com/robossembler',
|
|
|
|
'category': 'Robossembler',
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class addon_Properties(PropertyGroup):
|
|
|
|
|
|
|
|
engine: EnumProperty(
|
|
|
|
name='Physics Engine',
|
|
|
|
description='Selest Target Engine',
|
|
|
|
items=[('BULLET', 'Bullet', ''),
|
|
|
|
('ODE', 'O D E', ''),
|
|
|
|
('SIMBODY', 'Simbody', ''),
|
|
|
|
('OPENSIM', 'OpenSim', '')
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
conf_file_path: StringProperty(
|
|
|
|
name='Config File Path',
|
|
|
|
description='Input/output config file path',
|
|
|
|
default='',
|
|
|
|
maxlen=1023,
|
|
|
|
subtype='FILE_PATH'
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-02-24 14:11:29 +03:00
|
|
|
class RobossemblerPanel1(Panel):
|
|
|
|
''' Robossembler UI'''
|
|
|
|
bl_idname = 'ROBOSSEMBLER_PT_EXPORT_JSON'
|
|
|
|
bl_label = 'Export Scene as Json'
|
2023-12-21 08:45:25 +00:00
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_category = 'Robossembler'
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
prop = context.scene.robossembler_properties
|
|
|
|
|
|
|
|
layout = self.layout
|
|
|
|
layout.prop(prop, 'conf_file_path')
|
|
|
|
layout.prop(prop, 'engine')
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
col.alert = True
|
|
|
|
col.scale_y = 2.0
|
|
|
|
col.operator('export.scene_config',
|
|
|
|
icon='WORLD_DATA',
|
2024-02-24 14:11:29 +03:00
|
|
|
text='Export Scene')
|
|
|
|
|
|
|
|
|
|
|
|
class RobossemblerPanel2(Panel):
|
|
|
|
'''Doc'''
|
|
|
|
bl_idname = 'ROBOSSEMBLER_PT_IMPORT_ANIMATION'
|
|
|
|
bl_label = 'Import Ros2Bag Animation'
|
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'UI'
|
|
|
|
bl_category = 'Robossembler'
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
prop = context.scene.robossembler_properties
|
|
|
|
|
|
|
|
layout = self.layout
|
|
|
|
layout.prop(prop, 'conf_file_path')
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
col.alert = True
|
|
|
|
col.scale_y = 2.0
|
|
|
|
col.operator('export.scene_config',
|
|
|
|
icon='ACTION',
|
|
|
|
text='Import Animation')
|
2023-12-21 08:45:25 +00:00
|
|
|
|
|
|
|
|
2024-02-24 14:11:29 +03:00
|
|
|
class RobossemblerOperator1(Operator):
|
2023-12-21 08:45:25 +00:00
|
|
|
'''Tooltip'''
|
|
|
|
bl_idname = 'export.scene_config'
|
|
|
|
bl_label = ''
|
2024-02-24 14:11:29 +03:00
|
|
|
bl_description = 'Export scene liks to json config.'
|
2023-12-21 08:45:25 +00:00
|
|
|
bl_options = {'REGISTER', 'UNDO'}
|
|
|
|
|
|
|
|
def execute(self, context):
|
|
|
|
prop = context.scene.robossembler_properties
|
|
|
|
|
2024-02-24 14:11:29 +03:00
|
|
|
file_path = os.path.realpath(bpy.path.abspath((prop.conf_file_path)))
|
2023-12-21 08:45:25 +00:00
|
|
|
physics_engine = prop.engine
|
2024-02-24 14:11:29 +03:00
|
|
|
export_json(context, file_path, physics_engine)
|
|
|
|
|
|
|
|
return {'FINISHED'}
|
|
|
|
|
|
|
|
|
|
|
|
class RobossemblerOperator2(Operator):
|
|
|
|
'''Tooltip'''
|
|
|
|
bl_idname = 'export.scene_config'
|
|
|
|
bl_label = ''
|
|
|
|
bl_description = 'Export scene liks to json config.'
|
|
|
|
bl_options = {'REGISTER', 'UNDO'}
|
|
|
|
|
|
|
|
def execute(self, context):
|
|
|
|
prop = context.scene.robossembler_properties
|
|
|
|
|
|
|
|
file_path = os.path.realpath(bpy.path.abspath((prop.conf_file_path)))
|
|
|
|
set_animation_data(context, file_path)
|
2023-12-21 08:45:25 +00:00
|
|
|
|
|
|
|
return {'FINISHED'}
|
|
|
|
|
|
|
|
|
|
|
|
classes = (
|
2024-02-24 14:11:29 +03:00
|
|
|
RobossemblerPanel1,
|
|
|
|
RobossemblerPanel2,
|
|
|
|
RobossemblerOperator1,
|
|
|
|
RobossemblerOperator2,
|
2023-12-21 08:45:25 +00:00
|
|
|
addon_Properties)
|
|
|
|
|
|
|
|
|
|
|
|
def register():
|
|
|
|
for cls in classes:
|
|
|
|
bpy.utils.register_class(cls)
|
|
|
|
bpy.types.Scene.robossembler_properties = PointerProperty(type=addon_Properties)
|
|
|
|
|
|
|
|
|
|
|
|
def unregister():
|
|
|
|
for cls in classes:
|
|
|
|
bpy.utils.unregister_class(cls)
|
|
|
|
del bpy.types.Scene.robossembler_properties
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
register()
|