C4D tip - TENDRIL-ized: Random Walker Effector
This is the free video C4D tip - TENDRIL-ized: Random Walker Effector that can be downloaded, played and edit with our RedcoolMedia movie maker MovieStudio free video editor online and AudioStudio free audio editor online
VIDEO DESCRIPTION:
Play, download and edit the free video C4D tip - TENDRIL-ized: Random Walker Effector.
Random Walker Python Effector for Cinema 4D Cloner: original code made by Colin Sebestyen and enhanced with the invaluable help of Frubelsa; explanation on how to set up User Data at the end of video.
Scenes shamelessly copied from Tendril "AutoStore".
/ / / / / / Python Code / / / / / /
import c4d
from c4d.modules import mograph as mo
from c4d import utils as u
import random
walker = []
choiceData = []
startingPosForStepData = []
pF = -1 # Previous Frame
class Walker():
def __init__(self, location):
self.location = location
self.x = self.location[0]
self.y = self.location[1]
self.z = self.location[2]
def getStartingPosForStep(self, choice):
if choice == 0 or choice == 1:
return self.x
elif choice == 2 or choice == 3:
return self.y
elif choice == 4 or choice == 5:
return self.z
def move(self, index, cF, nF, step, stepsize, spline, width, height, depth, seed, clamped):
global choiceData, startingPosForStepData
if choiceData[index] == -1 or (cF % nF) == 0:
random.seed(cF+index+seed)
choice = random.randint(0, 5)
startingPosForStep = self.getStartingPosForStep(choice)
choiceData[index] = choice
startingPosForStepData[index] = startingPosForStep
valueToMap = ((cF % nF) + 1) * step
mapstep = u.RangeMap(valueToMap, 0, stepsize, 0, stepsize, False, spline)
if choiceData[index] == 0:
self.x = startingPosForStepData[index] + mapstep
elif choiceData[index] == 1:
self.x = startingPosForStepData[index] - mapstep
elif choiceData[index] == 2:
self.y = startingPosForStepData[index] + mapstep
elif choiceData[index] == 3:
self.y = startingPosForStepData[index] - mapstep
elif choiceData[index] == 4:
self.z = startingPosForStepData[index] + mapstep
elif choiceData[index] == 5:
self.z = startingPosForStepData[index] - mapstep
if clamped == 1:
self.x = u.ClampValue(self.x, -width/2, width/2)
self.y = u.ClampValue(self.y, -height/2, height/2)
self.z = u.ClampValue(self.z, -depth/2, depth/2)
self.location = c4d.Vector(self.x, self.y, self.z)
def initWalker(marr, count):
global walker
for i in xrange(0, count):
walker.append(Walker(marr[i].off))
choiceData.append(-1)
startingPosForStepData.append(0)
def main():
global walker, choiceData, startingPosForStepData, pF
md = mo.GeGetMoData(op)
# if there is no Modata, skip it
if md == None: return False
marr = md.GetArray(c4d.MODATA_MATRIX)
count = md.GetCount()
start = md.GetArray(c4d.MODATA_STARTMAT)
# userData
width = op[c4d.ID_USERDATA, 1]
height = op[c4d.ID_USERDATA, 2]
depth = op[c4d.ID_USERDATA, 3]
stepsize = op[c4d.ID_USERDATA, 4]
nF = op[c4d.ID_USERDATA, 5]
spline = op[c4d.ID_USERDATA, 6]
seed = op[c4d.ID_USERDATA, 7]
clamped = op[c4d.ID_USERDATA, 8]
# calculate step
step = stepsize / nF
cF = doc.GetTime().GetFrame(doc.GetFps())
#if pF == (cF - 1):
if (cF == 0):
md.SetArray(c4d.MODATA_MATRIX, start, True)
walker = []
choiceData = []
startingPosForStepData = []
pF = -1
return True
initWalker(marr, count)
#if pF == (cF - 1):
for i in reversed(xrange(0, count)):
walker[i].move(i, cF, nF, step, stepsize, spline, width, height, depth, seed, clamped)
marr[i].off = walker[i].location
md.SetArray(c4d.MODATA_MATRIX, marr, True)
return True
if __name__ == "__main__":
main()
/ / / / / / End Code / / / / / /
Download, play and edit free videos and free audios from C4D tip - TENDRIL-ized: Random Walker Effector using RedcoolMedia.net web apps