Skip to content

Commit

Permalink
update for changes in blender module layout, also add global axis con…
Browse files Browse the repository at this point in the history
…version to FBX.
  • Loading branch information
ideasman42 committed May 16, 2011
1 parent 5751efe commit fca80ff
Show file tree
Hide file tree
Showing 36 changed files with 77 additions and 76 deletions.
4 changes: 2 additions & 2 deletions add_mesh_ant_landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def create_mesh_object(context, verts, edges, faces, name):
# Update mesh geometry after adding stuff.
mesh.update()

import add_object_utils
return add_object_utils.object_data_add(context, mesh, operator=None)
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)

# A very simple "bridge" tool.
# Connects two equally long vertex rows with faces.
Expand Down
4 changes: 2 additions & 2 deletions add_mesh_extra_objects/add_mesh_3d_function_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ def create_mesh_object(context, verts, edges, faces, name):
# Update mesh geometry after adding stuff.
mesh.update()

import add_object_utils
return add_object_utils.object_data_add(context, mesh, operator=None)
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)


# A very simple "bridge" tool.
Expand Down
4 changes: 2 additions & 2 deletions add_mesh_extra_objects/add_mesh_extra_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def create_mesh_object(context, verts, edges, faces, name):
# Update mesh geometry after adding stuff.
mesh.update()

import add_object_utils
return add_object_utils.object_data_add(context, mesh, operator=None)
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)


# A very simple "bridge" tool.
Expand Down
4 changes: 2 additions & 2 deletions add_mesh_extra_objects/add_mesh_gears.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def create_mesh_object(context, verts, edges, faces, name):
# Update mesh geometry after adding stuff.
mesh.update()

import add_object_utils
return add_object_utils.object_data_add(context, mesh, operator=None)
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)


# A very simple "bridge" tool.
Expand Down
4 changes: 2 additions & 2 deletions add_mesh_extra_objects/add_mesh_gemstones.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def create_mesh_object(context, verts, edges, faces, name):
# Update mesh geometry after adding stuff.
mesh.update()

import add_object_utils
return add_object_utils.object_data_add(context, mesh, operator=None)
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)


# A very simple "bridge" tool.
Expand Down
4 changes: 2 additions & 2 deletions add_mesh_extra_objects/add_mesh_twisted_torus.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def create_mesh_object(context, verts, edges, faces, name):
# Update mesh geometry after adding stuff.
mesh.update()

import add_object_utils
return add_object_utils.object_data_add(context, mesh, operator=None)
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)

# A very simple "bridge" tool.
# Connects two equally long vertex rows with faces.
Expand Down
4 changes: 2 additions & 2 deletions add_mesh_pipe_joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def create_mesh_object(context, verts, edges, faces, name):
# Update mesh geometry after adding stuff.
mesh.update()

import add_object_utils
return add_object_utils.object_data_add(context, mesh, operator=None)
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)

# A very simple "bridge" tool.
# Connects two equally long vertex rows with faces.
Expand Down
2 changes: 1 addition & 1 deletion add_mesh_solid.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from math import sqrt
from mathutils import Vector,Matrix
from functools import reduce
from add_object_utils import object_data_add
from bpy_extras.object_utils import object_data_add

# this function creates a chain of quads and, when necessary, a remaining tri
# for each polygon created in this script. be aware though, that this function
Expand Down
2 changes: 1 addition & 1 deletion io_anim_bvh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

import bpy
from bpy.props import StringProperty, FloatProperty, IntProperty, BoolProperty, EnumProperty
from io_utils import ImportHelper, ExportHelper
from bpy_extras.io_utils import ImportHelper, ExportHelper


class ImportBVH(bpy.types.Operator, ImportHelper):
Expand Down
2 changes: 1 addition & 1 deletion io_anim_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def writeCameras(context, filepath, frame_start, frame_end, only_selected=False)


from bpy.props import StringProperty, IntProperty, BoolProperty
from io_utils import ExportHelper
from bpy_extras.io_utils import ExportHelper


class CameraExporter(bpy.types.Operator, ExportHelper):
Expand Down
2 changes: 1 addition & 1 deletion io_convert_image_to_mesh_img/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

import bpy
from bpy.props import *
from io_utils import ImportHelper
from bpy_extras.io_utils import ImportHelper


class ImportHiRISEIMGDTM(bpy.types.Operator, ImportHelper):
Expand Down
2 changes: 1 addition & 1 deletion io_curve_svg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

import bpy
from bpy.props import StringProperty
from io_utils import ImportHelper, ExportHelper
from bpy_extras.io_utils import ImportHelper, ExportHelper


class ImportSVG(bpy.types.Operator, ImportHelper):
Expand Down
2 changes: 1 addition & 1 deletion io_export_pc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import mathutils, math, struct
from os import remove
import time
from io_utils import ExportHelper
from bpy_extras.io_utils import ExportHelper

def getSampling(start, end, sampling):
samples = [start - sampling
Expand Down
2 changes: 1 addition & 1 deletion io_import_images_as_planes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import bpy, os, mathutils
from bpy.props import *
from add_utils import *
from io_utils import ImportHelper, load_image
from bpy_extras.io_utils import ImportHelper, load_image

## GLOBAL VARS ##
EXT_LIST = {
Expand Down
2 changes: 1 addition & 1 deletion io_import_scene_mhx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2617,7 +2617,7 @@ def writeDefaults():

DEBUG = False
from bpy.props import StringProperty, FloatProperty, EnumProperty, BoolProperty
from io_utils import ImportHelper
from bpy_extras.io_utils import ImportHelper


MhxBoolProps = [
Expand Down
2 changes: 1 addition & 1 deletion io_mesh_ply/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import os
import bpy
from bpy.props import CollectionProperty, StringProperty, BoolProperty
from io_utils import ImportHelper, ExportHelper
from bpy_extras.io_utils import ImportHelper, ExportHelper


class ImportPLY(bpy.types.Operator, ImportHelper):
Expand Down
2 changes: 1 addition & 1 deletion io_mesh_ply/import_ply.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def read(filepath):

def load_ply(filepath):
import time
from io_utils import load_image, unpack_list, unpack_face_list
from bpy_extras.io_utils import load_image, unpack_list, unpack_face_list

t = time.time()
obj_spec, obj = read(filepath)
Expand Down
2 changes: 1 addition & 1 deletion io_mesh_raw/import_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import bpy

# move those to a utility modul
from io_utils import unpack_face_list, unpack_list # TODO, make generic
from bpy_extras.io_utils import unpack_face_list, unpack_list # TODO, make generic


def readMesh(filename, objName):
Expand Down
2 changes: 1 addition & 1 deletion io_mesh_stl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

import bpy
from bpy.props import StringProperty, BoolProperty, CollectionProperty
from io_utils import ExportHelper, ImportHelper
from bpy_extras.io_utils import ExportHelper, ImportHelper


class ImportSTL(bpy.types.Operator, ImportHelper):
Expand Down
2 changes: 1 addition & 1 deletion io_scene_3ds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

import bpy
from bpy.props import StringProperty, FloatProperty, BoolProperty
from io_utils import ImportHelper, ExportHelper
from bpy_extras.io_utils import ImportHelper, ExportHelper


class Import3DS(bpy.types.Operator, ImportHelper):
Expand Down
3 changes: 1 addition & 2 deletions io_scene_3ds/export_3ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,7 @@ def save(operator, context, filepath="",

import bpy
import time
import io_utils
from io_utils import create_derived_objects, free_derived_objects
from bpy_extras.io_utils import create_derived_objects, free_derived_objects

'''Save the Blender scene to a 3ds file.'''

Expand Down
2 changes: 1 addition & 1 deletion io_scene_3ds/import_3ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import time
import struct

from io_utils import load_image
from bpy_extras.io_utils import load_image

import bpy
import mathutils
Expand Down
53 changes: 28 additions & 25 deletions io_scene_fbx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@

import bpy
from bpy.props import StringProperty, BoolProperty, FloatProperty, EnumProperty
import io_utils
from io_utils import ExportHelper
from bpy_extras.io_utils import ExportHelper, path_reference_mode, axis_conversion


class ExportFBX(bpy.types.Operator, ExportHelper):
Expand All @@ -61,15 +60,28 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
# EXP_OBS_SCENE = BoolProperty(name="Scene Objects", description="Export all objects in this scene", default=True)
global_scale = FloatProperty(name="Scale", description="Scale all data, (Note! some imports dont support scaled armatures)", min=0.01, max=1000.0, soft_min=0.01, soft_max=1000.0, default=1.0)

global_rotate = EnumProperty(
name="Rotate",
options={'ENUM_FLAG'},
items=(('X_90', "X 90", ""),
('Y_90', "Y 90", ""),
('Z_90', "Z 90", ""),
global_axis_forward = EnumProperty(
name="Forward",
items=(('X', "X Forward", ""),
('Y', "Y Forward", ""),
('Z', "Z Forward", ""),
('-X', "-X Forward", ""),
('-Y', "-Y Forward", ""),
('-Z', "-Z Forward", ""),
),
default='Y',
)

global_axis_up = EnumProperty(
name="Up",
items=(('X', "X Up", ""),
('Y', "Y Up", ""),
('Z', "Z Up", ""),
('-X', "-X Up", ""),
('-Y', "-Y Up", ""),
('-Z', "-Z Up", ""),
),
default={'X_90'},
description="Global rotation to apply to the exported scene",
default='Z',
)

object_types = EnumProperty(
Expand All @@ -84,7 +96,7 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
default={'EMPTY', 'CAMERA', 'LAMP', 'ARMATURE', 'MESH'},
)

mesh_apply_modifiers = BoolProperty(name="Modifiers", description="Apply modifiers to mesh objects", default=True)
mesh_apply_modifiers = BoolProperty(name="Apply Modifiers", description="Apply modifiers to mesh objects", default=True)

mesh_smooth_type = EnumProperty(
name="Smoothing",
Expand Down Expand Up @@ -114,7 +126,7 @@ class ExportFBX(bpy.types.Operator, ExportHelper):
BATCH_OWN_DIR = BoolProperty(name="Own Dir", description="Create a dir for each exported file", default=True)
use_metadata = BoolProperty(name="Use Metadata", default=True, options={'HIDDEN'})

path_mode = io_utils.path_reference_mode
path_mode = path_reference_mode

@property
def check_extension(self):
Expand All @@ -126,22 +138,13 @@ def execute(self, context):
if not self.filepath:
raise Exception("filepath not set")

mtx4_x90n = Matrix.Rotation(-math.pi / 2.0, 4, 'X')
mtx4_y90n = Matrix.Rotation(-math.pi / 2.0, 4, 'Y')
mtx4_z90n = Matrix.Rotation(-math.pi / 2.0, 4, 'Z')

GLOBAL_MATRIX = Matrix()
GLOBAL_MATRIX[0][0] = GLOBAL_MATRIX[1][1] = GLOBAL_MATRIX[2][2] = self.global_scale
if 'X_90' in self.global_rotate:
GLOBAL_MATRIX = mtx4_x90n * GLOBAL_MATRIX
if 'Y_90' in self.global_rotate:
GLOBAL_MATRIX = mtx4_y90n * GLOBAL_MATRIX
if 'Z_90' in self.global_rotate:
GLOBAL_MATRIX = mtx4_z90n * GLOBAL_MATRIX

keywords = self.as_keywords(ignore=("global_rotate", "global_scale", "check_existing", "filter_glob"))
keywords["GLOBAL_MATRIX"] = GLOBAL_MATRIX
GLOBAL_MATRIX = GLOBAL_MATRIX * axis_conversion(to_forward=self.global_axis_forward, to_up=self.global_axis_up).to_4x4()

keywords = self.as_keywords(ignore=("global_axis_forward", "global_axis_up", "global_scale", "check_existing", "filter_glob"))
keywords["GLOBAL_MATRIX"] = GLOBAL_MATRIX
print(GLOBAL_MATRIX)
from . import export_fbx
return export_fbx.save(self, context, **keywords)

Expand Down
8 changes: 4 additions & 4 deletions io_scene_fbx/export_fbx.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def save_single(operator, scene, filepath="",
path_mode='AUTO',
):

import io_utils
import bpy_extras.io_utils

mtx_x90 = Matrix.Rotation(math.pi / 2.0, 3, 'X')
mtx4_z90 = Matrix.Rotation(math.pi / 2.0, 4, 'Z')
Expand Down Expand Up @@ -1097,7 +1097,7 @@ def write_video(texname, tex):
Property: "Width", "int", "",0
Property: "Height", "int", "",0''')
if tex:
fname_rel = io_utils.path_reference(tex.filepath, base_src, base_dst, path_mode, "", copy_set)
fname_rel = bpy_extras.io_utils.path_reference(tex.filepath, base_src, base_dst, path_mode, "", copy_set)
fname_strip = os.path.basename(fname_rel)
else:
fname_strip = fname_rel = ""
Expand Down Expand Up @@ -1156,7 +1156,7 @@ def write_texture(texname, tex, num):
file.write('\n\t\tMedia: "Video::%s"' % texname)

if tex:
fname_rel = io_utils.path_reference(tex.filepath, base_src, base_dst, path_mode, "", copy_set)
fname_rel = bpy_extras.io_utils.path_reference(tex.filepath, base_src, base_dst, path_mode, "", copy_set)
fname_strip = os.path.basename(fname_rel)
else:
fname_strip = fname_rel = ""
Expand Down Expand Up @@ -2747,7 +2747,7 @@ def fbx_time(t):
file.close()

# copy all collected files.
io_utils.path_reference_copy(copy_set)
bpy_extras.io_utils.path_reference_copy(copy_set)

print('export finished in %.4f sec.' % (time.clock() - start_time))
return {'FINISHED'}
Expand Down
2 changes: 1 addition & 1 deletion io_scene_m3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import datetime
import bpy
from bpy.props import StringProperty, BoolProperty
from io_utils import ImportHelper, ExportHelper
from bpy_extras.io_utils import ImportHelper, ExportHelper


class ImportM3(bpy.types.Operator, ImportHelper):
Expand Down
2 changes: 1 addition & 1 deletion io_scene_m3/import_m3.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import struct
import os.path
from bpy.props import *
from io_utils import load_image
from bpy_extras.io_utils import load_image

##################
## Struct setup ##
Expand Down
5 changes: 2 additions & 3 deletions io_scene_obj/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@

import bpy
from bpy.props import BoolProperty, FloatProperty, StringProperty, EnumProperty
import io_utils
from io_utils import ExportHelper, ImportHelper
from bpy_extras.io_utils import ExportHelper, ImportHelper, path_reference_mode


class ImportOBJ(bpy.types.Operator, ImportHelper):
Expand Down Expand Up @@ -158,7 +157,7 @@ class ExportOBJ(bpy.types.Operator, ExportHelper):
group_by_material = BoolProperty(name="Material Groups", description="", default=False)
keep_vertex_order = BoolProperty(name="Keep Vertex Order", description="", default=False)

path_mode = io_utils.path_reference_mode
path_mode = path_reference_mode

def execute(self, context):
from . import export_obj
Expand Down
Loading

0 comments on commit fca80ff

Please sign in to comment.