diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-07-26 00:59:09 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-07-26 00:59:09 +0400 |
commit | 1b142434055e2b56b23991f0c9d695b6d4f33390 (patch) | |
tree | 8689574221e0d98697af406292b0383c14fc0c3b /release | |
parent | dff9dce1cdcb5250797f529456649510d2396096 (diff) | |
parent | 1c00eacca2b084d7189de33cb75e8612cb542030 (diff) |
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r20937:21899
missing commits from peter 20942, 21165, 21170, 21174, 21597
these files still need manual merging
source/blender/makesdna/DNA_sequence_types.h
source/blender/src/sequence.c
source/blender/src/seqeffects.c
source/blender/src/editseq.c
source/blender/include/BSE_sequence.h
Diffstat (limited to 'release')
-rw-r--r-- | release/datafiles/splash.jpg | bin | 196913 -> 197158 bytes | |||
-rw-r--r-- | release/scripts/bvh_import.py | 11 | ||||
-rw-r--r-- | release/scripts/export_dxf.py | 771 | ||||
-rw-r--r-- | release/scripts/export_fbx.py | 2 | ||||
-rw-r--r-- | release/scripts/export_map.py | 15 | ||||
-rw-r--r-- | release/scripts/export_obj.py | 10 | ||||
-rw-r--r-- | release/scripts/import_dxf.py | 19 | ||||
-rw-r--r-- | release/scripts/import_obj.py | 16 | ||||
-rw-r--r-- | release/scripts/object_active_to_other.py | 6 | ||||
-rw-r--r-- | release/scripts/vertexpaint_selfshadow_ao.py | 71 |
10 files changed, 604 insertions, 317 deletions
diff --git a/release/datafiles/splash.jpg b/release/datafiles/splash.jpg Binary files differindex deae8155ff4..1c34cf36f75 100644 --- a/release/datafiles/splash.jpg +++ b/release/datafiles/splash.jpg diff --git a/release/scripts/bvh_import.py b/release/scripts/bvh_import.py index 5cdd8a71231..4134503c511 100644 --- a/release/scripts/bvh_import.py +++ b/release/scripts/bvh_import.py @@ -277,12 +277,17 @@ def read_bvh(file_path, GLOBAL_SCALE=1.0): for bvh_node in bvh_nodes.itervalues(): if not bvh_node.rest_tail_world: - if len(bvh_node.children)==1: + if len(bvh_node.children)==0: + # could just fail here, but rare BVH files have childless nodes + bvh_node.rest_tail_world = Vector(bvh_node.rest_head_world) + bvh_node.rest_tail_local = Vector(bvh_node.rest_head_local) + elif len(bvh_node.children)==1: bvh_node.rest_tail_world= Vector(bvh_node.children[0].rest_head_world) bvh_node.rest_tail_local= Vector(bvh_node.children[0].rest_head_local) else: - if not bvh_node.children: - raise 'error, bvh node has no end and no children. bad file' + # allow this, see above + #if not bvh_node.children: + # raise 'error, bvh node has no end and no children. bad file' # Removed temp for now rest_tail_world= Vector(0,0,0) diff --git a/release/scripts/export_dxf.py b/release/scripts/export_dxf.py index b32962241cc..17f2132fbe8 100644 --- a/release/scripts/export_dxf.py +++ b/release/scripts/export_dxf.py @@ -1,13 +1,13 @@ #!BPY """ - Name: 'Autodesk DXF (.dxf)' + Name: 'Autodesk DXF (.dxf/dwg)' Blender: 249 Group: 'Export' Tooltip: 'Export geometry to DXF/DWG-r12 (Drawing eXchange Format).' """ -__version__ = "1.34 - 2009.06.08" +__version__ = "1.35 - 2009.06.18" __author__ = "Remigiusz Fiedler (AKA migius)" __license__ = "GPL" __url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf" @@ -31,19 +31,27 @@ IDEAs: - HPGL output, usefull for correct scaled printing of 2d drawings TODO: -- export dupligroups and dupliverts as blocks (option for the user to decide) +- export dupligroups and dupliverts as blocks (as option) - optimize POLYFACE routine: remove double-vertices -- more stable support for X,Y-rotated curves(to POLYLINEs): fix blender negative-matrix.invert() +- fix support for X,Y-rotated curves(to POLYLINEs): fix blender negative-matrix.invert() - support hierarchies: groups, instances, parented structures - support n/f-gons as POLYFACEs with invisible edges - mapping materials to DXF-styles - ProgressBar +- export rotation of Camera to VIEW/VPORT +- export parented Cameras to VIEW/VPORT - wip: write drawing extends for automatic view positioning in CAD -- wip: correct text-objects in persp-projection -- wip: translate Camera to VPORT/VIEW +- wip: fix text-objects in persp-projection - wip: translate current 3D-View to *ACTIVE-VPORT +- wip: fix support Include-Duplis, cause not conform with INSERT-method History +v1.35 - 2009.06.18 by migius +- export multiple-instances of Curve-Objects as BLOCK/INSERTs +- added export Cameras (ortho and persp) to VPORTs, incl. clipping +- added export Cameras (ortho and persp) to VIEWs, incl. clipping +- export multiple-instances of Mesh-Objects as BLOCK/INSERTs +- on start prints dxfLibrary version v1.34 - 2009.06.08 by migius - export Lamps and Cameras as POINTs - export passepartout for perspective projection @@ -55,7 +63,7 @@ v1.34 - 2009.06.08 by migius - support XYmirrored 2d-curves to 2dPOLYLINEs - support thickness and elevation for curve-objects - fix extrusion 210-code (3d orientation vector) -- fix POLYFACE export, synchronized with dxfLibrary.py +- fix POLYFACE export, synchronized also dxfLibrary.py - changed to the new 2.49 method Vector.cross() - output style manager (first try) v1.33 - 2009.05.25 by migius @@ -139,10 +147,16 @@ from Blender import Registry, Object, Mesh, Curve import os import subprocess -import dxfLibrary as DXF -#reload(DXF) -#reload(dxfLibrary) -#from dxfLibrary import * +try: + import dxfLibrary as DXF + #reload(DXF) + #reload(dxfLibrary) + #from dxfLibrary import * +except: + DXF=None + print "DXF-Exporter: error! found no dxfLibrary.py module in Blender script folder" + Draw.PupMenu("Error%t|found no dxfLibrary.py module in script folder") + import math from math import atan, atan2, log10, sin, cos @@ -152,9 +166,8 @@ from math import atan, atan2, log10, sin, cos r2d = 180.0 / math.pi d2r = math.pi / 180.0 #note: d2r * angle == math.radians(angle) +#note: r2d * angle == math.degrees(angle) -print '\n\n\n' -print 'DXF-Exporter v%s *** start ***' %(__version__) #--------------------- #DEBUG = True #activates debug mode @@ -170,6 +183,7 @@ SHADOWS = 0 # sun/shadows simulation CAMERA = 1 # selected camera index PERSPECTIVE = 0 # projection (camera) type: perspective, opposite to orthographic CAMERAVIEW = 0 # use camera for projection, opposite is 3d-view +INSTANCES = 1 # Export instances of Mesh/Curve as BLOCK/INSERTs on/off APPLY_MODIFIERS = 1 INCLUDE_DUPLIS = 0 OUTPUT_DWG = 0 #optional save to DWG with extern converter @@ -187,6 +201,7 @@ LAYERLTYPE_DEF = 0 #'CONTINUOUS' - default layer lineType ENTITYLAYER_DEF = LAYERNAME_DEF #default entity color index ENTITYCOLOR_DEF = BYLAYER #default entity color index ENTITYLTYPE_DEF = BYLAYER #default entity lineType + E_M = 0 LAB = "scroll MMB/WHEEL . wip .. todo" #"*) parts under construction" M_OBJ = 0 @@ -198,6 +213,7 @@ INIFILE_EXTENSION = '.ini' INIFILE_HEADER = '#ExportDXF.py ver.1.0 config data' INFFILE_HEADER = '#ExportDXF.py ver.1.0 analyze of DXF-data' +BLOCKREGISTRY = {} # registry and map for BLOCKs SCENE = None WORLDX = Mathutils.Vector((1,0,0)) WORLDY = Mathutils.Vector((0,1,0)) @@ -496,92 +512,136 @@ def isLeftHand(matrix): def exportMesh(ob, mx, mx_n, me=None, **common): """converts Mesh-Object to desired projection and representation(DXF-Entity type) """ + global BLOCKREGISTRY entities = [] - #print 'deb:exportMesh() common=', common #--------- + block = None + #print 'deb:exportMesh() given common=', common #--------- if me==None: me = ob.getData(mesh=1) else: me.getFromObject(ob) - # me.transform(mx); get verts data; me.transform(mx_inv)= back to the origin state - # above .transform method is faster, but bad, cause invasive: + # idea: me.transform(mx); get verts data; me.transform(mx_inv)= back to the origin state + # the .transform-method is fast, but bad, cause invasive: # it manipulates original geometry and by retransformation lefts back rounding-errors # we dont want to manipulate original data! #temp_verts = me.verts[:] #doesn't work on ubuntu(Yorik), bug? if me.verts: #print 'deb:exportMesh() started' #--------- - allpoints = [v.co for v in me.verts] - allpoints = projected_co(allpoints, mx) - allpoints = toNewOrigin(allpoints) - faces=[] - edges=[] - if me.faces and PROJECTION and HIDDEN_LINES: - #if DEBUG: print 'deb:exportMesh HIDDEN_LINES mode' #--------- - faces, edges = hidden_status(me.faces, mx, mx_n) - faces = [[v.index for v in me.faces[f_nr].verts] for f_nr in faces] - else: - #if DEBUG: print 'deb:exportMesh STANDARD mode' #--------- - for e in me.edges: edges.append(e.key) - #faces = [f.index for f in me.faces] - faces = [[v.index for v in f.verts] for f in me.faces] - #faces = [[allpoints[v.index] for v in f.verts] for f in me.faces] - #print 'deb: allpoints=\n', allpoints #--------- - #print 'deb: edges=\n', edges #--------- - #print 'deb: faces=\n', faces #--------- - if isLeftHand(mx): # then change vertex-order in every face - for f in faces: - f.reverse() - #f = [f[-1]] + f[:-1] #TODO: might be needed - #print 'deb: faces=\n', faces #--------- - - c = mesh_as_list[GUI_A['mesh_as'].val] - if 'POINTs'==c: # export Mesh as multiple POINTs - for p in allpoints: - dxfPOINT = DXF.Point(points=[p],**common) - entities.append(dxfPOINT) - elif 'LINEs'==c or (not faces): - if edges and allpoints: - if DEBUG: mesh_drawBlender(allpoints, edges, None) #deb: draw to blender scene - for e in edges: - points = [allpoints[e[0]], allpoints[e[1]]] - dxfLINE = DXF.Line(points, **common) - entities.append(dxfLINE) - elif faces: - if c in ('POLYFACE','POLYLINE'): - if allpoints: - #TODO: purge allpoints: left only vertices used by faces - if DEBUG: mesh_drawBlender(allpoints, None, faces) #deb: draw to scene - if not (PROJECTION and HIDDEN_LINES): - faces = [[v+1 for v in f] for f in faces] - else: - # for back-Faces-mode remove face-free verts - map=verts_state= [0]*len(allpoints) - for f in faces: - for v in f: - verts_state[v]=1 - if 0 in verts_state: # if dirty state - i,newverts=0,[] - for used_i,used in enumerate(verts_state): - if used: - newverts.append(allpoints[used_i]) - map[used_i]=i - i+=1 - allpoints = newverts - faces = [[map[v]+1 for v in f] for f in faces] - dxfPOLYFACE = DXF.PolyLine([allpoints, faces], flag=64, **common) - #print '\n deb: dxfPOLYFACE=',dxfPOLYFACE #------------- - entities.append(dxfPOLYFACE) - elif '3DFACEs'==c: - if DEBUG: mesh_drawBlender(allpoints, None, faces) #deb: draw to scene + + #print 'deb:exportMesh() ob.name=', ob.name #--------- + #print 'deb:exportMesh() me.name=', me.name #--------- + #print 'deb:exportMesh() me.users=', me.users #--------- + # check if there are more instances of this mesh (if used by other objects), then write to BLOCK/INSERT + if GUI_A['instances_on'].val and me.users>1 and not PROJECTION: + if me.name in BLOCKREGISTRY.keys(): + insert_name = BLOCKREGISTRY[me.name] + # write INSERT to entities + entities = exportInsert(ob, mx,insert_name, **common) + else: + # generate geom_output in ObjectCS + allpoints = [v.co for v in me.verts] + identity_matrix = Mathutils.Matrix().identity() + allpoints = projected_co(allpoints, identity_matrix) + #allpoints = toGlobalOrigin(allpoints) + faces=[] + edges=[] + for e in me.edges: edges.append(e.key) + faces = [[v.index for v in f.verts] for f in me.faces] + entities = writeMeshEntities(allpoints, edges, faces, **common) + if entities: # if not empty block + # write BLOCK definition and INSERT entity + # BLOCKREGISTRY = dictionary 'blender_name':'dxf_name'.append(me.name) + BLOCKREGISTRY[me.name]=validDXFr12name(('ME_'+ me.name)) + insert_name = BLOCKREGISTRY[me.name] + block = DXF.Block(insert_name,flag=0,base=(0,0,0),entities=entities) + # write INSERT as entity + entities = exportInsert(ob, mx, insert_name, **common) + + else: # no other instances, so go the standard way + allpoints = [v.co for v in me.verts] + allpoints = projected_co(allpoints, mx) + allpoints = toGlobalOrigin(allpoints) + faces=[] + edges=[] + if me.faces and PROJECTION and HIDDEN_LINES: + #if DEBUG: print 'deb:exportMesh HIDDEN_LINES mode' #--------- + faces, edges = hidden_status(me.faces, mx, mx_n) + faces = [[v.index for v in me.faces[f_nr].verts] for f_nr in faces] + else: + #if DEBUG: print 'deb:exportMesh STANDARD mode' #--------- + for e in me.edges: edges.append(e.key) + #faces = [f.index for f in me.faces] + faces = [[v.index for v in f.verts] for f in me.faces] + #faces = [[allpoints[v.index] for v in f.verts] for f in me.faces] + #print 'deb: allpoints=\n', allpoints #--------- + #print 'deb: edges=\n', edges #--------- + #print 'deb: faces=\n', faces #--------- + if isLeftHand(mx): # then change vertex-order in every face for f in faces: - #print 'deb: face=', f #--------- - points = [allpoints[key] for key in f] - #points = [p.co[:3] for p in points] - #print 'deb: pointsXX=\n', points #--------- - dxfFACE = DXF.Face(points, **common) - entities.append(dxfFACE) - + f.reverse() + #f = [f[-1]] + f[:-1] #TODO: might be needed + #print 'deb: faces=\n', faces #--------- + entities = writeMeshEntities(allpoints, edges, faces, **common) + + return entities, block + + +#------------------------------------------------- +def writeMeshEntities(allpoints, edges, faces, **common): + """help routine for exportMesh() + """ + entities = [] + + c = mesh_as_list[GUI_A['mesh_as'].val] + if 'POINTs'==c: # export Mesh as multiple POINTs + for p in allpoints: + dxfPOINT = DXF.Point(points=[p],**common) + entities.append(dxfPOINT) + elif 'LINEs'==c or (not faces): + if edges and allpoints: + if DEBUG: mesh_drawBlender(allpoints, edges, None) #deb: draw to blender scene + for e in edges: + points = [allpoints[e[0]], allpoints[e[1]]] + dxfLINE = DXF.Line(points, **common) + entities.append(dxfLINE) + elif faces: + if c in ('POLYFACE','POLYLINE'): + if allpoints: + #TODO: purge allpoints: left only vertices used by faces + if DEBUG: mesh_drawBlender(allpoints, None, faces) #deb: draw to scene + if not (PROJECTION and HIDDEN_LINES): + faces = [[v+1 for v in f] for f in faces] + else: + # for back-Faces-mode remove face-free verts + map=verts_state= [0]*len(allpoints) + for f in faces: + for v in f: + verts_state[v]=1 + if 0 in verts_state: # if dirty state + i,newverts=0,[] + for used_i,used in enumerate(verts_state): + if used: + newverts.append(allpoints[used_i]) + map[used_i]=i + i+=1 + allpoints = newverts + faces = [[map[v]+1 for v in f] for f in faces] + dxfPOLYFACE = DXF.PolyLine([allpoints, faces], flag=64, **common) + #print '\n deb: dxfPOLYFACE=',dxfPOLYFACE #------------- + entities.append(dxfPOLYFACE) + elif '3DFACEs'==c: + if DEBUG: mesh_drawBlender(allpoints, None, faces) #deb: draw to scene + for f in faces: + #print 'deb: face=', f #--------- + points = [allpoints[key] for key in f] + #points = [p.co[:3] for p in points] + #print 'deb: pointsXX=\n', points #--------- + dxfFACE = DXF.Face(points, **common) + entities.append(dxfFACE) + return entities + #----------------------------------------------------- def mesh_drawBlender(vertList, edgeList, faceList, name="dxfMesh", flatten=False, AT_CUR=True, link=True): #print 'deb:mesh_drawBlender started XXXXXXXXXXXXXXXXXX' #--------- @@ -640,7 +700,7 @@ def curve_drawBlender(vertList, org_point=[0.0,0.0,0.0], closed=0, name="dxfCurv #----------------------------------------------------- -def toNewOrigin(points): +def toGlobalOrigin(points): """relocates points to the new location needs a list of points [x,y,z] """ @@ -658,7 +718,7 @@ def exportEmpty(ob, mx, mw, **common): """ p = Mathutils.Vector(ob.loc) [p] = projected_co([p], mx) - [p] = toNewOrigin([p]) + [p] = toGlobalOrigin([p]) entities = [] c = empty_as_list[GUI_A['empty_as'].val] @@ -671,16 +731,50 @@ def exportEmpty(ob, mx, mw, **common): def exportCamera(ob, mx, mw, **common): """converts Camera-Object to desired projection and representation(DXF-Entity type) """ - p = Mathutils.Vector(ob.loc) - [p] = projected_co([p], mx) - [p] = toNewOrigin([p]) - - entities = [] + location = Mathutils.Vector(ob.loc) + [location] = projected_co([location], mx) + [location] = toGlobalOrigin([location]) + view_name=validDXFr12name(('CAM_'+ ob.name)) + + camera = Camera.Get(ob.getData(name_only=True)) + #print 'deb: camera=', dir(camera) #------------------ + if camera.type=='persp': + mode = 1+2+4+16 + # mode flags: 1=persp, 2=frontclip, 4=backclip,16=FrontZ + elif camera.type=='ortho': + mode = 0+2+4+16 + + leftBottom=(0.0,0.0) # default + rightTop=(1.0,1.0) # default + center=(0.0,0.0) # default + + direction = Mathutils.Vector(0.0,0.0,1.0) * mx.rotationPart() # in W-C-S + direction.normalize() + target=Mathutils.Vector(ob.loc) - direction # in W-C-S + #ratio=1.0 + width=height= camera.scale # for ortho-camera + lens = camera.lens # for persp-camera + frontClipping = -(camera.clipStart - 1.0) + backClipping = -(camera.clipEnd - 1.0) + + entities, vport, view = [], None, None c = camera_as_list[GUI_A['camera_as'].val] if c=="POINT": # export as POINT - dxfPOINT = DXF.Point(points=[p],**common) + dxfPOINT = DXF.Point(points=[location],**common) entities.append(dxfPOINT) - return entities + elif c=="VIEW": # export as VIEW + view = DXF.View(name=view_name, + center=center, width=width, height=height, + frontClipping=frontClipping,backClipping=backClipping, + direction=direction,target=target,lens=lens,mode=mode + ) + elif c=="VPORT": # export as VPORT + vport = DXF.VPort(name=view_name, + center=center, ratio=1.0, height=height, + frontClipping=frontClipping,backClipping=backClipping, + direction=direction,target=target,lens=lens,mode=mode + ) + return entities, vport, view #----------------------------------------------------- def exportLamp(ob, mx, mw, **common): @@ -688,7 +782,7 @@ def exportLamp(ob, mx, mw, **common): """ p = Mathutils.Vector(ob.loc) [p] = projected_co([p], mx) - [p] = toNewOrigin([p]) + [p] = toGlobalOrigin([p]) entities = [] c = lamp_as_list[GUI_A['lamp_as'].val] @@ -698,6 +792,75 @@ def exportLamp(ob, mx, mw, **common): return entities #----------------------------------------------------- +def exportInsert(ob, mx, insert_name, **common): + """converts Object to DXF-INSERT in given orientation + """ + WCS_loc = ob.loc # WCS_loc is object location in WorldCoordSystem + sizeX = ob.SizeX + sizeY = ob.SizeY + sizeZ = ob.SizeZ + rotX = ob.RotX + rotY = ob.RotY + rotZ = ob.RotZ + #print 'deb: sizeX=%s, sizeY=%s' %(sizeX, sizeY) #--------- + + Thickness,Extrusion,ZRotation,Elevation = None,None,None,None + + AXaxis = mx[0].copy().resize3D() # = ArbitraryXvector + if not PROJECTION: + #Extrusion, ZRotation, Elevation = getExtrusion(mx) + Extrusion, AXaxis = getExtrusion(mx) + + entities = [] + + if 1: + if not PROJECTION: + ZRotation,Zrotmatrix,OCS_origin,ECS_origin = getTargetOrientation(mx,Extrusion,\ + AXaxis,WCS_loc,sizeX,sizeY,sizeZ,rotX,rotY,rotZ) + ZRotation *= r2d + point = ECS_origin + else: #TODO: fails correct location + point1 = Mathutils.Vector(ob.loc) + [point] = projected_co([point1], mx) + if PERSPECTIVE: + clipStart = 10.0 + coef = -clipStart / (point1*mx)[2] + #print 'deb: coef=', coef #-------------- + #TODO: ? sizeX *= coef + #sizeY *= coef + #sizeZ *= coef + + #print 'deb: point=', point #-------------- + [point] = toGlobalOrigin([point]) + + #if DEBUG: text_drawBlender(textstr,points,OCS_origin) #deb: draw to scene + common['extrusion']= Extrusion + #common['elevation']= Elevation + #print 'deb: common=', common #------------------ + if 0: #DEBUG + #linepoints = [[0,0,0], [AXaxis[0],AXaxis[1],AXaxis[2]]] + linepoints = [[0,0,0], point] + dxfLINE = DXF.Line(linepoints,**common) + entities.append(dxfLINE) + + xscale=sizeX + yscale=sizeY + zscale=sizeZ + cols=None + colspacing=None + rows=None + rowspacing=None + + dxfINSERT = DXF.Insert(insert_name,point=point,rotation=ZRotation,\ + xscale=xscale,yscale=yscale,zscale=zscale,\ + cols=cols,colspacing=colspacing,rows=rows,rowspacing=rowspacing,\ + **common) + entities.append(dxfINSERT) + + return entities + + +#----------------------------------------------------- def exportText(ob, mx, mw, **common): """converts Text-Object to desired projection and representation(DXF-Entity type) """ @@ -755,7 +918,7 @@ def exportText(ob, mx, mw, **common): #print 'deb: coef=', coef #-------------- #print 'deb: point=', point #-------------- - [point] = toNewOrigin([point]) + [point] = toGlobalOrigin([point]) point2 = point #if DEBUG: text_drawBlender(textstr,points,OCS_origin) #deb: draw to scene @@ -835,132 +998,197 @@ def exportCurve(ob, mx, mw, **common): """converts Curve-Object to desired projection and representation(DXF-Entity type) """ entities = [] + block = None curve = ob.getData() - WCS_loc = ob.loc # WCS_loc is object location in WorldCoordSystem - #WCS_loc = [0.0,0.0,0.0] - #print 'deb: WCS_loc=', WCS_loc #--------- - sizeX = ob.SizeX - sizeY = ob.SizeY - sizeZ = ob.SizeZ - rotX = ob.RotX - rotY = ob.RotY - rotZ = ob.RotZ - #print 'deb: sizeX=%s, sizeY=%s' %(sizeX, sizeY) #--------- + #print 'deb: curve=', dir(curve) #--------- + # TODO: should be: if curve.users>1 and not (PERSPECTIVE or (PROJECTION and HIDDEN_MODE): + if GUI_A['instances_on'].val and curve.users>1 and not PROJECTION: + if curve.name in BLOCKREGISTRY.keys(): + insert_name = BLOCKREGISTRY[curve.name] + # write INSERT to entities + entities = exportInsert(ob, mx,insert_name, **common) + else: + # generate geom_output in ObjectCS + imx = Mathutils.Matrix().identity() + WCS_loc = [0,0,0] # WCS_loc is object location in WorldCoordSystem + #print 'deb: WCS_loc=', WCS_loc #--------- + sizeX = sizeY = sizeZ = 1.0 + rotX = rotY = rotZ = 0.0 + Thickness,Extrusion,ZRotation,Elevation = None,None,None,None + ZRotation,Zrotmatrix,OCS_origin,ECS_origin = None,None,None,None + AXaxis = imx[0].copy().resize3D() # = ArbitraryXvector + OCS_origin = [0,0,0] + if not PROJECTION: + #Extrusion, ZRotation, Elevation = getExtrusion(mx) + Extrusion, AXaxis = getExtrusion(imx) + + # no thickness/width for POLYLINEs converted into Screen-C-S + #print 'deb: curve.ext1=', curve.ext1 #--------- + if curve.ext1: Thickness = curve.ext1 * sizeZ + if curve.ext2 and sizeX==sizeY: + Width = curve.ext2 * sizeX + if "POLYLINE"==curve_as_list[GUI_A['curve_as'].val]: # export as POLYLINE + ZRotation,Zrotmatrix,OCS_origin,ECS_origin = getTargetOrientation(imx,Extrusion,\ + AXaxis,WCS_loc,sizeX,sizeY,sizeZ,rotX,rotY,rotZ) + + entities = writeCurveEntities(curve, imx, + Thickness,Extrusion,ZRotation,Elevation,AXaxis,Zrotmatrix, + WCS_loc,OCS_origin,ECS_origin,sizeX,sizeY,sizeZ, + **common) + + if entities: # if not empty block + # write BLOCK definition and INSERT entity + # BLOCKREGISTRY = dictionary 'blender_name':'dxf_name'.append(me.name) + BLOCKREGISTRY[curve.name]=validDXFr12name(('CU_'+ curve.name)) + insert_name = BLOCKREGISTRY[curve.name] + block = DXF.Block(insert_name,flag=0,base=(0,0,0),entities=entities) + # write INSERT as entity + entities = exportInsert(ob, mx, insert_name, **common) + + else: # no other instances, so go the standard way + WCS_loc = ob.loc # WCS_loc is object location in WorldCoordSystem + #print 'deb: WCS_loc=', WCS_loc #--------- + sizeX = ob.SizeX + sizeY = ob.SizeY + sizeZ = ob.SizeZ + rotX = ob.RotX + rotY = ob.RotY + rotZ = ob.RotZ + #print 'deb: sizeX=%s, sizeY=%s' %(sizeX, sizeY) #--------- + + Thickness,Extrusion,ZRotation,Elevation = None,None,None,None + ZRotation,Zrotmatrix,OCS_origin,ECS_origin = None,None,None,None + AXaxis = mx[0].copy().resize3D() # = ArbitraryXvector + OCS_origin = [0,0,0] + if not PROJECTION: + #Extrusion, ZRotation, Elevation = getExtrusion(mx) + Extrusion, AXaxis = getExtrusion(mx) + + # no thickness/width for POLYLINEs converted into Screen-C-S + #print 'deb: curve.ext1=', curve.ext1 #--------- + if curve.ext1: Thickness = curve.ext1 * sizeZ + if curve.ext2 and sizeX==sizeY: + Width = curve.ext2 * sizeX + if "POLYLINE"==curve_as_list[GUI_A['curve_as'].val]: # export as POLYLINE + ZRotation,Zrotmatrix,OCS_origin,ECS_origin = getTargetOrientation(mx,Extrusion,\ + AXaxis,WCS_loc,sizeX,sizeY,sizeZ,rotX,rotY,rotZ) + entities = writeCurveEntities(curve, mx, + Thickness,Extrusion,ZRotation,Elevation,AXaxis,Zrotmatrix, + WCS_loc,OCS_origin,ECS_origin,sizeX,sizeY,sizeZ, + **common) + + return entities, block - Thickness,Extrusion,ZRotation,Elevation = None,None,None,None - AXaxis = mx[0].copy().resize3D() # = ArbitraryXvector - OCS_origin = [0,0,0] - if not PROJECTION: - #Extrusion, ZRotation, Elevation = getExtrusion(mx) - Extrusion, AXaxis = getExtrusion(mx) - # no thickness/width for POLYLINEs converted into ScreenCS - #print 'deb: curve.ext1=', curve.ext1 #--------- - if curve.ext1: Thickness = curve.ext1 * sizeZ - if curve.ext2 and sizeX==sizeY: - Width = curve.ext2 * sizeX - if "POLYLINE"==curve_as_list[GUI_A['curve_as'].val]: # export as POLYLINE - ZRotation,Zrotmatrix,OCS_origin,ECS_origin = getTargetOrientation(mx,Extrusion,\ - AXaxis,WCS_loc,sizeX,sizeY,sizeZ,rotX,rotY,rotZ) +#------------------------------------------------- +def writeCurveEntities(curve, mx, + Thickness,Extrusion,ZRotation,Elevation,AXaxis,Zrotmatrix, + WCS_loc,OCS_origin,ECS_origin,sizeX,sizeY,sizeZ, + **common): + """help routine for exportCurve() + """ + entities = [] - for cur in curve: - #print 'deb: START cur=', cur #-------------- - points = [] - if cur.isNurb(): - for point in cur: - #print 'deb:isNurb point=', point #--------- - vec = point[0:3] - #print 'deb: vec=', vec #--------- - pkt = Mathutils.Vector(vec) - #print 'deb: pkt=', pkt #--------- - points.append(pkt) - else: - for point in cur: - #print 'deb:isBezier point=', point.getTriple() #--------- - vec = point.getTriple()[1] - #print 'deb: vec=', vec #--------- - pkt = Mathutils.Vector(vec) - #print 'deb: pkt=', pkt #--------- - points.append(pkt) - - #print 'deb: points', points #-------------- - if len(points)>1: - c = curve_as_list[GUI_A['curve_as'].val] - - if c=="POLYLINE": # export Curve as POLYLINE - if not PROJECTION: - # recalculate points(2d=X,Y) into Entity-Coords-System - for p in points: # list of vectors - p[0] *= sizeX - p[1] *= sizeY - p2 = p * Zrotmatrix - p2[0] += ECS_origin[0] - p2[1] += ECS_origin[1] - p[0],p[1] = p2[0],p2[1] - else: - points = projected_co(points, mx) - #print 'deb: points', points #-------------- - - if cur.isCyclic(): closed = 1 - else: closed = 0 - points = toNewOrigin(points) - - if DEBUG: curve_drawBlender(points,OCS_origin,closed) #deb: draw to scene - common['extrusion']= Extrusion - ##common['rotation']= ZRotation - ##common['elevation']= Elevation - common['thickness']= Thickness - #print 'deb: common=', common #------------------ - - if 0: #DEBUG - p=AXaxis[:3] - entities.append(DXF.Line([[0,0,0], p],**common)) - p=ECS_origin[:3] - entities.append(DXF.Line([[0,0,0], p],**common)) - common['color']= 5 - p=OCS_origin[:3] - entities.append(DXF.Line([[0,0,0], p],**common)) - #OCS_origin=[0,0,0] #only debug---------------- - dxfPLINE = DXF.PolyLine(points,OCS_origin,closed,**common) - entities.append(dxfPLINE) + if 1: + for cur in curve: + #print 'deb: START cur=', cur #-------------- + points = [] + if cur.isNurb(): + for point in cur: + #print 'deb:isNurb point=', point #--------- + vec = point[0:3] + #print 'deb: vec=', vec #--------- + pkt = Mathutils.Vector(vec) + #print 'deb: pkt=', pkt #--------- + points.append(pkt) + else: + for point in cur: + #print 'deb:isBezier point=', point.getTriple() #--------- + vec = point.getTriple()[1] + #print 'deb: vec=', vec #--------- + pkt = Mathutils.Vector(vec) + #print 'deb: pkt=', pkt #--------- + points.append(pkt) + + #print 'deb: points', points #-------------- + if len(points)>1: + c = curve_as_list[GUI_A['curve_as'].val] + + if c=="POLYLINE": # export Curve as POLYLINE + if not PROJECTION: + # recalculate points(2d=X,Y) into Entity-Coords-System + for p in points: # list of vectors + p[0] *= sizeX + p[1] *= sizeY + p2 = p * Zrotmatrix + p2[0] += ECS_origin[0] + p2[1] += ECS_origin[1] + p[0],p[1] = p2[0],p2[1] + else: + points = projected_co(points, mx) + #print 'deb: points', points #-------------- + + if cur.isCyclic(): closed = 1 + else: closed = 0 + points = toGlobalOrigin(points) + + if DEBUG: curve_drawBlender(points,OCS_origin,closed) #deb: draw to scene - dxfPLINE = DXF.PolyLine(points,OCS_origin,closed,**common) - entities.append(dxfPLINE) - if Thickness: - common['thickness']= -Thickness + common['extrusion']= Extrusion + ##common['rotation']= ZRotation + ##common['elevation']= Elevation + common['thickness']= Thickness + #print 'deb: common=', common #------------------ + + if 0: #DEBUG + p=AXaxis[:3] + entities.append(DXF.Line([[0,0,0], p],**common)) + p=ECS_origin[:3] + entities.append(DXF.Line([[0,0,0], p],**common)) + common['color']= 5 + p=OCS_origin[:3] + entities.append(DXF.Line([[0,0,0], p],**common)) + #OCS_origin=[0,0,0] #only debug---------------- + dxfPLINE = DXF.PolyLine(points,OCS_origin,closed,**common) + entities.append(dxfPLINE) + dxfPLINE = DXF.PolyLine(points,OCS_origin,closed,**common) entities.append(dxfPLINE) - - elif c=="LINEs": # export Curve as multiple LINEs - points = projected_co(points, mx) - if cur.isCyclic(): points.append(points[0]) - #print 'deb: points', points #-------------- - points = toNewOrigin(points) - - if DEBUG: curve_drawBlender(points,WCS_loc,closed) #deb: draw to scene - common['extrusion']= Extrusion - common['elevation']= Elevation - common['thickness']= Thickness - #print 'deb: common=', common #------------------ - for i in range(len(points)-1): - linepoints = [points[i], points[i+1]] - dxfLINE = DXF.Line(linepoints,**common) - entities.append(dxfLINE) - if Thickness: - common['thickness']= -Thickness + if Thickness: + common['thickness']= -Thickness + dxfPLINE = DXF.PolyLine(points,OCS_origin,closed,**common) + entities.append(dxfPLINE) + + elif c=="LINEs": # export Curve as multiple LINEs + points = projected_co(points, mx) + if cur.isCyclic(): points.append(points[0]) + #print 'deb: points', points #-------------- + points = toGlobalOrigin(points) + + if DEBUG: curve_drawBlender(points,WCS_loc,closed) #deb: draw to scene + common['extrusion']= Extrusion + common['elevation']= Elevation + common['thickness']= Thickness + #print 'deb: common=', common #------------------ for i in range(len(points)-1): linepoints = [points[i], points[i+1]] dxfLINE = DXF.Line(linepoints,**common) entities.append(dxfLINE) - - elif c=="POINTs": # export Curve as multiple POINTs - points = projected_co(points, mx) - for p in points: - dxfPOINT = DXF.Point(points=[p],**common) - entities.append(dxfPOINT) - + if Thickness: + common['thickness']= -Thickness + for i in range(len(points)-1): + linepoints = [points[i], points[i+1]] + dxfLINE = DXF.Line(linepoints,**common) + entities.append(dxfLINE) + + elif c=="POINTs": # export Curve as multiple POINTs + points = projected_co(points, mx) + for p in points: + dxfPOINT = DXF.Point(points=[p],**common) + entities.append(dxfPOINT) return entities + #----------------------------------------------------- def getClipBox(camera): """calculates Field-of-View-Clipping-Box of given Camera @@ -1075,12 +1303,12 @@ def drawClipBox(clip_box): verts.append([max_X2, max_Y2, max_Z]) verts.append([min_X2, max_Y2, max_Z]) faces = [[0,1,2,3],[4,5,6,7]] - nme = Mesh.New() - nme.verts.extend(verts) - nme.faces.extend(faces) + newmesh = Mesh.New() + newmesh.verts.extend(verts) + newmesh.faces.extend(faces) plan = Object.New('Mesh','clip_box') - plan.link(nme) + plan.link(newmesh) sce = Scene.GetCurrent() sce.objects.link(plan) plan.setMatrix(sce.objects.camera.matrix) @@ -1170,19 +1398,35 @@ def getCommons(ob): #----------------------------------------------------- def do_export(export_list, filepath): - global PERSPECTIVE, CAMERAVIEW + global PERSPECTIVE, CAMERAVIEW, BLOCKREGISTRY Window.WaitCursor(1) t = Blender.sys.time() # init Drawing --------------------- d=DXF.Drawing() # add Tables ----------------- - #d.blocks.append(b) #table blocks - #goes automatic: d.styles.append(DXF.Style()) #table styles + # initialized automatic: d.blocks.append(b) #section BLOCKS + # initialized automatic: d.styles.append(DXF.Style()) #table STYLE + + #table LTYPE --------------- + #d.linetypes.append(DXF.LineType(name='CONTINUOUS',description='--------',elements=[0.0])) + d.linetypes.append(DXF.LineType(name='DOT',description='. . . . . . .',elements=[0.25, 0.0, -0.25])) + d.linetypes.append(DXF.LineType(name='DASHED',description='__ __ __ __ __',elements=[0.8, 0.5, -0.3])) + d.linetypes.append(DXF.LineType(name='DASHDOT',description='__ . __ . __ .',elements=[1.0, 0.5, -0.25, 0.0, -0.25])) + d.linetypes.append(DXF.LineType(name='DIVIDE',description='____ . . ____ . . ',elements=[1.25, 0.5, -0.25, 0.0, -0.25, 0.0, -0.25])) + d.linetypes.append(DXF.LineType(name='BORDER',description='__ __ . __ __ . ',elements=[1.75, 0.5, -0.25, 0.5, -0.25, 0.0, -0.25])) + d.linetypes.append(DXF.LineType(name='HIDDEN',description='__ __ __ __ __',elements=[0.4, 0.25, -0.25])) + d.linetypes.append(DXF.LineType(name='CENTER',description='____ _ ____ _ __',elements=[2.0, 1.25, -0.25, 0.25, -0.25])) + + #d.vports.append(DXF.VPort('*ACTIVE')) + d.vports.append(DXF.VPort('*ACTIVE',center=(-5.0,1.0),height=10.0)) + #d.vports.append(DXF.VPort('*ACTIVE',leftBottom=(-100.0,-60.0),rightTop=(100.0,60.0))) #d.views.append(DXF.View('Normal')) #table view d.views.append(DXF.ViewByWindow('BF_TOPVIEW',leftBottom=(-100,-60),rightTop=(100,60))) #idem # add Entities -------------------- + BLOCKREGISTRY = {} # registry and map for BLOCKs + PERSPECTIVE = 0 something_ready = 0 selected_len = len(export_list) sce = Scene.GetCurrent() @@ -1246,9 +1490,10 @@ def do_export(export_list, filepath): layernames = [] for ob,mx in export_list: entities = [] + block = None #mx = ob.matrix.copy() #print 'deb: ob =', ob #--------- - print 'deb: ob.type =', ob.type #--------- + #print 'deb: ob.type =', ob.type #--------- #print 'deb: mx =\n', mx #--------- #print 'deb: mw0 =\n', mw0 #--------- #mx_n is trans-matrix for normal_vectors for front-side faces @@ -1274,10 +1519,10 @@ def do_export(export_list, filepath): d.layers.append(DXF.Layer(color=tempcolor, name=elayer)) if (ob.type == 'Mesh') and GUI_B['bmesh'].val: - entities = exportMesh(ob, mx, mx_n, tmp_me,\ + entities, block = exportMesh(ob, mx, mx_n, tmp_me,\ paperspace=espace, color=ecolor, layer=elayer, lineType=eltype) elif (ob.type == 'Curve') and GUI_B['bcurve'].val: - entities = exportCurve(ob, mx, mw, \ + entities, block = exportCurve(ob, mx, mw, \ paperspace=espace, color=ecolor, layer=elayer, lineType=eltype) elif (ob.type == 'Empty') and GUI_B['empty'].val: entities = exportEmpty(ob, mx, mw, \ @@ -1286,8 +1531,10 @@ def do_export(export_list, filepath): entities = exportText(ob, mx, mw, \ paperspace=espace, color=ecolor, layer=elayer, lineType=eltype) elif (ob.type == 'Camera') and GUI_B['camera'].val: - entities = exportCamera(ob, mx, mw, \ + entities, vport, view = exportCamera(ob, mx, mw, \ paperspace=espace, color=ecolor, layer=elayer, lineType=eltype) + if vport: d.vports.append(vport) + if view: d.views.append(view) elif (ob.type == 'Lamp') and GUI_B['lamp'].val: entities = exportLamp(ob, mx, mw, \ paperspace=espace, color=ecolor, layer=elayer, lineType=eltype) @@ -1297,16 +1544,26 @@ def do_export(export_list, filepath): for e in entities: d.append(e) + if block: + d.blocks.append(block) #add to BLOCK-section + + if something_ready: - if PERSPECTIVE: # draw view border - mw2 = Mathutils.Matrix().identity() - points = projected_co(border, mw2) + if PERSPECTIVE: # generate view border - passepartout + identity_matrix = Mathutils.Matrix().identity() + points = projected_co(border, identity_matrix) closed = 1 - points = toNewOrigin(points) - - dxfPLINE = DXF.PolyLine(points,points[0],closed,\ - paperspace=espace, color=LAYERCOLOR_DEF) - d.append(dxfPLINE) + points = toGlobalOrigin(points) + c = curve_as_list[GUI_A['curve_as'].val] + if c=="LINEs": # export Curve as multiple LINEs + for i in range(len(points)-1): + linepoints = [points[i], points[i+1]] + dxfLINE = DXF.Line(linepoints,paperspace=espace,color=LAYERCOLOR_DEF) + entities.append(dxfLINE) + else: + dxfPLINE = DXF.PolyLine(points,points[0],closed,\ + paperspace=espace, color=LAYERCOLOR_DEF) + d.append(dxfPLINE) if not GUI_A['outputDWG_on'].val: @@ -1573,7 +1830,7 @@ parent_as_menu = prepareMenu("export to: %t", parent_as_list) proxy_as_list = ["..BLOCK","..XREF","..ungroup","..POINT"] proxy_as_menu = prepareMenu("export to: %t", proxy_as_list) -camera_as_list = ["..BLOCK","..A_CAMERA","..VPORT","..VIEW","POINT"] +camera_as_list = ["..BLOCK","..A_CAMERA","VPORT","VIEW","POINT"] camera_as_menu = prepareMenu("export to: %t", camera_as_list) lamp_as_list = ["..BLOCK","..A_LAMP","POINT"] @@ -1655,6 +1912,7 @@ keywords_org = { 'outputDWG_on' : OUTPUT_DWG, 'to_polyline_on': POLYLINES, 'to_polyface_on': POLYFACES, + 'instances_on': INSTANCES, 'apply_modifiers_on': APPLY_MODIFIERS, 'include_duplis_on': INCLUDE_DUPLIS, 'camera_selected': CAMERA, @@ -1691,7 +1949,7 @@ keywords_org = { 'group_as' : 0, 'parent_as' : 0, 'proxy_as' : 0, - 'camera_as': 4, + 'camera_as': 3, 'lamp_as' : 2, } @@ -2066,7 +2324,7 @@ def draw_UI(): #--------------------------------------------------------------- but_3c = common_column #button 3.column menu_w = (3 * butt_margin) + but_0c + but_1c + but_2c + but_3c #menu width - simple_menu_h = 240 + simple_menu_h = 260 extend_menu_h = 345 menu_h = simple_menu_h # y is menu upper.y if config_UI.val: @@ -2361,6 +2619,11 @@ def draw_UI(): #--------------------------------------------------------------- y -= 20 b0, b0_ = but0c, but_0c + butt_margin +but_1c + GUI_A['instances_on'] = Draw.Toggle('Instances as BLOCKs', EVENT_NONE, b0, y, b0_, 20, GUI_A['instances_on'].val, "Export instances (multi-users) of Mesh/Curve as BLOCK/INSERTs on/off") + #b0, b0_ = but2c, but_2c + butt_margin + but_3c + + y -= 20 + b0, b0_ = but0c, but_0c + butt_margin +but_1c GUI_A['apply_modifiers_on'] = Draw.Toggle('Apply Modifiers', EVENT_NONE, b0, y, b0_, 20, GUI_A['apply_modifiers_on'].val, "Apply modifier stack to mesh objects before export on/off") #b0, b0_ = but2c, but_2c + butt_margin + but_3c @@ -2750,23 +3013,29 @@ def multi_export(DIR): #TODO: #----------------------------------------------------- if __name__=='__main__': - if not DXF.copy: - Draw.PupMenu('Error%t|The dxfLibrary.py script requires a full python install') - #Window.FileSelector(dxf_export_ui, 'EXPORT DXF', Blender.sys.makename(ext='.dxf')) - # recall last used DXF-file and INI-file names - dxffilename = check_RegistryKey('dxfFileName') - #print 'deb:start dxffilename:', dxffilename #---------------- - if dxffilename: dxfFileName.val = dxffilename - else: - dirname = Blender.sys.dirname(Blender.Get('filename')) - #print 'deb:start dirname:', dirname #---------------- - dxfFileName.val = Blender.sys.join(dirname, '') - inifilename = check_RegistryKey('iniFileName') - if inifilename: iniFileName.val = inifilename - - updateMenuCAMERA() - updateCAMERA() - - Draw.Register(draw_UI, event, bevent) - + if DXF: + print '\n\n\n' + print 'DXF-Exporter v%s *** start ***' %(__version__) #--------------------- + print 'with Library %s' %(DXF.__version__) #--------------------- + if not DXF.copy: + print "DXF-Exporter: dxfLibrary.py script requires a full Python install" + Draw.PupMenu('Error%t|The dxfLibrary.py script requires a full Python install') + else: + #Window.FileSelector(dxf_export_ui, 'EXPORT DXF', Blender.sys.makename(ext='.dxf')) + # recall last used DXF-file and INI-file names + dxffilename = check_RegistryKey('dxfFileName') + #print 'deb:start dxffilename:', dxffilename #---------------- + if dxffilename: dxfFileName.val = dxffilename + else: + dirname = Blender.sys.dirname(Blender.Get('filename')) + #print 'deb:start dirname:', dirname #---------------- + dxfFileName.val = Blender.sys.join(dirname, '') + inifilename = check_RegistryKey('iniFileName') + if inifilename: iniFileName.val = inifilename + + updateMenuCAMERA() + updateCAMERA() + + Draw.Register(draw_UI, event, bevent) +
\ No newline at end of file diff --git a/release/scripts/export_fbx.py b/release/scripts/export_fbx.py index 4115140a852..50357cbfa75 100644 --- a/release/scripts/export_fbx.py +++ b/release/scripts/export_fbx.py @@ -1464,7 +1464,7 @@ def write(filename, batch_objects = None, \ # Write Edge Smoothing file.write(''' - LayerElementSmoothing: 0 { + LayerElementSmoothing: 1 { Version: 101 Name: "" MappingInformationType: "ByEdge" diff --git a/release/scripts/export_map.py b/release/scripts/export_map.py index 7df78fc3c9a..ab32f6d5ff5 100644 --- a/release/scripts/export_map.py +++ b/release/scripts/export_map.py @@ -2,14 +2,14 @@ """ Name: 'Quake 3 (.map)' -Blender: 243 +Blender: 249 Group: 'Export' Tooltip: 'Export to Quake map format' """ __author__ = 'Campbell Barton' -__version__ = '0.1' -__email__ = "cbarton@metavr.com" +__version__ = '0.1a' +__email__ = "ideasman42@gmail.com" __bpydoc__ = """\ This script Exports a Quake 3 map format. @@ -234,7 +234,7 @@ def write_node_map(file, ob): as a MAP node as long as it has the property name - classname returns True/False based on weather a node was written ''' - props= [(p.name, p.data) for p in ob.properties] + props= [(p.name, p.data) for p in ob.game_properties] IS_MAP_NODE= False for name, value in props: @@ -287,7 +287,7 @@ def export_map(filepath): TOTBRUSH= TOTLAMP= TOTNODE= 0 for ob in Object.GetSelected(): - type= ob.getType() + type= ob.type if type == 'Mesh': obs_mesh.append(ob) elif type == 'Surf': obs_surf.append(ob) elif type == 'Lamp': obs_lamp.append(ob) @@ -406,9 +406,10 @@ NULL else: print "NOT EXPORTING PATCH", surf_name, u,v, 'Unsupported' - - file.write('}\n') # end worldspan + + if obs_mesh or obs_surf: + file.write('}\n') # end worldspan print '\twriting lamps' diff --git a/release/scripts/export_obj.py b/release/scripts/export_obj.py index 739b02bcbb3..7dffb5d2048 100644 --- a/release/scripts/export_obj.py +++ b/release/scripts/export_obj.py @@ -2,14 +2,14 @@ """ Name: 'Wavefront (.obj)...' -Blender: 248 +Blender: 249 Group: 'Export' Tooltip: 'Save a Wavefront OBJ File' """ __author__ = "Campbell Barton, Jiri Hnidek, Paolo Ciccone" __url__ = ['http://wiki.blender.org/index.php/Scripts/Manual/Export/wavefront_obj', 'www.blender.org', 'blenderartists.org'] -__version__ = "1.21" +__version__ = "1.22" __bpydoc__ = """\ This script is an exporter to OBJ file format. @@ -23,11 +23,11 @@ will be exported as mesh data. """ -# -------------------------------------------------------------------------- -# OBJ Export v1.1 by Campbell Barton (AKA Ideasman) -# -------------------------------------------------------------------------- # ***** BEGIN GPL LICENSE BLOCK ***** # +# Script copyright (C) Campbell J Barton 2007-2009 +# - V1.22- bspline import/export added (funded by PolyDimensions GmbH) +# # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 diff --git a/release/scripts/import_dxf.py b/release/scripts/import_dxf.py index 36a1a048075..b3bee11c464 100644 --- a/release/scripts/import_dxf.py +++ b/release/scripts/import_dxf.py @@ -7,7 +7,7 @@ Group: 'Import' Tooltip: 'Import for DWG/DXF geometry data.' """ __author__ = 'Kitsu(Ed Blake) & migius(Remigiusz Fiedler)' -__version__ = '1.12 - 2009.05.27 by migius' +__version__ = '1.12 - 2009.06.16 by migius' __url__ = ["http://blenderartists.org/forum/showthread.php?t=84319", "http://wiki.blender.org/index.php/Scripts/Manual/Import/DXF-3D"] __email__ = ["migius(at)4d-vectors.de","Kitsune_e(at)yahoo.com"] @@ -100,7 +100,7 @@ History: -- better support for long dxf-layer-names -- add configuration file.ini handles multiple material setups -- added f_layerFilter - -- to-check: obj/mat/group/_mapping-idea from ideasman42: + -- to-check: obj/mat/group/_mapping-idea from ideasman42 -- curves: added "fill/non-fill" option for closed curves: CIRCLEs,ELLIPSEs,POLYLINEs -- "normalize Z" option to correct non-planar figures -- LINEs need "width" in 3d-space incl vGroups @@ -108,11 +108,13 @@ History: -- add better support for color_index BYLAYER=256, BYBLOCK=0 -- bug: "oneMesh" produces irregularly errors -- bug: Registry recall from hd_cache ?? only win32 bug?? - -- support DXF-definitions of scene, lights and cameras + -- support DXF-definitions of autoshade: scene, lights and cameras -- support ortho mode for VIEWs and VPORTs as cameras + v1.12 - 2009.06.16 by migius + d7 fix for ignored BLOCKs (e.g. *X) which are members of other BLOCKs v1.12 - 2009.05.27 by migius - d6 todo: bugfix negative scaled INSERTs - isLeftHand(Matrix) check + d6 bugfix negative scaled INSERTs - isLeftHand(Matrix) check v1.12 - 2009.05.26 by migius d5 changed to the new 2.49 method Vector.cross() d5 bugfix WORLDY(1,1,0) to (0,1,0) @@ -161,7 +163,7 @@ History: a4 added to analyzeTool: report about VIEWs, VPORTs, unused/xref BLOCKs a4 bugfix: individual support for 2D/3DPOLYLINE/POLYMESH a4 added to UI: (*wip)BLOCK-(F): name filtering for BLOCKs - a4 added to UI: BLOCK-(n): filter anoname/hatch BLOCKs *X... + a4 added to UI: BLOCK-(n): filter noname/hatch BLOCKs *X... a2 g_scale_as is no more GUI_A-variable a2 bugfix "material": negative sign color_index a2 added support for BLOCKs defined with origin !=(0,0,0) @@ -4520,7 +4522,7 @@ def getBlocksmap(drawing, layersmap, layFrozen_on=False): #-------------------- item2str = [item2.name, item2.layer] childList.append(item2str) try: usedblocks[item.name] = [used, childList] - except KeyError: print 'Cannot map "%s" - "%s" as Block!' %(item.name, item) + except KeyError: print 'Cannot find "%s" Block!' %(item.name) #print 'deb:getBlocksmap: usedblocks=' , usedblocks #------------- #print 'deb:getBlocksmap: layersmap=' , layersmap #------------- @@ -4528,7 +4530,7 @@ def getBlocksmap(drawing, layersmap, layFrozen_on=False): #-------------------- if type(item) != list and item.type == 'insert': if not layersmap or (not layersmap[item.layer].frozen or layFrozen_on): #if insert_layer is not frozen try: usedblocks[item.name][0] = True - except: pass + except KeyError: print 'Cannot find "%s" Block!' %(item.name) key_list = usedblocks.keys() key_list.reverse() @@ -4536,7 +4538,8 @@ def getBlocksmap(drawing, layersmap, layFrozen_on=False): #-------------------- if usedblocks[key][0]: #if parent used, then set used also all child blocks for child in usedblocks[key][1]: if not layersmap or (layersmap and not layersmap[child[1]].frozen): #if insert_layer is not frozen - usedblocks[child[0]][0] = True # marked as used BLOCK + try: usedblocks[child[0]][0] = True # marked as used BLOCK + except KeyError: print 'Cannot find "%s" Block!' %(child[0]) usedblocks = [i for i in usedblocks.keys() if usedblocks[i][0]] #print 'deb:getBlocksmap: usedblocks=' , usedblocks #------------- diff --git a/release/scripts/import_obj.py b/release/scripts/import_obj.py index d88f06a2a47..81230bfcf03 100644 --- a/release/scripts/import_obj.py +++ b/release/scripts/import_obj.py @@ -9,7 +9,7 @@ Tooltip: 'Load a Wavefront OBJ File, Shift: batch import all dir.' __author__= "Campbell Barton", "Jiri Hnidek", "Paolo Ciccone" __url__= ['http://wiki.blender.org/index.php/Scripts/Manual/Import/wavefront_obj', 'blender.org', 'blenderartists.org'] -__version__= "2.11" +__version__= "2.13" __bpydoc__= """\ This script imports a Wavefront OBJ files to Blender. @@ -21,7 +21,8 @@ Note, This loads mesh objects and materials only, nurbs and curves are not suppo # ***** BEGIN GPL LICENSE BLOCK ***** # -# Script copyright (C) Campbell J Barton 2007 +# Script copyright (C) Campbell J Barton 2007-2009 +# - V2.12- bspline import/export added (funded by PolyDimensions GmbH) # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -124,6 +125,16 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_ image= obj_image_load(imagepath, DIR, IMAGE_SEARCH) has_data = image.has_data texture.image = image + + if not has_data: + try: + # first time using this image. We need to load it first + image.glLoad() + except: + # probably the image is crashed + pass + else: + has_data = image.has_data # Adds textures for materials (rendering) if type == 'Kd': @@ -207,6 +218,7 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_ context_material.setIOR( max(1, min(float(line_split[1]), 3))) # Between 1 and 3 elif line_lower.startswith('d') or line_lower.startswith('tr'): context_material.setAlpha(float(line_split[1])) + context_material.mode |= Material.Modes.ZTRANSP elif line_lower.startswith('map_ka'): img_filepath= line_value(line.split()) if img_filepath: diff --git a/release/scripts/object_active_to_other.py b/release/scripts/object_active_to_other.py index 131d1f63d74..68aa6a3a039 100644 --- a/release/scripts/object_active_to_other.py +++ b/release/scripts/object_active_to_other.py @@ -38,13 +38,13 @@ def my_object_util(sce): Draw.PupMenu('Error%t|No active object selected') return - mats = [ob.matrixWorld for ob in sce.objects.context if ob != ob_act] + mats = [(ob, ob.matrixWorld) for ob in sce.objects.context if ob != ob_act] - for m in mats: + for ob, m in mats: ob_copy = ob_act.copy() sce.objects.link(ob_copy) ob_copy.setMatrix(m) - ob_copy.Layers = ob.Layers + ob_copy.Layers = ob.Layers & (1<<20)-1 def main(): diff --git a/release/scripts/vertexpaint_selfshadow_ao.py b/release/scripts/vertexpaint_selfshadow_ao.py index 54c67fd27e2..3554e016f79 100644 --- a/release/scripts/vertexpaint_selfshadow_ao.py +++ b/release/scripts/vertexpaint_selfshadow_ao.py @@ -43,7 +43,7 @@ import bpy import BPyMesh -def vertexFakeAO(me, PREF_BLUR_ITERATIONS, PREF_BLUR_RADIUS, PREF_MIN_EDLEN, PREF_CLAMP_CONCAVE, PREF_CLAMP_CONVEX, PREF_SHADOW_ONLY, PREF_SEL_ONLY): +def vertexFakeAO(me, PREF_BLUR_ITERATIONS, PREF_BLUR_STRENGTH, PREF_CLAMP_CONCAVE, PREF_CLAMP_CONVEX, PREF_SHADOW_ONLY, PREF_SEL_ONLY): Window.WaitCursor(1) Ang= Mathutils.AngleBetweenVecs @@ -83,32 +83,34 @@ def vertexFakeAO(me, PREF_BLUR_ITERATIONS, PREF_BLUR_RADIUS, PREF_MIN_EDLEN, PRE if vert_tone_count[i]: vert_tone[i] = vert_tone[i] / vert_tone_count[i] + + # Below we use edges to blur along so the edges need counting, not the faces + vert_tone_count= [0] * len(me.verts) + for ed in me.edges: + vert_tone_count[ed.v1.index] += 1 + vert_tone_count[ed.v2.index] += 1 + - # BLUR TONE - edge_lengths= [ ed.length for ed in me.edges] + # Blur tone + blur = PREF_BLUR_STRENGTH + blur_inv = 1.0 - PREF_BLUR_STRENGTH for i in xrange(PREF_BLUR_ITERATIONS): + + # backup the original tones orig_vert_tone= list(vert_tone) - for ii, ed in enumerate(me.edges): + + for ed in me.edges: + i1= ed.v1.index i2= ed.v2.index - l= edge_lengths[ii] + + val1= (orig_vert_tone[i2]*blur) + (orig_vert_tone[i1]*blur_inv) + val2= (orig_vert_tone[i1]*blur) + (orig_vert_tone[i2]*blur_inv) - f=1.0 - if l > PREF_MIN_EDLEN and l < PREF_BLUR_RADIUS: - f= l/PREF_BLUR_RADIUS - - len_vert_tone_list_i1 = vert_tone_count[i1] - len_vert_tone_list_i2 = vert_tone_count[i2] - - if not len_vert_tone_list_i1: len_vert_tone_list_i1=1 - if not len_vert_tone_list_i2: len_vert_tone_list_i2=1 - - val1= (orig_vert_tone[i2]/len_vert_tone_list_i1)/ f - val2= (orig_vert_tone[i1]/len_vert_tone_list_i2)/ f - - vert_tone[i1]+= val1 - vert_tone[i2]+= val2 + # Apply the ton divided by the number of faces connected + vert_tone[i1]+= val1 / max(vert_tone_count[i1], 1) + vert_tone[i2]+= val2 / max(vert_tone_count[i2], 1) min_tone= min(vert_tone) @@ -144,21 +146,19 @@ def main(): me= ob.getData(mesh=1) - PREF_BLUR_ITERATIONS= Draw.Create(1) - PREF_BLUR_RADIUS= Draw.Create(0.05) - PREF_MIN_EDLEN= Draw.Create(0.01) + PREF_BLUR_ITERATIONS= Draw.Create(1) + PREF_BLUR_STRENGTH= Draw.Create(0.5) PREF_CLAMP_CONCAVE= Draw.Create(90) PREF_CLAMP_CONVEX= Draw.Create(20) PREF_SHADOW_ONLY= Draw.Create(0) PREF_SEL_ONLY= Draw.Create(0) pup_block= [\ 'Post AO Blur',\ - (' Iterations:', PREF_BLUR_ITERATIONS, 0, 40, 'Number times to blur the colors. (higher blurs more)'),\ - (' Blur Radius:', PREF_BLUR_RADIUS, 0.01, 40.0, 'How much distance effects blur transfur (higher blurs more).'),\ - (' Min EdgeLen:', PREF_MIN_EDLEN, 0.00001, 1.0, 'Minimim edge length to blur (very low values can cause errors).'),\ + ('Strength:', PREF_BLUR_STRENGTH, 0, 1, 'Blur strength per iteration'),\ + ('Iterations:', PREF_BLUR_ITERATIONS, 0, 40, 'Number times to blur the colors. (higher blurs more)'),\ 'Angle Clipping',\ - (' Highlight Angle:', PREF_CLAMP_CONVEX, 0, 180, 'Less then 180 limits the angle used in the tonal range.'),\ - (' Shadow Angle:', PREF_CLAMP_CONCAVE, 0, 180, 'Less then 180 limits the angle used in the tonal range.'),\ + ('Highlight Angle:', PREF_CLAMP_CONVEX, 0, 180, 'Less then 180 limits the angle used in the tonal range.'),\ + ('Shadow Angle:', PREF_CLAMP_CONCAVE, 0, 180, 'Less then 180 limits the angle used in the tonal range.'),\ ('Shadow Only', PREF_SHADOW_ONLY, 'Dont calculate highlights for convex areas.'),\ ('Sel Faces Only', PREF_SEL_ONLY, 'Only apply to UV/Face selected faces (mix vpain/uvface select).'),\ ] @@ -166,19 +166,16 @@ def main(): if not Draw.PupBlock('SelfShadow...', pup_block): return - PREF_BLUR_ITERATIONS= PREF_BLUR_ITERATIONS.val - PREF_BLUR_RADIUS= PREF_BLUR_RADIUS.val - PREF_MIN_EDLEN= PREF_MIN_EDLEN.val - PREF_CLAMP_CONCAVE= PREF_CLAMP_CONCAVE.val - PREF_CLAMP_CONVEX= PREF_CLAMP_CONVEX.val - PREF_SHADOW_ONLY= PREF_SHADOW_ONLY.val - PREF_SEL_ONLY= PREF_SEL_ONLY.val - if not me.vertexColors: me.vertexColors= 1 t= sys.time() - vertexFakeAO(me, PREF_BLUR_ITERATIONS, PREF_BLUR_RADIUS, PREF_MIN_EDLEN, PREF_CLAMP_CONCAVE, PREF_CLAMP_CONVEX, PREF_SHADOW_ONLY, PREF_SEL_ONLY) + vertexFakeAO(me, PREF_BLUR_ITERATIONS.val, \ + PREF_BLUR_STRENGTH.val, \ + PREF_CLAMP_CONCAVE.val, \ + PREF_CLAMP_CONVEX.val, \ + PREF_SHADOW_ONLY.val, \ + PREF_SEL_ONLY.val) if ob.modifiers: me.update() |