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

Import additional format bin #19

Draft
wants to merge 24 commits into
base: opt/bin_loader
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 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
0a6e25c
Corrected version
justo46 Mar 31, 2023
5306141
Merge branch 'InteractiveComputerGraphics:main' into import_bin
justo46 Apr 7, 2023
40c1b52
Added changes in importer.py to this branch
justo46 Apr 20, 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
Next Next commit
Added Enable/Disable All and the option to select a root directory fo…
…r relative paths
  • Loading branch information
Julius Stotz committed Dec 7, 2022
commit 25216eae38add84d17c502c8178e541e7b6954c7
2 changes: 2 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
BSEQ_OT_disable_selected,
BSEQ_OT_enable_selected,
BSEQ_OT_refresh_seq,
BSEQ_OT_disable_all,
BSEQ_OT_enable_all,
]


Expand Down
4 changes: 3 additions & 1 deletion bseq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from bseq.utils import refresh_obj
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
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
from .properties import BSEQ_scene_property, BSEQ_obj_property, BSEQ_mesh_property
from .panels import BSEQ_UL_Obj_List, BSEQ_List_Panel, BSEQ_Settings, BSEQ_Import, BSEQ_Templates, BSEQ_UL_Att_List, draw_template
from .messenger import subscribe_to_selected, unsubscribe_to_selected
Expand Down Expand Up @@ -43,4 +43,6 @@ def BSEQ_initialize(scene):
"BSEQ_OT_disable_selected",
"BSEQ_OT_enable_selected",
"BSEQ_OT_refresh_seq",
"BSEQ_OT_disable_all",
"BSEQ_OT_enable_all",
]
2 changes: 1 addition & 1 deletion bseq/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ def auto_refresh(scene, depsgraph=None):
continue
if obj.mode != "OBJECT":
continue
refresh_obj(obj)
refresh_obj(obj, scene)
10 changes: 5 additions & 5 deletions bseq/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def update_mesh(meshio_mesh, mesh):
mesh.normals_split_custom_set_from_vertices(v)


def create_obj(fileseq, use_relaitve, transform_matrix=Matrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]])):
def create_obj(fileseq, use_relative, root_path, transform_matrix=Matrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]])):

current_frame = bpy.context.scene.frame_current
filepath = fileseq[current_frame % len(fileseq)]
Expand All @@ -156,9 +156,9 @@ def create_obj(fileseq, use_relaitve, transform_matrix=Matrix([[1, 0, 0, 0], [0,
name = fileseq.basename() + "@" + fileseq.extension()
mesh = bpy.data.meshes.new(name)
object = bpy.data.objects.new(name, mesh)
object.BSEQ.use_relative = use_relaitve
if use_relaitve:
object.BSEQ.pattern = bpy.path.relpath(str(fileseq))
object.BSEQ.use_relative = use_relative
if use_relative:
object.BSEQ.pattern = bpy.path.relpath(str(fileseq), start=root_path)
else:
object.BSEQ.pattern = str(fileseq)
object.BSEQ.init = True
Expand Down Expand Up @@ -191,7 +191,7 @@ def update_obj(scene, depsgraph=None):
meshio_mesh = None
pattern = obj.BSEQ.pattern
if obj.BSEQ.use_relative:
pattern = bpy.path.abspath(pattern)
pattern = bpy.path.abspath(pattern, start=scene.BSEQ.root_path)
# in case the blender file was created on windows system, but opened in linux system
pattern = bpy.path.native_pathsep(pattern)
fs = fileseq.FileSequence(pattern)
Expand Down
28 changes: 26 additions & 2 deletions bseq/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def execute(self, context):
show_message_box(traceback.format_exc(), "Can't find sequence: " + str(fs), "ERROR")
return {"CANCELLED"}

create_obj(fs, importer_prop.relative)
create_obj(fs, importer_prop.relative, importer_prop.root_path)
return {"FINISHED"}


Expand Down Expand Up @@ -270,6 +270,30 @@ class BSEQ_OT_refresh_seq(bpy.types.Operator):
def execute(self, context):
scene = context.scene
obj = bpy.data.objects[scene.BSEQ.selected_obj_num]
refresh_obj(obj)
refresh_obj(obj, scene)

return {"FINISHED"}

class BSEQ_OT_disable_all(bpy.types.Operator):
'''This operator disable all selected sequence'''
bl_label = "Disable All Sequences"
bl_idname = "bseq.disableall"
bl_options = {"UNDO"}

def execute(self, context):
for obj in bpy.context.scene.collection.all_objects:
if obj.BSEQ.init and obj.BSEQ.enabled:
obj.BSEQ.enabled = False
return {"FINISHED"}

class BSEQ_OT_enable_all(bpy.types.Operator):
'''This operator enable all selected sequence'''
bl_label = "Enable All Sequences"
bl_idname = "bseq.enableall"
bl_options = {"UNDO"}

def execute(self, context):
for obj in bpy.context.scene.collection.all_objects:
if obj.BSEQ.init and not obj.BSEQ.enabled:
obj.BSEQ.enabled = True
return {"FINISHED"}
8 changes: 8 additions & 0 deletions bseq/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def draw(self, context):
row.operator("bseq.enableselected", text="Enable Selected")
row.operator("bseq.disableselected", text="Disable Selected")
row.operator("bseq.refresh", text="Refresh")
row = layout.row()
row.operator("bseq.enableall", text="Enable All")
row.operator("bseq.disableall", text="Disable All")



class BSEQ_Settings(bpy.types.Panel):
Expand Down Expand Up @@ -192,6 +196,10 @@ def draw(self, context):
col1.label(text="Use Relative Path")
col2.prop(importer_prop, "relative", text="")

if importer_prop.relative is True:
col1.label(text="Root Directory")
col2.prop(importer_prop, "root_path", text="")

layout.operator("sequence.load")
split = layout.split()
col1 = split.column()
Expand Down
4 changes: 4 additions & 0 deletions bseq/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class BSEQ_scene_property(bpy.types.PropertyGroup):
description="You need to go to the folder with the sequence, then click \"Accept\". ",
update=update_path)
relative: bpy.props.BoolProperty(name='Use relative path', description="whether or not to use reletive path", default=False)
root_path: bpy.props.StringProperty(name="Root Directory",
subtype="DIR_PATH",
description="Select a root folder for all relative paths. When not set the current filename is used.",
update=update_path)
fileseq: bpy.props.EnumProperty(
name="File Sequences",
description="Please choose the file sequences you want",
Expand Down
6 changes: 3 additions & 3 deletions bseq/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ def stop_animation():



def refresh_obj(obj):
def refresh_obj(obj, scene):
fs = obj.BSEQ.pattern
if obj.BSEQ.use_relative:
fs = bpy.path.abspath(fs)
fs = bpy.path.abspath(fs, start=scene.BSEQ.root_path)
fs = fileseq.findSequenceOnDisk(fs)
fs = fileseq.findSequenceOnDisk(fs.dirname() + fs.basename() + "@" + fs.extension())
fs = str(fs)
if obj.BSEQ.use_relative:
fs = bpy.path.relpath(fs)
fs = bpy.path.relpath(fs, start=scene.BSEQ.root_path)
obj.BSEQ.pattern = fs