Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Run this script to generate a UV map and Image with 1 pixel per face so each face has a single colour.
- import bpy
- import bmesh
- import math
- # Get selected/active object
- obj = bpy.context.object
- obj.update_from_editmode()
- bpy.ops.object.mode_set(mode='EDIT')
- bm = bmesh.from_edit_mesh(obj.data)
- # Get count of faces
- num_faces = len(bm.faces)
- # Create UV map
- obj.data.uv_textures.new("facepixels_"+str(num_faces))
- uv_layer = bm.loops.layers.uv[0]
- bm.faces.layers.tex.verify()
- # Process each face and position each loop vertex around the centre point
- faceidx = -1
- for f in bm.faces:
- faceidx = faceidx + 1
- loopidx = -1
- numverts = len(f.loops)
- for l in f.loops:
- loopidx = loopidx + 1
- luv = l[uv_layer]
- luv.uv[0] = float(faceidx)
- luv.uv[1] = 0.5
Add Comment
Please, Sign In to add comment