Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add feature - export particle objects as multimeshinstance to godot #354

Merged
merged 16 commits into from
Nov 13, 2020
Prev Previous commit
Next Next commit
pep8 line length
  • Loading branch information
U-TTE\celpec committed Oct 27, 2020
commit 947d75ea9400122d7099fd2cee11a52c09dac1cd
24 changes: 11 additions & 13 deletions io_scene_godot/converters/multimesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def export_multimesh_node(escn_file, export_settings,
ob = context.object.evaluated_get(dg)

ps = ob.particle_systems.active
epth marked this conversation as resolved.
Show resolved Hide resolved
if ps.settings.instance_collection and ps.settings.instance_collection.all_objects[0]:
if (ps.settings.instance_collection and
epth marked this conversation as resolved.
Show resolved Hide resolved
ps.settings.instance_collection.all_objects[0]):
instance_object = ps.settings.instance_collection.all_objects[0]
elif ps.settings.instance_object:
instance_object = ps.settings.instance_object
Expand All @@ -24,15 +25,7 @@ def export_multimesh_node(escn_file, export_settings,

# Export instance mesh resource first
instance_mesh_exporter = ArrayMeshResourceExporter(instance_object)
# armature_obj = None
# if "ARMATURE" in export_settings['object_types']:
# armature_obj = get_modifier_armature(obj)
# if armature_obj:
# instance_mesh_exporter.init_mesh_bones_data(armature_obj, export_settings)
# # set armature to REST so current pose does not affect converted
# # meshes.
# armature_pose_position = armature_obj.data.pose_position
# armature_obj.data.pose_position = "REST"

mesh_id = instance_mesh_exporter.export_mesh(escn_file, export_settings)

multimeshExporter = MultiMeshResourceExporter(obj, mesh_id, ps)
Expand Down Expand Up @@ -84,8 +77,10 @@ def export_multimesh(self, escn_file, export_settings, particle_name):
len(self.particle_system.particles))
self.mesh_resource['mesh'] = 'SubResource({})'.format(
self.instance_mesh_id)
self.mesh_resource['transform_array'] = 'PoolVector3Array({})'.format(
self.mesh_resource['transform_array'] = (
'PoolVector3Array({})'.format(
converter.to_multimesh())
)

multimesh_id = escn_file.add_internal_resource(
self.mesh_resource, key)
Expand Down Expand Up @@ -132,7 +127,8 @@ def __init__(self, name):


class MultiMeshConverter:
"""Blender Particles' mat4x4 to Godot MultiMesh resource PoolVector3Array"""
"""Blender Particles' mat4x4 to
Godot MultiMesh resource PoolVector3Array"""

def __init__(self, particle_system):
self.particle_system = particle_system
Expand Down Expand Up @@ -164,7 +160,9 @@ def to_multimesh(self):
mat_rot = rot.to_matrix()
mat_trans = mathutils.Matrix.Translation(loc)

mat = mat_trans @ mat_rot.to_4x4() @ mat_sca_x @ mat_sca_y @ mat_sca_z
mat = (
mat_trans @ mat_rot.to_4x4() @ mat_sca_x @ mat_sca_y @ mat_sca_z
)

mat4 = mat.to_4x4()

Expand Down