[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11977] trunk/blender/release/scripts/ image_billboard.py: update from stable

Campbell Barton cbarton at metavr.com
Sat Sep 8 14:09:51 CEST 2007


Revision: 11977
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11977
Author:   campbellbarton
Date:     2007-09-08 14:09:51 +0200 (Sat, 08 Sep 2007)

Log Message:
-----------
update from stable

Modified Paths:
--------------
    trunk/blender/release/scripts/image_billboard.py

Modified: trunk/blender/release/scripts/image_billboard.py
===================================================================
--- trunk/blender/release/scripts/image_billboard.py	2007-09-08 12:07:17 UTC (rev 11976)
+++ trunk/blender/release/scripts/image_billboard.py	2007-09-08 12:09:51 UTC (rev 11977)
@@ -48,11 +48,8 @@
 
 import Blender as B
 import BPyMathutils
-# reload(BPyMathutils)
+import bpy
 import BPyRender
-reload(BPyRender)
-import boxpack2d
-# reload(boxpack2d) # for developing.
 from Blender.Scene import Render
 
 import os
@@ -60,11 +57,11 @@
 
 def alpha_mat(image):
 	# returns a material useable for 
-	mtl= B.Material.New()
+	mtl= bpy.data.materials.new()
 	mtl.mode |= (B.Material.Modes.SHADELESS | B.Material.Modes.ZTRANSP | B.Material.Modes.FULLOSA )
 	mtl.alpha= 0.0 # so image sets the alpha
 	
-	tex= B.Texture.New()
+	tex= bpy.data.textures.new()
 	tex.type= B.Texture.Types.IMAGE
 	image.antialias = True
 	tex.setImageFlags('InterPol', 'UseAlpha')
@@ -126,7 +123,7 @@
 		camera_matrix= BPyMathutils.plane2mat(plane)
 		tmp_path= '%s_%d' % (PREF_IMAGE_PATH, i)
 		img= BPyRender.imageFromObjectsOrtho(ob_sel, tmp_path, PREF_TILE_RES.val, PREF_TILE_RES.val, PREF_AA.val, PREF_ALPHA.val, camera_matrix)
-		# img.reload()
+		img.reload()
 		#img.pack() # se we can keep overwriting the path
 		#img.filename= ""
 		
@@ -143,24 +140,25 @@
 			h= ((plane[1]-plane[2]).length + (plane[3]-plane[0]).length)/2
 			
 			face_data.append( (f, img, rot90) )
-			boxes2Pack.append( (i, h, w) )
+			boxes2Pack.append( [0.0,0.0,h, w, i] )
 	
 	if PREF_IMG_PACK.val:
 		# pack the quads into a square
+		packWidth, packHeight = B.Geometry.BoxPack2D(boxes2Pack)
 		
-		packWidth, packHeight, packedLs = boxpack2d.boxPackIter(boxes2Pack)
 		render_obs= []
 		
 		# Add geometry to the mesh
-		for box in packedLs:
-			i= box[0]
+		for box in boxes2Pack:
+			i= box[4]
 			
 			orig_f, img, rot90= face_data[i]
 			
 			# New Mesh and Object
 			render_mat= alpha_mat(img)
 			
-			render_me= B.Mesh.New()
+			render_me= bpy.data.meshes.new()
+			
 			render_ob= B.Object.New('Mesh')
 			render_me.materials= [render_mat]
 			render_ob.link(render_me)
@@ -168,10 +166,10 @@
 			render_obs.append(render_ob)
 			
 			# Add verts clockwise from the bottom left.
-			_x= box[1] / packWidth
-			_y= box[2] / packHeight
-			_w= box[3] / packWidth
-			_h= box[4] / packHeight
+			_x= box[0] / packWidth
+			_y= box[1] / packHeight
+			_w= box[2] / packWidth
+			_h= box[3] / packHeight
 			
 			
 			render_me.verts.extend([\
@@ -224,12 +222,11 @@
 
 
 def main():
-	scn= B.Scene.GetCurrent()
+	scn= bpy.data.scenes.active
 	ob_sel= list(scn.objects.context)
 	
 	PREF_KEEP_ASPECT= False
 	
-	
 	# Error Checking
 	if len(ob_sel) < 2:
 		B.Draw.PupMenu("Error%t|Select 2 mesh objects")
@@ -257,8 +254,6 @@
 			return
 	
 	
-	
-	
 	# Get user input
 	block = [\
 	'Image Pixel Size',\





More information about the Bf-blender-cvs mailing list