vertex color animation script blender

make a mesh i like grids

  1. make vertex colors on it
  2. make material and turn on vcol paint
  3. set drawtype to textured
  4. open text window and load this script:

wordpress invariably destroys my python when i try and put it in code tags for ya, sorry.  you’ll haftu fix the indents but hay what fun

#!BPY
“”"
Name:’AYVABTU’
Blender:245
Group:’Mesh’
Tooltip:’Selects Vertice moduli indices’
“”"
import Blender
import bpy
from Blender import Draw
from Blender import Window
from Blender import sys
import math
global N,inverting_modulus_truth,color_a,color_b,init_color_a,init_color_b,skipping_hidden,irf,igf,ibf
irf=igf=ibf=1.005
N = 2
skipping_hidden=bool(0)
inverting_modulus_truth = bool(1)
init_color_a=(0.8, 0.2, 0.8)
init_color_b=(0.2, 0.8, 0.2)
class Freq:
def __init__(self,freq):
self.freq=freq
def getN(self,n):
return int(math.sin(self.freq*n)*128)+128

class freqs:
def __init__(self,freqset):
self.fqs=[]
for fq in freqset:
self.fqs.append(Freq(fq))
def getN(self,n):
ret=[]
for fq in self.fqs:
ret.append(fq.getN(n))
return ret

t= Blender.sys.time()
print “===================[%s]======” % t
###########################################
scn=Blender.Scene.GetCurrent()
meshes = [me for me in scn.objects.selected if (me.type=='Mesh')]
if len(meshes)<1:
scn.objects.selected=[]
res=Draw.PupIntInput(“res for default grid:”,32,2,100)
if res==None:Blender.Draw.Exit()
nu=Blender.Mesh.Primitives.Grid(res,res,2)
nuob=scn.objects.new(nu,”nu”)
scn.objects.active=nuob
Window.RedrawAll()
Window.EditMode(0)
sce= bpy.data.scenes.active
ob_act = sce.objects.active
obj= ob_act.getData(mesh=1)
obj.vertexColors=True
Window.EditMode(0)

mt=Blender.Get(‘curframe’)
print “frame:”
print “\t”,mt

freq_set=freqs([irf+mt,igf+mt,ibf+mt])
for f in obj.faces:
for i,v in enumerate(f.verts):
if v.sel==1:
r,g,b=freq_set.getN(v.index)
print “–r%d g%d b%d–” %(r,g,b)
f.col[i].r=r
f.col[i].g=g
f.col[i].b=b

  1. go to script links and make a world scriptlink on framechanged that runs the text whalleva ucallit
  2. change the frame forward manually with arrow key
  3. tab into and out of the object
  4. you should see results but sometimes tinkering is needed
  5. now you can render an animation or just watch it slowly
  6. big meshes obviously cooler than little ones

~ by distroid on January 6, 2008.

Leave a Reply