Compare commits
5 Commits
ae85247072
...
19560787e8
Author | SHA1 | Date |
---|---|---|
|
19560787e8 | |
|
f189786f72 | |
|
3edc46e393 | |
|
db2135760c | |
|
8622628b09 |
|
@ -0,0 +1,2 @@
|
|||
__pycache__/
|
||||
.vscode/
|
30
__init__.py
30
__init__.py
|
@ -62,9 +62,9 @@ class ImportB3D(bpy.types.Operator, ImportHelper):
|
|||
bl_options = {'UNDO'}
|
||||
|
||||
filename_ext = ".b3d"
|
||||
filter_glob : StringProperty(default="*.b3d", options={'HIDDEN'})
|
||||
filter_glob = StringProperty(default="*.b3d", options={'HIDDEN'})
|
||||
|
||||
constrain_size : FloatProperty(
|
||||
constrain_size = FloatProperty(
|
||||
name="Size Constraint",
|
||||
description="Scale the model by 10 until it reaches the "
|
||||
"size constraint (0 to disable)",
|
||||
|
@ -72,13 +72,13 @@ class ImportB3D(bpy.types.Operator, ImportHelper):
|
|||
soft_min=0.0, soft_max=1000.0,
|
||||
default=10.0,
|
||||
)
|
||||
use_image_search : BoolProperty(
|
||||
use_image_search = BoolProperty(
|
||||
name="Image Search",
|
||||
description="Search subdirectories for any associated images "
|
||||
"(Warning, may be slow)",
|
||||
default=True,
|
||||
)
|
||||
use_apply_transform : BoolProperty(
|
||||
use_apply_transform = BoolProperty(
|
||||
name="Apply Transform",
|
||||
description="Workaround for object transformations "
|
||||
"importing incorrectly",
|
||||
|
@ -101,20 +101,15 @@ class ImportB3D(bpy.types.Operator, ImportHelper):
|
|||
return import_b3d.load(self, context, **keywords)
|
||||
|
||||
|
||||
@orientation_helper(axis_forward='Y', axis_up='Z')
|
||||
class ExportB3D(bpy.types.Operator, ExportHelper):
|
||||
"""Export to B3D file format (.b3d)"""
|
||||
bl_idname = "export_scene.blitz3d_b3d"
|
||||
bl_label = 'Export B3D'
|
||||
|
||||
filename_ext = ".b3d"
|
||||
filter_glob = StringProperty(default="*.b3d", options={'HIDDEN'})
|
||||
|
||||
filter_glob: StringProperty(
|
||||
default="*.b3d",
|
||||
options={'HIDDEN'},
|
||||
)
|
||||
|
||||
use_selection: BoolProperty(
|
||||
use_selection = BoolProperty(
|
||||
name="Selection Only",
|
||||
description="Export selected objects only",
|
||||
default=False,
|
||||
|
@ -123,15 +118,10 @@ class ExportB3D(bpy.types.Operator, ExportHelper):
|
|||
def execute(self, context):
|
||||
from . import export_b3d
|
||||
|
||||
keywords = self.as_keywords(ignore=("axis_forward",
|
||||
"axis_up",
|
||||
"filter_glob",
|
||||
"check_existing",
|
||||
))
|
||||
global_matrix = axis_conversion(to_forward=self.axis_forward,
|
||||
to_up=self.axis_up,
|
||||
).to_4x4()
|
||||
keywords["global_matrix"] = global_matrix
|
||||
export_b3d.b3d_parameters["vertex-normals"] = True
|
||||
export_b3d.b3d_parameters["export-selected"] = self.use_selection
|
||||
|
||||
keywords = self.as_keywords(ignore=("filter_glob", "check_existing"))
|
||||
|
||||
return export_b3d.save(self, context, **keywords)
|
||||
|
||||
|
|
|
@ -225,10 +225,10 @@ def write_texs(objects=[]):
|
|||
if objects:
|
||||
exp_obj = objects
|
||||
else:
|
||||
if b3d_parameters.get("export-selected"):
|
||||
exp_obj = [ob for ob in bpy.data.objects if ob.select]
|
||||
else:
|
||||
exp_obj = bpy.data.objects
|
||||
exp_obj = bpy.data.objects
|
||||
|
||||
if b3d_parameters.get("export-selected"):
|
||||
exp_obj = [ob for ob in exp_obj if ob.select_get()]
|
||||
|
||||
if PROGRESS: print(len(exp_obj),"TEXS")
|
||||
|
||||
|
@ -363,10 +363,10 @@ def write_brus(objects=[]):
|
|||
if objects:
|
||||
exp_obj = objects
|
||||
else:
|
||||
if b3d_parameters.get("export-selected"):
|
||||
exp_obj = [ob for ob in bpy.data.objects if ob.select]
|
||||
else:
|
||||
exp_obj = bpy.data.objects
|
||||
exp_obj = bpy.data.objects
|
||||
|
||||
if b3d_parameters.get("export-selected"):
|
||||
exp_obj = [ob for ob in exp_obj if ob.select_get()]
|
||||
|
||||
if PROGRESS: print(len(exp_obj),"BRUS")
|
||||
if PROGRESS_VERBOSE: progress = 0
|
||||
|
@ -543,10 +543,10 @@ def write_node(objects=[]):
|
|||
if objects:
|
||||
exp_obj = objects
|
||||
else:
|
||||
if b3d_parameters.get("export-selected"):
|
||||
exp_obj = [ob for ob in bpy.data.objects if ob.select]
|
||||
else:
|
||||
exp_obj = bpy.data.objects
|
||||
exp_obj = bpy.data.objects
|
||||
|
||||
if b3d_parameters.get("export-selected"):
|
||||
exp_obj = [ob for ob in exp_obj if ob.select_get()]
|
||||
|
||||
for obj in exp_obj:
|
||||
if obj.type == "MESH":
|
||||
|
@ -1092,6 +1092,7 @@ def write_node_mesh_vrts(obj, data, obj_count, arm_action, exp_root):
|
|||
my_uvs[f.index].append(uv)
|
||||
|
||||
uv_layers_count = len(getUVTextures(data))
|
||||
data.calc_normals_split() # ensure loop normals are valid
|
||||
for face in getFaces(data):
|
||||
|
||||
if DEBUG: print(" <!-- Face",face.index,"-->")
|
||||
|
@ -1102,8 +1103,10 @@ def write_node_mesh_vrts(obj, data, obj_count, arm_action, exp_root):
|
|||
|
||||
per_face_vertices[face.index] = []
|
||||
|
||||
for vertex_id,vert in enumerate(face.vertices):
|
||||
for vertex_id, loop_index in enumerate(face.loop_indices):
|
||||
|
||||
loop = data.loops[loop_index]
|
||||
vert = loop.vertex_index
|
||||
ivert += 1
|
||||
|
||||
per_face_vertices[face.index].append(ivert)
|
||||
|
@ -1125,13 +1128,11 @@ def write_node_mesh_vrts(obj, data, obj_count, arm_action, exp_root):
|
|||
#time_in_a += b - a
|
||||
|
||||
if b3d_parameters.get("vertex-normals"):
|
||||
norm_matrix = mathutils.Matrix.Translation(data.vertices[vert].normal)
|
||||
|
||||
if arm_action:
|
||||
norm_matrix @= mesh_matrix
|
||||
norm_matrix = mathutils.Matrix.Translation(loop.normal)
|
||||
|
||||
norm_matrix @= TRANS_MATRIX
|
||||
normal_vector = norm_matrix.to_translation()
|
||||
normal_vector.normalize()
|
||||
|
||||
temp_buf.append(write_float_triplet(normal_vector.x, #NX
|
||||
normal_vector.z, #NY
|
||||
|
@ -1602,6 +1603,7 @@ def save(operator,
|
|||
filepath += ".b3d"
|
||||
|
||||
obj_list = []
|
||||
# use_selection
|
||||
obj_list = bpy.data.objects
|
||||
|
||||
global the_scene
|
||||
|
|
Loading…
Reference in New Issue