[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18450] trunk/blender/release/scripts: == Scripts ==

Willian Padovani Germano wpgermano at gmail.com
Sun Jan 11 17:13:00 CET 2009


Revision: 18450
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18450
Author:   ianwill
Date:     2009-01-11 17:13:00 +0100 (Sun, 11 Jan 2009)

Log Message:
-----------
== Scripts ==

- Scripts Help Browser: Brendon Murphy requested and Kevin Morgan implemented a "run script" button.
- AC3D importer: option to store emis color from .ac file in mirror color in Blender (the exporter has the option to export mirror color as emis). Patch by Francesco Brisa.

Thanks for the contributions.

Modified Paths:
--------------
    trunk/blender/release/scripts/ac3d_import.py
    trunk/blender/release/scripts/help_browser.py

Modified: trunk/blender/release/scripts/ac3d_import.py
===================================================================
--- trunk/blender/release/scripts/ac3d_import.py	2009-01-11 15:15:15 UTC (rev 18449)
+++ trunk/blender/release/scripts/ac3d_import.py	2009-01-11 16:13:00 UTC (rev 18450)
@@ -8,9 +8,9 @@
 """
 
 __author__ = "Willian P. Germano"
-__url__ = ("blender", "blenderartists.org", "AC3D's homepage, http://www.ac3d.org",
+__url__ = ("blender", "elysiun", "AC3D's homepage, http://www.ac3d.org",
 	"PLib 3d gaming lib, http://plib.sf.net")
-__version__ = "2.43.1 2007-02-21"
+__version__ = "2.48.1 2009-01-11"
 
 __bpydoc__ = """\
 This script imports AC3D models into Blender.
@@ -31,6 +31,7 @@
 Config Options:<br>
     - display transp (toggle): if "on", objects that have materials with alpha < 1.0 are shown with translucency (transparency) in the 3D View.<br>
     - subdiv (toggle): if "on", ac3d objects meant to be subdivided receive a SUBSURF modifier in Blender.<br>
+    - emis as mircol: store the emissive rgb color from AC3D as mirror color in Blender -- this is a hack to preserve the values and be able to export them using the equivalent option in the exporter.<br>
     - textures dir (string): if non blank, when imported texture paths are
 wrong in the .ac file, Blender will also look for them at this dir.
 
@@ -50,11 +51,12 @@
 # --------------------------------------------------------------------------
 # Thanks: Melchior Franz for extensive bug testing and reporting, making this
 # version cope much better with old or bad .ac files, among other improvements;
-# Stewart Andreason for reporting a serious crash.
+# Stewart Andreason for reporting a serious crash; Francesco Brisa for the
+# emis as mircol functionality (w/ patch).
 # --------------------------------------------------------------------------
 # ***** BEGIN GPL LICENSE BLOCK *****
 #
-# Copyright (C) 2004-2007: Willian P. Germano, wgermano _at_ ig.com.br
+# Copyright (C) 2004-2009: Willian P. Germano, wgermano _at_ ig.com.br
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -89,15 +91,19 @@
 
 SUBDIV = True
 
+EMIS_AS_MIRCOL = False
+
+
 tooltips = {
 	'DISPLAY_TRANSP': 'Turn transparency on in the 3d View for objects using materials with alpha < 1.0.',
 	'SUBDIV': 'Apply a SUBSURF modifier to objects meant to appear subdivided.',
-	'TEXTURES_DIR': 'Additional folder to look for missing textures.'
+	'TEXTURES_DIR': 'Additional folder to look for missing textures.',
+	'EMIS_AS_MIRCOL': 'Store emis color as mirror color in Blender.'	
 }
 
 def update_registry():
-	global TEXTURES_DIR, DISPLAY_TRANSP
-	rd = dict([('tooltips', tooltips), ('TEXTURES_DIR', TEXTURES_DIR), ('DISPLAY_TRANSP', DISPLAY_TRANSP), ('SUBDIV', SUBDIV)])
+	global TEXTURES_DIR, DISPLAY_TRANSP, EMIS_AS_MIRCOL
+	rd = dict([('tooltips', tooltips), ('TEXTURES_DIR', TEXTURES_DIR), ('DISPLAY_TRANSP', DISPLAY_TRANSP), ('SUBDIV', SUBDIV), ('EMIS_AS_MIRCOL', EMIS_AS_MIRCOL)])
 	Registry.SetKey('ac3d_import', rd, True)
 
 rd = Registry.GetKey('ac3d_import', True)
@@ -109,6 +115,7 @@
 		TEXTURES_DIR = rd['TEXTURES_DIR']
 		DISPLAY_TRANSP = rd['DISPLAY_TRANSP']
 		SUBDIV = rd['SUBDIV']
+		EMIS_AS_MIRCOL = rd['EMIS_AS_MIRCOL']
 	except:
 		update_registry()
 else: update_registry()
@@ -299,7 +306,7 @@
 		lines = self.lines
 		line = lines[i].split()
 		mat_name = ''
-		mat_col = mat_amb = mat_emit = mat_spec_col = [0,0,0]
+		mat_col = mat_amb = mat_emit = mat_spec_col = mat_mir_col = [0,0,0]
 		mat_alpha = 1
 		mat_spec = 1.0
 
@@ -310,11 +317,15 @@
 			mat_amb = (v[0]+v[1]+v[2]) / 3.0
 			v = map(float,[line[11],line[12],line[13]])
 			mat_emit = (v[0]+v[1]+v[2]) / 3.0
+			if EMIS_AS_MIRCOL:
+				mat_emit = 0
+				mat_mir_col = map(float,[line[11],line[12],line[13]])
+
 			mat_spec_col = map(float,[line[15],line[16],line[17]])
 			mat_spec = float(line[19]) / 64.0
 			mat_alpha = float(line[-1])
 			mat_alpha = 1 - mat_alpha
-			self.mlist.append([mat_name, mat_col, mat_amb, mat_emit, mat_spec_col, mat_spec, mat_alpha])
+			self.mlist.append([mat_name, mat_col, mat_amb, mat_emit, mat_spec_col, mat_spec, mat_mir_col, mat_alpha])
 			i += 1
 			line = lines[i].split()
 
@@ -590,7 +601,8 @@
 			m.emit = mat[3]
 			m.specCol = (mat[4][0], mat[4][1], mat[4][2])
 			m.spec = mat[5]
-			m.alpha = mat[6]
+			m.mirCol = (mat[6][0], mat[6][1], mat[6][2])
+			m.alpha = mat[7]
 			if m.alpha < 1.0:
 				m.mode |= MAT_MODE_ZTRANSP
 				has_transp_mats = True

Modified: trunk/blender/release/scripts/help_browser.py
===================================================================
--- trunk/blender/release/scripts/help_browser.py	2009-01-11 15:15:15 UTC (rev 18449)
+++ trunk/blender/release/scripts/help_browser.py	2009-01-11 16:13:00 UTC (rev 18450)
@@ -8,7 +8,7 @@
 """
 
 __author__ = "Willian P. Germano"
-__version__ = "0.1 11/02/04"
+__version__ = "0.2 01/11/09"
 __email__ = ('scripts', 'Author, wgermano:ig*com*br')
 __url__ = ('blender', 'blenderartists.org')
 
@@ -47,8 +47,6 @@
 # $Id$
 #
 # --------------------------------------------------------------------------
-# sysinfo.py version 0.1 Jun 09, 2004
-# --------------------------------------------------------------------------
 # ***** BEGIN GPL LICENSE BLOCK *****
 #
 # Copyright (C) 2004: Willian P. Germano, wgermano _at_ ig.com.br
@@ -69,6 +67,8 @@
 #
 # ***** END GPL LICENCE BLOCK *****
 # --------------------------------------------------------------------------
+# Thanks: Brendon Murphy (suggestion) and Kevin Morgan (implementation)
+# for the "run" button.
 
 import Blender
 from Blender import sys as bsys, Draw, Window, Registry
@@ -543,6 +543,7 @@
 BEVT_VIEWSOURCE = 1
 BEVT_EXIT = 2
 BEVT_BACK = 3
+BEVT_EXEC = 4	# Executes Script
 
 # gui callbacks:
 
@@ -551,7 +552,7 @@
 	global SCREEN, START_SCREEN, SCRIPT_SCREEN
 	global SCRIPT_INFO, AllGroups, GROUP_MENUS
 	global BEVT_EMAIL, BEVT_LINK
-	global BEVT_VIEWSOURCE, BEVT_EXIT, BEVT_BACK, BEVT_GMENU, BUT_GMENU
+	global BEVT_VIEWSOURCE, BEVT_EXIT, BEVT_BACK, BEVT_GMENU, BUT_GMENU, BEVT_EXEC
 	global PADDING, WIN_W, WIN_H, SCROLL_DOWN, COLUMNS, FMODE
 
 	theme = Theme.Get()[0]
@@ -674,8 +675,11 @@
 				'View this script\'s source code in the Text Editor (hotkey: S)')
 			Draw.PushButton('exit', BEVT_EXIT, x + 45, 17, 45, bh,
 				'Exit from Scripts Help Browser (hotkey: Q)')
-			if not FMODE: Draw.PushButton('back', BEVT_BACK, x + 2*45, 17, 45, bh,
+			if not FMODE: 
+				Draw.PushButton('back', BEVT_BACK, x + 2*45, 17, 45, bh,
 				'Back to scripts selection screen (hotkey: ESC)')
+				Draw.PushButton('run script', BEVT_EXEC, x + 3*45, 17, 60, bh, 'Run this script')
+
 			BGL.glColor3ub(COL_TXTHI[0],COL_TXTHI[1], COL_TXTHI[2])
 			BGL.glRasterPos2i(x, 5)
 			Draw.Text('use the arrow keys or the mouse wheel to scroll text', 'small')
@@ -766,7 +770,15 @@
 			SCRIPT_INFO = None
 			SCROLL_DOWN = 0
 			Draw.Redraw()
+	elif evt == BEVT_EXEC: # Execute script
+		exec_line = ''
+		if SCRIPT_INFO.script.userdir:
+			exec_line = bsys.join(Blender.Get('uscriptsdir'), SCRIPT_INFO.script.fname)
+		else:
+			exec_line = bsys.join(Blender.Get('scriptsdir'), SCRIPT_INFO.script.fname)
 
+		Blender.Run(exec_line)
+
 keepon = True
 FMODE = False # called by Blender.ShowHelp(name) API function ?
 





More information about the Bf-blender-cvs mailing list