Skip to content

Commit 1351858

Browse files
justo46Julius Stotz
and
Julius Stotz
authored
Fixed moving in Blender UI and refresh for relative paths (#18)
* Added Enable/Disable All and the option to select a root directory for relative paths * Added first version of bin file format * Added bin.py * Fixed byte errors and store the rest of the bytes in an (unused) list * Added 1 main commit * Added main commit * Added a button to select multiple sequences * Added the functionality to import multiple sequences (in top menu and in addon), a custom initial transformation matrix and a list, so the file sequences do not have to be loaded again in every frame * Added object property for initial transformation matrix, made for multiple sequence loading cleaner code and tried to resolve the issue with transformation matrices * Added install script * Fixed keyframe animation system to work with other transformations * Optimized adding meshio objects and added a button to refresh the sequences * Fixed keyframe system for multiple files * Deleted install file from repo, since this is a local file. * Resolved further changes * Updated version + test to import MeshIO Objects * Updated version * Deleted some comments and made the code easier to read * Further code improvements * Removed bin.py * Deleted import of bin.py and corrected version * Fixed transforming via viewport (except for .bin) * This breaks the bin format but enables in-view transformations again * Deleted property & Fix refresh for relative paths * Deleted old comment * Added set to timeline button * Set timeline button is atm working on select obj! * Better set timeline button * Fixed start and end frames --------- Co-authored-by: Julius Stotz <jstotz@wilson.informatik.rwth-aachen.de>
1 parent b3caaa4 commit 1351858

File tree

7 files changed

+38
-14
lines changed

7 files changed

+38
-14
lines changed

__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
BSEQ_OT_disable_all,
4747
BSEQ_OT_enable_all,
4848
BSEQ_OT_refresh_sequences,
49+
BSEQ_OT_set_start_end_frames,
4950
WM_OT_batchSequences,
5051
WM_OT_MeshioObject
5152
]

bseq/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from bseq.utils import refresh_obj
2-
from .operators import BSEQ_OT_load, BSEQ_OT_edit, BSEQ_OT_resetpt, BSEQ_OT_resetmesh, BSEQ_OT_resetins, BSEQ_OT_set_as_split_norm, BSEQ_OT_remove_split_norm, BSEQ_OT_disable_selected, BSEQ_OT_enable_selected, BSEQ_OT_refresh_seq, BSEQ_OT_disable_all, BSEQ_OT_enable_all, BSEQ_OT_refresh_sequences, WM_OT_batchSequences, WM_OT_MeshioObject
2+
from .operators import BSEQ_OT_load, BSEQ_OT_edit, BSEQ_OT_resetpt, BSEQ_OT_resetmesh, BSEQ_OT_resetins, BSEQ_OT_set_as_split_norm, BSEQ_OT_remove_split_norm, BSEQ_OT_disable_selected, BSEQ_OT_enable_selected, BSEQ_OT_refresh_seq, BSEQ_OT_disable_all, BSEQ_OT_enable_all, BSEQ_OT_refresh_sequences, BSEQ_OT_set_start_end_frames, WM_OT_batchSequences, WM_OT_MeshioObject
33
from .properties import BSEQ_scene_property, BSEQ_obj_property, BSEQ_mesh_property
44
from .panels import BSEQ_UL_Obj_List, BSEQ_List_Panel, BSEQ_Settings, BSEQ_Import, BSEQ_Templates, BSEQ_UL_Att_List, draw_template
55
from .messenger import subscribe_to_selected, unsubscribe_to_selected
@@ -46,6 +46,7 @@ def BSEQ_initialize(scene):
4646
"BSEQ_OT_disable_all",
4747
"BSEQ_OT_enable_all",
4848
"BSEQ_OT_refresh_sequences",
49+
"BSEQ_OT_set_start_end_frames",
4950
"WM_OT_batchSequences",
5051
"WM_OT_MeshioObject"
5152
]

bseq/importer.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def has_keyframe(obj, attr):
6363

6464
def apply_transformation(meshio_mesh, obj, depsgraph):
6565
# evaluate the keyframe animation system
66-
eval_location = obj.evaluated_get(depsgraph).location if has_keyframe(obj, "location") else None
67-
eval_scale = obj.evaluated_get(depsgraph).scale if has_keyframe(obj, "scale") else None
66+
eval_location = obj.evaluated_get(depsgraph).location if has_keyframe(obj, "location") else obj.location
67+
eval_scale = obj.evaluated_get(depsgraph).scale if has_keyframe(obj, "scale") else obj.scale
6868

6969
if has_keyframe(obj, "rotation_quaternion"):
7070
eval_rotation = obj.evaluated_get(depsgraph).rotation_quaternion
@@ -73,7 +73,7 @@ def apply_transformation(meshio_mesh, obj, depsgraph):
7373
elif has_keyframe(obj, "rotation_euler"):
7474
eval_rotation = obj.evaluated_get(depsgraph).rotation_euler
7575
else:
76-
eval_rotation = None
76+
eval_rotation = obj.rotation_euler
7777

7878
eval_transform_matrix = mathutils.Matrix.LocRotScale(eval_location, eval_rotation, eval_scale)
7979

@@ -83,7 +83,7 @@ def apply_transformation(meshio_mesh, obj, depsgraph):
8383
rigid_body_transformation = meshio_mesh.field_data["transformation_matrix"]
8484

8585
# multiply everything together (with custom transform matrix)
86-
obj.matrix_world = rigid_body_transformation @ obj.BSEQ.initial_transform_matrix @ eval_transform_matrix
86+
obj.matrix_world = rigid_body_transformation @ eval_transform_matrix
8787

8888
def update_mesh(meshio_mesh, mesh):
8989
# extract information from the meshio mesh
@@ -219,8 +219,8 @@ def create_obj(fileseq, use_relative, root_path, transform_matrix=Matrix([[1, 0,
219219
object.BSEQ.pattern = str(fileseq)
220220
object.BSEQ.init = True
221221
object.BSEQ.enabled = enabled
222-
# Flatten custom transformation matrix for the property
223-
object.BSEQ.initial_transform_matrix = [transform_matrix[j][i] for i in range(4) for j in range(4)]
222+
object.BSEQ.start_end_frame = (fileseq.start(), fileseq.end())
223+
object.matrix_world = transform_matrix
224224
driver = object.driver_add("BSEQ.frame")
225225
driver.driver.expression = 'frame'
226226
if enabled:

bseq/operators.py

+17
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,24 @@ def execute(self, context):
315315
scene = context.scene
316316
# call the update function of path by setting it to its own value
317317
scene.BSEQ.path = scene.BSEQ.path
318+
318319
return {"FINISHED"}
320+
321+
class BSEQ_OT_set_start_end_frames(bpy.types.Operator):
322+
'''This changes the timeline start and end frames to the length of a specific sequence'''
323+
bl_label = "Set timeline"
324+
bl_idname = "bseq.set_start_end_frames"
325+
bl_options = {"UNDO"}
326+
327+
def execute(self, context):
328+
scene = context.scene
329+
obj = bpy.data.objects[scene.BSEQ.selected_obj_num]
330+
(start, end) = obj.BSEQ.start_end_frame
331+
scene.frame_start = 0
332+
scene.frame_end = end - start
333+
334+
return {"FINISHED"}
335+
319336

320337
from pathlib import Path
321338
import meshio

bseq/panels.py

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def draw(self, context):
7777
row = layout.row()
7878
row.operator("bseq.enableall", text="Enable All")
7979
row.operator("bseq.disableall", text="Disable All")
80+
row.operator("bseq.set_start_end_frames", text="Set timeline")
8081

8182

8283

bseq/properties.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ class BSEQ_obj_property(bpy.types.PropertyGroup):
8383
use_relative: bpy.props.BoolProperty(default=False)
8484
pattern: bpy.props.StringProperty()
8585
frame: bpy.props.IntProperty()
86-
initial_transform_matrix: bpy.props.FloatVectorProperty(name='Custom Transformation Matrix',
87-
description='Set custom transformation',
88-
size=16,
89-
subtype="MATRIX")
86+
start_end_frame: bpy.props.IntVectorProperty(name="Start and End Frames", size=2, default=(0, 0))
9087

9188
# set this property for mesh, not object (maybe change later?)
9289
class BSEQ_mesh_property(bpy.types.PropertyGroup):

bseq/utils.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,17 @@ def stop_animation():
2929
def refresh_obj(obj, scene):
3030
fs = obj.BSEQ.pattern
3131
if obj.BSEQ.use_relative:
32-
fs = bpy.path.abspath(fs, start=scene.BSEQ.root_path)
32+
if scene.BSEQ.root_path != "":
33+
fs = bpy.path.abspath(fs, start=scene.BSEQ.root_path)
34+
else:
35+
fs = bpy.path.abspath(fs)
3336
fs = fileseq.findSequenceOnDisk(fs)
3437
fs = fileseq.findSequenceOnDisk(fs.dirname() + fs.basename() + "@" + fs.extension())
38+
obj.BSEQ.start_end_frame = (fs.start(), fs.end())
3539
fs = str(fs)
3640
if obj.BSEQ.use_relative:
37-
fs = bpy.path.relpath(fs, start=scene.BSEQ.root_path)
38-
obj.BSEQ.pattern = fs
41+
if scene.BSEQ.root_path != "":
42+
fs = bpy.path.relpath(fs, start=scene.BSEQ.root_path)
43+
else:
44+
fs = bpy.path.relpath(fs)
45+
obj.BSEQ.pattern = fs

0 commit comments

Comments
 (0)