Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

3D

INTERN

ADOBE

ARDUINO

BITBUCKET

DOCKER

C4D

GIT

HTML

IPHONE

JAVASCRIPT

JTL-SHOP

LARAVEL

MAGENTO2

MYSQL

PHP

PLESK

PROCESSING

PYTHON

SUITECRM

SEO

TRYTON

THUNDERBIRD / ICEDOVE / FossaMail

TYPO3

TYPO3: BACKEND

TYPO3: TYPOSCRIPT

UNIX

VLC

VVVV

WINDOWS

WINDOWS 10

WORDPRESS

XAMPP

XT:C 4 (Veyton)

c4d:python-snippets

C4D Python Snippets

shuffle position of cloner objects ever 30 frames

import c4d
from c4d.modules import mograph as mo
import math, random
 
 
def my_shuffle(array):
    print 'before shuffle'
    random.shuffle(array)
    print '##after'
    return array
 
 
def main():
    # preparation
    md = mo.GeGetMoData(op)
    if md==None: return False
 
    cnt = md.GetCount()
 
    marr = md.GetArray(c4d.MODATA_MATRIX)
    fall = md.GetFalloffs()
    ud_off_y = op[c4d.ID_USERDATA,1]
 
    global marr1
 
    try:
        marr = marr1
    except NameError:
        pass
 
    frame = doc.GetTime().GetFrame(doc.GetFps())
    if frame%30==0:
        marr1 = my_shuffle(marr)
 
    # delivery
    md.SetArray(c4d.MODATA_MATRIX, marr, True)
    return True

morph between 2 states of cloner item

(taking relative position of an linked object as input value)

import c4d
from c4d.modules import mograph as mo
 
 
def main():
    # preperation
    md = mo.GeGetMoData(op)
    if md==None: return False
    frame = doc.GetTime().GetFrame(doc.GetFps())
    kugel = op[c4d.ID_USERDATA,1]
    kugelpos = kugel.GetAbsPos()
 
    cnt = md.GetCount()
    marr = md.GetArray(c4d.MODATA_MATRIX)
    fall = md.GetFalloffs()
 
    # _colorArray
    carr = [c4d.Vector(0.0)] * cnt
 
    # _modified clone array
    modcarr = [0.0] * cnt
 
    # processing
    for i in reversed(xrange(0,cnt)):
        diffvect = kugelpos - marr[i].off
        #newrot = target(marr[i], diffvect)
        distance = diffvect.GetLength()
 
        colormap = c4d.utils.Boxstep(300,350, distance)
 
        modcarr[i] = 1-(c4d.utils.Smoothstep(50,250,distance))
 
 
    md.SetArray(c4d.MODATA_CLONE, modcarr, True)
    md.SetArray(c4d.MODATA_MATRIX, marr, True)
    md.SetArray(c4d.MODATA_COLOR, carr, True)
 
    return True
c4d/python-snippets.txt · Zuletzt geändert: 2018/01/13 02:51 von admin