Skip to content
Snippets Groups Projects
Commit 3f7e914d authored by Campbell Barton's avatar Campbell Barton
Browse files

pep8 edits and some style change

parent 2a9841dc
No related branches found
No related tags found
No related merge requests found
......@@ -70,11 +70,28 @@ class RawExporter(bpy.types.Operator):
bl_idname = "export_mesh.raw"
bl_label = "Export RAW"
filepath = StringProperty(name="File Path", description="Filepath used for exporting the RAW file", maxlen=1024, default= "", subtype='FILE_PATH')
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
apply_modifiers = BoolProperty(name="Apply Modifiers", description="Use transformed mesh data from each object", default=True)
triangulate = BoolProperty(name="Triangulate", description="Triangulate quads.", default=True)
filepath = StringProperty(
name="File Path",
description="Filepath used for exporting the RAW file",
maxlen=1024,
subtype='FILE_PATH',
)
check_existing = BoolProperty(
name="Check Existing",
description="Check and warn on overwriting existing files",
default=True,
options={'HIDDEN'},
)
apply_modifiers = BoolProperty(
name="Apply Modifiers",
description="Use transformed mesh data from each object",
default=True,
)
triangulate = BoolProperty(
name="Triangulate",
description="Triangulate quads.",
default=True,
)
def execute(self, context):
from . import export_raw
......@@ -107,6 +124,7 @@ def register():
bpy.types.INFO_MT_file_import.append(menu_import)
bpy.types.INFO_MT_file_export.append(menu_export)
def unregister():
bpy.utils.unregister_module(__name__)
......
......@@ -43,6 +43,7 @@ tolerance.
import bpy
def readMesh(filename, objName):
file = open(filename, "rb")
......@@ -59,7 +60,6 @@ def readMesh(filename, objName):
else:
return None
faces = []
for line in file.readlines():
face = line_to_face(line)
......
......@@ -42,7 +42,7 @@ if "bpy" in locals():
import bpy
from bpy.props import StringProperty, BoolProperty, FloatProperty, EnumProperty
from bpy_extras.io_utils import (ExportHelper,
from bpy_extras.io_utils import (ExportHelper,
path_reference_mode,
axis_conversion,
axis_conversion_ensure,
......
......@@ -427,7 +427,19 @@ def split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP):
return [(value[0], value[1], value[2], key_to_name(key)) for key, value in list(face_split_dict.items())]
def create_mesh(new_objects, has_ngons, use_ngons, use_edges, verts_loc, verts_tex, faces, unique_materials, unique_material_images, unique_smooth_groups, vertex_groups, dataname):
def create_mesh(new_objects,
has_ngons,
use_ngons,
use_edges,
verts_loc,
verts_tex,
faces,
unique_materials,
unique_material_images,
unique_smooth_groups,
vertex_groups,
dataname,
):
'''
Takes all the data gathered and generates a mesh, adding the new object to new_objects
deals with fgons, sharp edges and assigning materials
......@@ -452,11 +464,12 @@ def create_mesh(new_objects, has_ngons, use_ngons, use_edges, verts_loc, verts_t
# reverse loop through face indices
for f_idx in range(len(faces) - 1, -1, -1):
face_vert_loc_indices,\
face_vert_tex_indices,\
context_material,\
context_smooth_group,\
context_object = faces[f_idx]
(face_vert_loc_indices,
face_vert_tex_indices,
context_material,
context_smooth_group,
context_object,
) = faces[f_idx]
len_face_vert_loc_indices = len(face_vert_loc_indices)
......@@ -494,15 +507,20 @@ def create_mesh(new_objects, has_ngons, use_ngons, use_edges, verts_loc, verts_t
if has_ngons and len_face_vert_loc_indices > 4:
ngon_face_indices = ngon_tesselate(verts_loc, face_vert_loc_indices)
faces.extend(
[(
[face_vert_loc_indices[ngon[0]], face_vert_loc_indices[ngon[1]], face_vert_loc_indices[ngon[2]]],
[face_vert_tex_indices[ngon[0]], face_vert_tex_indices[ngon[1]], face_vert_tex_indices[ngon[2]]],
context_material,
context_smooth_group,
context_object)
for ngon in ngon_face_indices]
)
faces.extend([([face_vert_loc_indices[ngon[0]],
face_vert_loc_indices[ngon[1]],
face_vert_loc_indices[ngon[2]],
],
[face_vert_tex_indices[ngon[0]],
face_vert_tex_indices[ngon[1]],
face_vert_tex_indices[ngon[2]],
],
context_material,
context_smooth_group,
context_object,
)
for ngon in ngon_face_indices]
)
# edges to make fgons
if use_ngons:
......@@ -575,11 +593,12 @@ def create_mesh(new_objects, has_ngons, use_ngons, use_edges, verts_loc, verts_t
blender_face = me.faces[i]
face_vert_loc_indices,\
face_vert_tex_indices,\
context_material,\
context_smooth_group,\
context_object = face
(face_vert_loc_indices,
face_vert_tex_indices,
context_material,
context_smooth_group,
context_object,
) = face
if context_smooth_group:
blender_face.use_smooth = True
......@@ -887,13 +906,12 @@ def load(operator, context, filepath,
face_vert_tex_indices = []
# Instance a face
faces.append((\
face_vert_loc_indices,\
face_vert_tex_indices,\
context_material,\
context_smooth_group,\
context_object\
))
faces.append((face_vert_loc_indices,
face_vert_tex_indices,
context_material,
context_smooth_group,
context_object,
))
if strip_slash(line_split):
context_multi_line = b'f'
......@@ -944,13 +962,12 @@ def load(operator, context, filepath,
face_vert_tex_indices = []
# Instance a face
faces.append((\
face_vert_loc_indices,\
face_vert_tex_indices,\
context_material,\
context_smooth_group,\
context_object\
))
faces.append((face_vert_loc_indices,
face_vert_tex_indices,
context_material,
context_smooth_group,
context_object,
))
if strip_slash(line_split):
context_multi_line = b'l'
......@@ -1088,7 +1105,19 @@ def load(operator, context, filepath,
for verts_loc_split, faces_split, unique_materials_split, dataname in split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP):
# Create meshes from the data, warning 'vertex_groups' wont support splitting
create_mesh(new_objects, has_ngons, use_ngons, use_edges, verts_loc_split, verts_tex, faces_split, unique_materials_split, unique_material_images, unique_smooth_groups, vertex_groups, dataname)
create_mesh(new_objects,
has_ngons,
use_ngons,
use_edges,
verts_loc_split,
verts_tex,
faces_split,
unique_materials_split,
unique_material_images,
unique_smooth_groups,
vertex_groups,
dataname,
)
# nurbs support
for context_nurbs in nurbs:
......
......@@ -218,7 +218,7 @@ def export(file,
return ident
def writeFooter(ident):
if use_h3d:
# global
for route in h3d_material_route:
......@@ -1012,7 +1012,7 @@ def export(file,
value = '%.6g %.6g %.6g' % (global_matrix * lamp_obj.matrix_world).to_translation()[:]
fw('%s<field name="%s" type="SFVec3f" accessType="inputOutput" value="%s" />\n' % (ident, uniform['varname'], value))
# ------------------------------------------------------
# shader-patch
fw('%s<field name="%s_transform" type="SFMatrix4f" accessType="inputOutput" />\n' % (ident, uniform['varname']))
......@@ -1022,7 +1022,7 @@ def export(file,
h3d_material_route.append(
'<ROUTE fromNode=%s fromField="accForwardMatrix" toNode=%s toField="%s_transform" />' %
(suffix_quoted_str(lamp_obj_id, "_TRANSFORM"), material_id, uniform['varname']))
h3d_material_route.append(
'<ROUTE fromNode=%s fromField="location" toNode=%s toField="%s" />' %
(suffix_quoted_str(lamp_obj_id, "_TRANSFORM"), material_id, uniform['varname']))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment