- added new mathutils.Color() type, use with rna so we can do for eg:
 material.diffuse_color.r = 1.0
 # also has hsv access
 material.diffuse_color.s = 0.6

 - made Mathutils and Geometry module names lowercase.
This commit is contained in:
Campbell Barton
2010-04-11 14:22:27 +00:00
parent 4d2bc9f907
commit 67cfc427ee
62 changed files with 735 additions and 194 deletions

View File

@@ -77,7 +77,7 @@ import shutil # for file copying
# import Blender
import bpy
import Mathutils
import mathutils
@@ -135,7 +135,7 @@ def copy_images(dest_dir, textures):
# I guess FBX uses degrees instead of radians (Arystan).
# Call this function just before writing to FBX.
def eulerRadToDeg(eul):
ret = Mathutils.Euler()
ret = mathutils.Euler()
ret.x = 180 / math.pi * eul[0]
ret.y = 180 / math.pi * eul[1]
@@ -143,10 +143,10 @@ def eulerRadToDeg(eul):
return ret
mtx4_identity = Mathutils.Matrix()
mtx4_identity = mathutils.Matrix()
# testing
mtx_x90 = Mathutils.RotationMatrix( math.pi/2, 3, 'X') # used
mtx_x90 = mathutils.RotationMatrix( math.pi/2, 3, 'X') # used
#mtx_x90n = RotationMatrix(-90, 3, 'x')
#mtx_y90 = RotationMatrix( 90, 3, 'y')
#mtx_y90n = RotationMatrix(-90, 3, 'y')
@@ -154,11 +154,11 @@ mtx_x90 = Mathutils.RotationMatrix( math.pi/2, 3, 'X') # used
#mtx_z90n = RotationMatrix(-90, 3, 'z')
#mtx4_x90 = RotationMatrix( 90, 4, 'x')
mtx4_x90n = Mathutils.RotationMatrix(-math.pi/2, 4, 'X') # used
mtx4_x90n = mathutils.RotationMatrix(-math.pi/2, 4, 'X') # used
#mtx4_y90 = RotationMatrix( 90, 4, 'y')
mtx4_y90n = Mathutils.RotationMatrix(-math.pi/2, 4, 'Y') # used
mtx4_z90 = Mathutils.RotationMatrix( math.pi/2, 4, 'Z') # used
mtx4_z90n = Mathutils.RotationMatrix(-math.pi/2, 4, 'Z') # used
mtx4_y90n = mathutils.RotationMatrix(-math.pi/2, 4, 'Y') # used
mtx4_z90 = mathutils.RotationMatrix( math.pi/2, 4, 'Z') # used
mtx4_z90n = mathutils.RotationMatrix(-math.pi/2, 4, 'Z') # used
# def strip_path(p):
# return p.split('\\')[-1].split('/')[-1]
@@ -333,7 +333,7 @@ def write(filename, batch_objects = None, \
EXP_CAMERA = True,
EXP_EMPTY = True,
EXP_IMAGE_COPY = False,
GLOBAL_MATRIX = Mathutils.Matrix(),
GLOBAL_MATRIX = mathutils.Matrix(),
ANIM_ENABLE = True,
ANIM_OPTIMIZE = True,
ANIM_OPTIMIZE_PRECISSION = 6,
@@ -600,8 +600,8 @@ def write(filename, batch_objects = None, \
matrix_rot = matrix_rot * mtx_x90
elif type =='CAMERA':
# elif ob and type =='Camera':
y = matrix_rot * Mathutils.Vector(0,1,0)
matrix_rot = Mathutils.RotationMatrix(math.pi/2, 3, y) * matrix_rot
y = matrix_rot * mathutils.Vector(0,1,0)
matrix_rot = mathutils.RotationMatrix(math.pi/2, 3, y) * matrix_rot
return matrix_rot
@@ -702,8 +702,8 @@ def write(filename, batch_objects = None, \
matrix_rot = matrix_rot * mtx_x90
rot = tuple(matrix_rot.to_euler())
elif ob and ob.type =='Camera':
y = matrix_rot * Mathutils.Vector(0,1,0)
matrix_rot = Mathutils.RotationMatrix(math.pi/2, 3, y) * matrix_rot
y = matrix_rot * mathutils.Vector(0,1,0)
matrix_rot = mathutils.RotationMatrix(math.pi/2, 3, y) * matrix_rot
rot = tuple(matrix_rot.to_euler())
else:
rot = tuple(matrix_rot.to_euler())
@@ -1088,8 +1088,8 @@ def write(filename, batch_objects = None, \
file.write('\n\t\tTypeFlags: "Camera"')
file.write('\n\t\tGeometryVersion: 124')
file.write('\n\t\tPosition: %.6f,%.6f,%.6f' % loc)
file.write('\n\t\tUp: %.6f,%.6f,%.6f' % tuple(matrix_rot * Mathutils.Vector(0,1,0)) )
file.write('\n\t\tLookAt: %.6f,%.6f,%.6f' % tuple(matrix_rot * Mathutils.Vector(0,0,-1)) )
file.write('\n\t\tUp: %.6f,%.6f,%.6f' % tuple(matrix_rot * mathutils.Vector(0,1,0)) )
file.write('\n\t\tLookAt: %.6f,%.6f,%.6f' % tuple(matrix_rot * mathutils.Vector(0,0,-1)) )
#file.write('\n\t\tUp: 0,0,0' )
#file.write('\n\t\tLookAt: 0,0,0' )

View File

@@ -48,7 +48,7 @@ Be sure not to use modifiers that change the number or order of verts in the mes
# ***** END GPL LICENCE BLOCK *****
import bpy
import Mathutils
import mathutils
from struct import pack
@@ -87,7 +87,7 @@ def write(filename, sce, ob, PREF_STARTFRAME, PREF_ENDFRAME, PREF_FPS):
me = ob.create_mesh(sce, True, 'PREVIEW')
#Flip y and z
mat_flip = Mathutils.Matrix(\
mat_flip = mathutils.Matrix(\
[1.0, 0.0, 0.0, 0.0],\
[0.0, 0.0, 1.0, 0.0],\
[0.0, 1.0, 0.0, 0.0],\

View File

@@ -47,7 +47,7 @@ import time
import shutil
import bpy
import Mathutils
import mathutils
# Returns a tuple - path,extension.
@@ -221,7 +221,7 @@ def write_nurb(file, ob, ob_mat):
cu = ob.data
# use negative indices
Vector = Blender.Mathutils.Vector
Vector = Blender.mathutils.Vector
for nu in cu:
if nu.type==0: DEG_ORDER_U = 1
@@ -370,7 +370,7 @@ def write(filename, objects, scene,
file.write('mtllib %s\n' % ( mtlfilename.split('\\')[-1].split('/')[-1] ))
if EXPORT_ROTX90:
mat_xrot90= Mathutils.RotationMatrix(-math.pi/2, 4, 'X')
mat_xrot90= mathutils.RotationMatrix(-math.pi/2, 4, 'X')
# Initialize totals, these are updated each object
totverts = totuvco = totno = 1

View File

@@ -69,7 +69,7 @@ import math
import os
import bpy
import Mathutils
import mathutils
from export_3ds import create_derived_objects, free_derived_objects
@@ -81,7 +81,7 @@ from export_3ds import create_derived_objects, free_derived_objects
#
DEG2RAD=0.017453292519943295
MATWORLD= Mathutils.RotationMatrix(-90, 4, 'X')
MATWORLD= mathutils.RotationMatrix(-90, 4, 'X')
####################################
# Global Variables

View File

@@ -22,8 +22,8 @@ import math
from math import radians
import bpy
import Mathutils
from Mathutils import Vector, Euler, Matrix, RotationMatrix, TranslationMatrix
import mathutils
from mathutils import Vector, Euler, Matrix, RotationMatrix, TranslationMatrix
class bvh_node_class(object):

View File

@@ -144,7 +144,7 @@ import struct
from import_scene_obj import unpack_face_list, load_image
import bpy
import Mathutils
import mathutils
BOUNDS_3DS = []
@@ -310,8 +310,8 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
contextObName = None
contextLamp = [None, None] # object, Data
contextMaterial = None
contextMatrix_rot = None # Blender.Mathutils.Matrix(); contextMatrix.identity()
#contextMatrix_tx = None # Blender.Mathutils.Matrix(); contextMatrix.identity()
contextMatrix_rot = None # Blender.mathutils.Matrix(); contextMatrix.identity()
#contextMatrix_tx = None # Blender.mathutils.Matrix(); contextMatrix.identity()
contextMesh_vertls = None
contextMesh_facels = None
contextMeshMaterials = {} # matname:[face_idxs]
@@ -722,7 +722,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
def getuv():
temp_data = file.read(STRUCT_SIZE_2FLOAT)
new_chunk.bytes_read += STRUCT_SIZE_2FLOAT #2 float x 4 bytes each
return Mathutils.Vector( struct.unpack('<2f', temp_data) )
return mathutils.Vector( struct.unpack('<2f', temp_data) )
contextMeshUV = [ getuv() for i in range(num_uv) ]
@@ -732,7 +732,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
data = list( struct.unpack('<ffffffffffff', temp_data) )
new_chunk.bytes_read += STRUCT_SIZE_4x3MAT
contextMatrix_rot = Mathutils.Matrix(\
contextMatrix_rot = mathutils.Matrix(\
data[:3] + [0],\
data[3:6] + [0],\
data[6:9] + [0],\
@@ -740,7 +740,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
'''
contextMatrix_rot = Blender.Mathutils.Matrix(\
contextMatrix_rot = Blender.mathutils.Matrix(\
data[:3] + [0],\
data[3:6] + [0],\
data[6:9] + [0],\
@@ -748,14 +748,14 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
'''
'''
contextMatrix_rot = Blender.Mathutils.Matrix(\
contextMatrix_rot = Blender.mathutils.Matrix(\
data[:3] ,\
data[3:6],\
data[6:9])
'''
'''
contextMatrix_rot = Blender.Mathutils.Matrix()
contextMatrix_rot = Blender.mathutils.Matrix()
m = 0
for j in xrange(4):
for i in xrange(3):
@@ -773,7 +773,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
#print contextMatrix_rot
contextMatrix_rot.invert()
#print contextMatrix_rot
#contextMatrix_tx = Blender.Mathutils.TranslationMatrix(0.5 * Blender.Mathutils.Vector(data[9:]))
#contextMatrix_tx = Blender.mathutils.TranslationMatrix(0.5 * Blender.mathutils.Vector(data[9:]))
#contextMatrix_tx.invert()
#tx.invert()
@@ -946,8 +946,8 @@ def load_3ds(filename, context, IMPORT_CONSTRAIN_BOUNDS=10.0, IMAGE_SEARCH=True,
SCALE/=10
# SCALE Matrix
SCALE_MAT = Mathutils.Matrix([SCALE,0,0,0],[0,SCALE,0,0],[0,0,SCALE,0],[0,0,0,1])
# SCALE_MAT = Blender.Mathutils.Matrix([SCALE,0,0,0],[0,SCALE,0,0],[0,0,SCALE,0],[0,0,0,1])
SCALE_MAT = mathutils.Matrix([SCALE,0,0,0],[0,SCALE,0,0],[0,0,SCALE,0],[0,0,0,1])
# SCALE_MAT = Blender.mathutils.Matrix([SCALE,0,0,0],[0,SCALE,0,0],[0,0,SCALE,0],[0,0,0,1])
for ob in importedObjects:
ob.setMatrix(ob.matrixWorld * SCALE_MAT)

View File

@@ -54,8 +54,8 @@ Note, This loads mesh objects and materials only, nurbs and curves are not suppo
import os
import time
import bpy
import Mathutils
import Geometry
import mathutils
from geometry import PolyFill
# from Blender import Mesh, Draw, Window, Texture, Material, sys
# # import BPyMesh
@@ -127,7 +127,7 @@ def BPyMesh_ngon(from_data, indices, PREF_FIX_LOOPS= True):
if not set: # Need sets for this, otherwise do a normal fill.
PREF_FIX_LOOPS= False
Vector= Mathutils.Vector
Vector= mathutils.Vector
if not indices:
return []
@@ -158,7 +158,7 @@ def BPyMesh_ngon(from_data, indices, PREF_FIX_LOOPS= True):
if verts[i][1]==verts[i-1][0]:
verts.pop(i-1)
fill= Geometry.PolyFill([verts])
fill= PolyFill([verts])
else:
'''
@@ -266,7 +266,7 @@ def BPyMesh_ngon(from_data, indices, PREF_FIX_LOOPS= True):
vert_map[i+ii]= vert[2]
ii+=len(verts)
fill= Geometry.PolyFill([ [v[0] for v in loop] for loop in loop_list ])
fill= PolyFill([ [v[0] for v in loop] for loop in loop_list ])
#draw_loops(loop_list)
#raise 'done loop'
# map to original indicies

View File

@@ -19,7 +19,7 @@
# <pep8 compliant>
from _bpy import types as bpy_types
from Mathutils import Vector
from mathutils import Vector
StructRNA = bpy_types.Struct.__bases__[0]
# StructRNA = bpy_types.Struct
@@ -236,7 +236,7 @@ class EditBone(StructRNA, _GenericBone):
Transform the the bones head, tail, roll and envalope (when the matrix has a scale component).
Expects a 4x4 or 3x3 matrix.
"""
from Mathutils import Vector
from mathutils import Vector
z_vec = self.matrix.rotation_part() * Vector(0.0, 0.0, 1.0)
self.tail = matrix * self.tail
self.head = matrix * self.head

View File

@@ -19,7 +19,7 @@
# <pep8 compliant>
import bpy
from Mathutils import Vector
from mathutils import Vector
# TODO, have these in a more general module
from rna_prop_ui import rna_idprop_ui_prop_get

View File

@@ -23,7 +23,7 @@ from math import radians, pi
from rigify import RigifyError, ORG_PREFIX
from rigify_utils import bone_class_instance, copy_bone_simple, add_pole_target_bone, add_stretch_to, blend_bone_list, get_side_name, get_base_name
from rna_prop_ui import rna_idprop_ui_prop_get
from Mathutils import Vector
from mathutils import Vector
METARIG_NAMES = "shoulder", "arm", "forearm", "hand"

View File

@@ -20,7 +20,7 @@
import bpy
from rna_prop_ui import rna_idprop_ui_prop_get
from Mathutils import Vector
from mathutils import Vector
from rigify import RigifyError
from rigify_utils import copy_bone_simple

View File

@@ -21,7 +21,7 @@
import bpy
from rna_prop_ui import rna_idprop_ui_prop_get
from math import acos
from Mathutils import Vector
from mathutils import Vector
from rigify import RigifyError
from rigify_utils import copy_bone_simple

View File

@@ -279,7 +279,7 @@ def ik(obj, bone_definition, base_names, options):
def fk(obj, bone_definition, base_names, options):
from Mathutils import Vector
from mathutils import Vector
arm = obj.data
# these account for all bones in METARIG_NAMES

View File

@@ -23,7 +23,7 @@ from rna_prop_ui import rna_idprop_ui_prop_get
from math import pi
from rigify import RigifyError
from rigify_utils import bone_class_instance, copy_bone_simple, get_side_name, get_base_name
from Mathutils import Vector
from mathutils import Vector
METARIG_NAMES = "hips", "thigh", "shin", "foot", "toe"

View File

@@ -21,7 +21,7 @@
import bpy
from rna_prop_ui import rna_idprop_ui_prop_get
from math import acos, pi
from Mathutils import Vector
from mathutils import Vector
from rigify import RigifyError
from rigify_utils import copy_bone_simple

View File

@@ -119,7 +119,7 @@ def deform(obj, definitions, base_names, options):
def main(obj, bone_definition, base_names, options):
from Mathutils import Vector
from mathutils import Vector
arm = obj.data
eb = obj.data.edit_bones

View File

@@ -125,7 +125,7 @@ def deform(obj, definitions, base_names, options):
def main(obj, bone_definition, base_names, options):
from Mathutils import Vector
from mathutils import Vector
arm = obj.data

View File

@@ -248,7 +248,7 @@ def main(obj, bone_definition, base_names, options):
# NOTE: the direction of the Z rotation depends on which side the palm is on.
# we could do a simple side-of-x test but better to work out the direction
# the hand is facing.
from Mathutils import Vector
from mathutils import Vector
from math import degrees
child_pbone_01 = obj.pose.bones[children[0]].bone
child_pbone_02 = obj.pose.bones[children[1]].bone

View File

@@ -147,7 +147,7 @@ def deform(obj, definitions, base_names, options):
def main(obj, bone_definition, base_names, options):
from Mathutils import Vector, RotationMatrix
from mathutils import Vector, RotationMatrix
from math import radians, pi
arm = obj.data

View File

@@ -22,7 +22,7 @@ import bpy
from rigify import RigifyError
from rigify_utils import bone_class_instance, copy_bone_simple
from rna_prop_ui import rna_idprop_ui_prop_get
from Mathutils import Vector, RotationMatrix
from mathutils import Vector, RotationMatrix
from math import radians, pi
# not used, defined for completeness

View File

@@ -128,7 +128,7 @@ def deform(obj, definitions, base_names, options):
# TODO: rename all of the head/neck references to tongue
def main(obj, bone_definition, base_names, options):
from Mathutils import Vector
from mathutils import Vector
arm = obj.data

View File

@@ -26,7 +26,7 @@
# that a generic function would need to check for.
import bpy
from Mathutils import Vector
from mathutils import Vector
from rna_prop_ui import rna_idprop_ui_prop_get
DELIMITER = '-._'

View File

@@ -18,7 +18,7 @@
# <pep8-80 compliant>
import bpy
import Mathutils
import mathutils
from math import cos, sin, pi
# could this be stored elsewhere?

View File

@@ -18,13 +18,13 @@
# <pep8 compliant>
import bpy
import Mathutils
import mathutils
from math import cos, sin, pi
def add_torus(major_rad, minor_rad, major_seg, minor_seg):
Vector = Mathutils.Vector
Quaternion = Mathutils.Quaternion
Vector = mathutils.Vector
Quaternion = mathutils.Quaternion
PI_2 = pi * 2
z_axis = (0, 0, 1)

View File

@@ -190,7 +190,7 @@ def banner(context):
add_scrollback("Execute: Enter", 'OUTPUT')
add_scrollback("Autocomplete: Ctrl+Space", 'OUTPUT')
add_scrollback("Ctrl +/- Wheel: Zoom", 'OUTPUT')
add_scrollback("Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bgl, blf, Mathutils, Geometry", 'OUTPUT')
add_scrollback("Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bgl, blf, mathutils, Geometry", 'OUTPUT')
add_scrollback("", 'OUTPUT')
add_scrollback(" WARNING!!! Blender 2.5 API is subject to change, see API reference for more info.", 'ERROR')
add_scrollback("", 'OUTPUT')

View File

@@ -1,6 +1,6 @@
from math import *
import bpy
from Mathutils import *
from mathutils import *
def main(context):
def cleanupEulCurve(fcv):

View File

@@ -76,7 +76,7 @@ class MeshMirrorUV(bpy.types.Operator):
def execute(self, context):
DIR = 1 # TODO, make an option
from Mathutils import Vector
from mathutils import Vector
ob = context.active_object
is_editmode = (ob.mode == 'EDIT')

View File

@@ -22,7 +22,7 @@ import bpy
def pose_info():
from Mathutils import Matrix
from mathutils import Matrix
info = {}

View File

@@ -235,8 +235,8 @@ class ShapeTransfer(bpy.types.Operator):
ob.active_shape_key_index = len(me.shape_keys.keys) - 1
ob.shape_key_lock = True
from Geometry import BarycentricTransform
from Mathutils import Vector
from geometry import BarycentricTransform
from mathutils import Vector
if use_clamp and mode == 'OFFSET':
use_clamp = False
@@ -452,7 +452,7 @@ class MakeDupliFace(bpy.types.Operator):
return (obj and obj.type == 'MESH')
def _main(self, context):
from Mathutils import Vector
from mathutils import Vector
from math import sqrt
SCALE_FAC = 0.01

View File

@@ -19,7 +19,7 @@
# <pep8 compliant>
import bpy
from Mathutils import Vector
from mathutils import Vector
def align_objects(align_x, align_y, align_z, align_mode, relative_to):

View File

@@ -25,7 +25,7 @@ def randomize_selected(seed, loc, rot, scale, scale_even, scale_min):
import random
from random import uniform
from Mathutils import Vector
from mathutils import Vector
random.seed(seed)

View File

@@ -22,10 +22,9 @@
# <pep8 compliant>
#from Blender import Object, Draw, Window, sys, Mesh, Geometry
from Mathutils import Matrix, Vector, RotationMatrix
from mathutils import Matrix, Vector, RotationMatrix
import time
import Geometry
import geometry
import bpy
from math import cos, radians
@@ -227,7 +226,7 @@ def islandIntersectUvIsland(source, target, SourceOffset):
# Edge intersect test
for ed in edgeLoopsSource:
for seg in edgeLoopsTarget:
i = Geometry.LineIntersect2D(\
i = geometry.LineIntersect2D(\
seg[0], seg[1], SourceOffset+ed[0], SourceOffset+ed[1])
if i:
return 1 # LINE INTERSECTION
@@ -741,7 +740,7 @@ def packIslands(islandList):
#XXX Window.DrawProgressBar(0.7, 'Packing %i UV Islands...' % len(packBoxes) )
time1 = time.time()
packWidth, packHeight = Geometry.BoxPack2D(packBoxes)
packWidth, packHeight = geometry.BoxPack2D(packBoxes)
# print 'Box Packing Time:', time.time() - time1
@@ -1056,7 +1055,7 @@ def main(context, island_margin, projection_limit):
for f in faceProjectionGroupList[i]:
f_uv = f.uv
for j, v in enumerate(f.v):
# XXX - note, between Mathutils in 2.4 and 2.5 the order changed.
# XXX - note, between mathutils in 2.4 and 2.5 the order changed.
f_uv[j][:] = (v.co * MatProj)[:2]

View File

@@ -34,7 +34,7 @@ import bpy
import math
import time
from Mathutils import Vector
from mathutils import Vector
from bpy.props import *

View File

@@ -7,7 +7,7 @@
# import GameKeys
# support for Vector(), Matrix() types and advanced functions like ScaleMatrix(...) and RotationMatrix(...)
# import Mathutils
# import mathutils
# for functions like getWindowWidth(), getWindowHeight()
# import Rasterizer