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

Fixed moving in Blender UI and refresh for relative paths #18

Merged
merged 32 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
25216ea
Added Enable/Disable All and the option to select a root directory fo…
Dec 7, 2022
2344d8e
Added first version of bin file format
justo46 Mar 7, 2023
0f575de
Added bin.py
justo46 Mar 9, 2023
cf201a8
Fixed byte errors and store the rest of the bytes in an (unused) list
justo46 Mar 13, 2023
66a2180
Added 1 main commit
justo46 Mar 13, 2023
7cb6fe1
Added main commit
justo46 Mar 13, 2023
f410be3
Merge commit
justo46 Mar 13, 2023
5f8be5a
Added a button to select multiple sequences
justo46 Mar 15, 2023
30cd9b4
Added the functionality to import multiple sequences (in top menu and…
justo46 Mar 27, 2023
ea852b9
Added object property for initial transformation matrix, made for mul…
justo46 Mar 27, 2023
341cbad
Added install script
justo46 Mar 29, 2023
fb9f982
Fixed keyframe animation system to work with other transformations
justo46 Mar 29, 2023
f6c5ac2
Optimized adding meshio objects and added a button to refresh the seq…
justo46 Mar 29, 2023
c8d12e2
Fixed keyframe system for multiple files
justo46 Mar 31, 2023
31fc32b
Merge remote-tracking branch 'upstream/main'
justo46 Mar 31, 2023
7c276a0
Deleted install file from repo, since this is a local file.
justo46 Mar 31, 2023
53d9cfd
Resolved further changes
justo46 Mar 31, 2023
f38ae77
Updated version + test to import MeshIO Objects
justo46 Mar 31, 2023
1903ce3
Updated version
justo46 Mar 31, 2023
a7d5e99
Deleted some comments and made the code easier to read
justo46 Mar 31, 2023
d9bebfa
Further code improvements
justo46 Mar 31, 2023
785d229
Removed bin.py
justo46 Mar 31, 2023
7f70202
Deleted import of bin.py and corrected version
justo46 Mar 31, 2023
c120f7d
Fixed transforming via viewport (except for .bin)
justo46 Apr 7, 2023
d9d5c78
This breaks the bin format but enables in-view transformations again
justo46 Apr 17, 2023
784954a
Merge branch 'main' of https://github.com/justo46/blender-sequence-lo…
justo46 Apr 17, 2023
7ac8423
Deleted property & Fix refresh for relative paths
justo46 May 4, 2023
5d962fc
Deleted old comment
justo46 May 4, 2023
0b984c3
Added set to timeline button
justo46 May 4, 2023
c799519
Set timeline button is atm working on select obj!
justo46 May 4, 2023
1b8c070
Better set timeline button
justo46 May 10, 2023
2fcf0a7
Fixed start and end frames
justo46 May 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Deleted some comments and made the code easier to read
  • Loading branch information
justo46 committed Mar 31, 2023
commit a7d5e99625fcc5a32065e5d83e7320bf631ad9cc
1 change: 0 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
bpy.context.preferences.filepaths.use_relative_paths = False

from bseq import *

from bseq.operators import menu_func_import

classes = [
Expand Down
37 changes: 4 additions & 33 deletions additional_file_formats/bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def readBIN_to_meshio(filepath):
# currently assume that numBodies is always 1
(numBodies,), bytes = struct.unpack('i', bytes[:4]), bytes[4:]
numBodies *= isFirstFile
#print("numBodies: ", numBodies)

field_datas = []
for i in range(0, numBodies):
Expand All @@ -30,8 +29,6 @@ def readBIN_to_meshio(filepath):
if i == 0:
objFileString = objFile.decode('ascii')

#print("objFileString: ", objFileString)

cur_field_data = {}
cur_field_data["translation"] = None
cur_field_data["scaling"] = None
Expand Down Expand Up @@ -60,8 +57,6 @@ def readBIN_to_meshio(filepath):
dirPath = os.path.dirname(filepath)
objPath = os.path.join(dirPath, objFileString)

#print("Tried to load object at path: ", objPath)

mesh = meshio.read(objPath)
else:
otherFile = open(filepath, 'rb')
Expand All @@ -73,13 +68,6 @@ def readBIN_to_meshio(filepath):
# since there is no object referenced, create empty mesh
mesh = meshio.Mesh([], [])

#print("Field Data List:", field_datas)
#print()
#print("Bytes left:", len(bytes))
#print()

#print(mesh.points)

i = 0
while len(bytes) != 0:
cur_field_data = {}
Expand Down Expand Up @@ -107,17 +95,10 @@ def readBIN_to_meshio(filepath):
rotationMatrix[2][0:3] = r[2], r[5], r[8]

cur_field_data["rotation"] = rotationMatrix.to_quaternion()

cur_field_data["transformation_matrix"] = mathutils.Matrix.LocRotScale(cur_field_data["translation"], cur_field_data["rotation"], cur_field_data["scaling"])

#print("Translation:")
#print(cur_field_data["translation"])
#print("Rotation:")
#print(cur_field_data["rotation"])
#print("Scaling:")
#print(cur_field_data["scaling"])
#print("Transformation matrix:")
#print(cur_field_data["transformation_matrix"])
cur_field_data["transformation_matrix"] = mathutils.Matrix.LocRotScale(
cur_field_data["translation"],
cur_field_data["rotation"],
cur_field_data["scaling"])

if isFirstFile:
field_datas[i]["translation"] = cur_field_data["translation"]
Expand All @@ -131,17 +112,7 @@ def readBIN_to_meshio(filepath):

mesh.field_data = field_datas[0]

#print("Field data:")
#print(mesh.field_data)

return mesh

#print("-----------------------")
#print(objPath)
#print("-----------------------")
bpy.ops.import_scene.obj(filepath=objPath)

return meshio.Mesh([], [], field_data=field_data)

# no need for write function
meshio.register_format("bin", [".bin"], readBIN_to_meshio, {".bin": None})
2 changes: 1 addition & 1 deletion bseq/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def update_mesh(meshio_mesh, mesh):
faces_loop_start = np.roll(faces_loop_start, 1)
faces_loop_start[0] = 0


if len(mesh.vertices) == n_verts and len(mesh.polygons) == n_poly and len(mesh.loops) == n_loop:
pass
else:
Expand Down Expand Up @@ -224,6 +223,7 @@ def create_obj(fileseq, use_relative, root_path, transform_matrix=Matrix([[1, 0,
object.BSEQ.pattern = str(fileseq)
object.BSEQ.init = True
object.BSEQ.enabled = enabled
# Flatten custom transformation matrix for the property
object.BSEQ.initial_transform_matrix = [transform_matrix[j][i] for i in range(4) for j in range(4)]
driver = object.driver_add("BSEQ.frame")
driver.driver.expression = 'frame'
Expand Down
34 changes: 16 additions & 18 deletions bseq/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ def execute(self, context):
show_message_box(traceback.format_exc(), "Can't find sequence: " + str(fs), "ERROR")
return {"CANCELLED"}

transform_matrix = Matrix.Identity(4)
if importer_prop.use_custom_transform:
transform_matrix = Matrix.LocRotScale(importer_prop.custom_location, importer_prop.custom_rotation, importer_prop.custom_scale)
transform_matrix = (Matrix.LocRotScale(
importer_prop.custom_location,
importer_prop.custom_rotation,
importer_prop.custom_scale)
if importer_prop.use_custom_transform else Matrix.Identity(4))

create_obj(fs, importer_prop.relative, importer_prop.root_path, transform_matrix=transform_matrix)
return {"FINISHED"}
Expand Down Expand Up @@ -332,24 +334,20 @@ def execute(self, context):
importer_prop = scene.BSEQ

folder = Path(self.filepath)
used_seqs = []
used_seqs = set()

for selection in self.files:
# Check if there exists a matching file sequence for every selection
fp = str(Path(folder.parent, selection.name))

seqs = fileseq.findSequencesOnDisk(str(folder.parent))

for s in seqs:
if fp in list(s) and s not in used_seqs:
transform_matrix = Matrix.Identity(4)
if importer_prop.use_custom_transform:
transform_matrix = Matrix.LocRotScale(importer_prop.custom_location, importer_prop.custom_rotation, importer_prop.custom_scale)

create_obj(s, False, importer_prop.root_path, transform_matrix=transform_matrix)

used_seqs.append(s)
break
# load that specific file sequence (only if it is not already in the scene)
#bpy.ops.sequence.load()
matching_seqs = [s for s in seqs if fp in list(s) and s not in used_seqs]

if matching_seqs:
s = matching_seqs[0]
transform_matrix = (Matrix.LocRotScale(importer_prop.custom_location, importer_prop.custom_rotation, importer_prop.custom_scale)
if importer_prop.use_custom_transform else Matrix.Identity(4))
create_obj(s, False, importer_prop.root_path, transform_matrix=transform_matrix)
used_seqs.add(s)
return {'FINISHED'}

class WM_OT_MeshioObject(bpy.types.Operator, ImportHelper):
Expand Down