#!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 nos= BPyMesh.meshPrettyNormals(me) vert_tone= [0.0] * len(me.verts) vert_tone_list= [ [] for i in xrange(len(me.verts)) ] ed_face_users = [ [] for i in xrange(len(me.edges)) ] fcent= [BPyMesh.faceCent(f) for f in me.faces] min_tone=0 max_tone=0 for i, f in enumerate(me.faces): c= fcent[i] fno = f.no*0.0001 for v in f.v: #vno=v.no # ugly normal vno= nos[v.index]*0.0001 # pretty notrmal l1= (c-v.co).length l2= ((c+fno) - (v.co+vno)).length if abs(l1-l2) < 0.0000001: vert_tone_list[v.index].append(0) else: try: a= Ang(vno, fno) except: a=0 # Convex if l1