#!BPY """ Name: 'Self Shadow VCols (AO)...' Blender: 241 Group: 'VertexPaint' Tooltip: 'Generate Fake Ambient Occlusion with vertex colors.' """ __author__ = ["Campbell Barton"] __url__ = ("blender", "elysiun", "http://members.iinet.net.au/~cpbarton/ideasman/") __version__ = "0.1" __bpydoc__ = """\ Clean Weight This Script is to be used only in weight paint mode, It removes very low weighted verts from the current group with a weight option. """ # ***** BEGIN GPL LICENSE BLOCK ***** # # Script copyright (C) Campbell J Barton # # 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 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # ***** END GPL LICENCE BLOCK ***** # -------------------------------------------------------------------------- from Blender import * import BPyMesh # reload(BPyMesh) def vertexFakeAO(me, PREF_BLUR_ITERATIONS, PREF_BLUR_SCALE, PREF_CLAMP_CONCAVE, PREF_CLAMP_CONVEX, PREF_SHADOW_ONLY, PREF_SEL_ONLY): Window.WaitCursor(1) V=Mathutils.Vector M=Mathutils.Matrix Ang= Mathutils.AngleBetweenVecs BPyMesh.meshCalcNormals(me) vert_tone= [0.0] * len(me.verts) vert_tone_count= [0] * len(me.verts) ed_face_users = [ [] for i in xrange(len(me.edges)) ] fcent= [f.cent for f in me.faces] min_tone=0 max_tone=0 for i, f in enumerate(me.faces): c= fcent[i] fno = f.no for v in f.v: vno=v.no # get a scaled down normal. l1= (c-(v.co-vno)).length l2= (c-(v.co+vno)).length vert_tone_count[v.index]+=1 if abs(l1-l2) < 0.0000001: pass else: try: a= Ang(vno, fno) except: continue # Convex if l1