Python bpy_extras.io_utils.axis_conversion() Examples
The following are 6
code examples of bpy_extras.io_utils.axis_conversion().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bpy_extras.io_utils
, or try the search function
.
Example #1
Source File: bob_plugin.py From BombSquad-Community-Mod-Manager with The Unlicense | 5 votes |
def execute(self, context): keywords = self.as_keywords(ignore=('filter_glob',)) mesh = load(self, context, **keywords) if not mesh: return {'CANCELLED'} scene = bpy.context.scene obj = bpy.data.objects.new(mesh.name, mesh) scene.objects.link(obj) scene.objects.active = obj obj.select = True obj.matrix_world = axis_conversion(from_forward='-Z', from_up='Y').to_4x4() scene.update() return {'FINISHED'}
Example #2
Source File: bob_plugin.py From BombSquad-Community-Mod-Manager with The Unlicense | 5 votes |
def execute(self, context): keywords = self.as_keywords(ignore=('filter_glob',)) mesh = loadcob(self, context, **keywords) if not mesh: return {'CANCELLED'} scene = bpy.context.scene obj = bpy.data.objects.new(mesh.name, mesh) scene.objects.link(obj) scene.objects.active = obj obj.select = True obj.draw_type = "SOLID" obj.matrix_world = axis_conversion(from_forward='-Z', from_up='Y').to_4x4() scene.update() return {'FINISHED'}
Example #3
Source File: bob_plugin.py From BombSquad-Community-Mod-Manager with The Unlicense | 5 votes |
def savecob(operator, context, filepath, triangulate, check_existing): print("exporting", filepath) global_matrix = axis_conversion(to_forward='-Z', to_up='Y').to_4x4() scene = context.scene obj = scene.objects.active mesh = obj.to_mesh(scene, True, 'PREVIEW') mesh.transform(global_matrix * obj.matrix_world) # inverse transformation if triangulate or any([len(face.vertices) != 3 for face in mesh.tessfaces]): print("triangulating...") with to_bmesh(mesh, save=True) as bm: bmesh.ops.triangulate(bm, faces=bm.faces) mesh.update(calc_edges=True, calc_tessface=True) with open(os.fsencode(filepath), 'wb') as file: def writestruct(s, *args): file.write(struct.pack(s, *args)) writestruct('I', COB_FILE_ID) writestruct('I', len(mesh.vertices)) writestruct('I', len(mesh.tessfaces)) for i, vert in enumerate(mesh.vertices): writestruct('fff', *vert.co) for face in mesh.tessfaces: assert len(face.vertices) == 3 for vertid in face.vertices: writestruct('I', vertid) for face in mesh.tessfaces: writestruct('fff', *face.normal) return {'FINISHED'}
Example #4
Source File: import_pix.py From GameTools with GNU General Public License v3.0 | 5 votes |
def execute(self, context): keywords = self.as_keywords(ignore=("axis_forward", "axis_up", "filter_glob")) global_matrix = axis_conversion(from_forward=self.axis_forward, from_up=self.axis_up, ).to_4x4() keywords["global_matrix"] = global_matrix print(keywords) importCSV(**keywords) return {'FINISHED'}
Example #5
Source File: export.py From se-blender with GNU General Public License v2.0 | 5 votes |
def __getitem__(self, key): # makes all attributes available for parameter substitution if not type(key) is str or key.startswith('_'): raise KeyError(key) try: value = getattr(self, key) if value is None or type(value) is _FUNCTION_TYPE: raise KeyError(key) return value except AttributeError: raise KeyError(key) # FWD = 'Z' # UP = 'Y' # MATRIX_NORMAL = axis_conversion(to_forward=FWD, to_up=UP).to_4x4() # MATRIX_SCALE_DOWN = Matrix.Scale(0.2, 4) * MATRIX_NORMAL
Example #6
Source File: bob_plugin.py From BombSquad-Community-Mod-Manager with The Unlicense | 4 votes |
def execute(self, context): keywords = self.as_keywords(ignore=('filter_glob',)) print("executing", keywords["filepath"]) data = {} with open(os.fsencode(keywords["filepath"]), "r") as file: exec(file.read(), data) del data["__builtins__"] if "points" not in data or "boxes" not in data: return {'CANCELLED'} scene = bpy.context.scene points_obj = bpy.data.objects.new("points", None) points_obj.matrix_world = axis_conversion(from_forward='-Z', from_up='Y').to_4x4() scene.objects.link(points_obj) scene.update() points_obj.layers = tuple([i == 1 for i in range(20)]) boxes_obj = bpy.data.objects.new("boxes", None) boxes_obj.matrix_world = axis_conversion(from_forward='-Z', from_up='Y').to_4x4() scene.objects.link(boxes_obj) scene.update() boxes_obj.layers = tuple([i == 1 for i in range(20)]) def makeBox(middle, scale): bpy.ops.mesh.primitive_cube_add(location=middle) cube = scene.objects.active cube.scale = scale cube.show_name = True cube.show_wire = True cube.draw_type = 'WIRE' return cube for key, pos in data["points"].items(): if len(pos) == 6: # spawn points with random variance middle, size = Vector(pos[:3]), Vector(pos[3:]) if "spawn" in key.lower(): size.y = 0.05 cube = makeBox(middle, size) cube.parent = points_obj cube.name = key else: empty = bpy.data.objects.new(key, None) empty.location = pos[:3] empty.empty_draw_size = 0.45 empty.parent = points_obj empty.show_name = True scene.objects.link(empty) for key, pos in data["boxes"].items(): middle, size = Vector(pos[:3]), flpV(Vector(pos[6:9])) cube = makeBox(middle, size) cube.parent = boxes_obj cube.name = key scene.update() return {'FINISHED'}