I wrote two Python Effectors that changes clone offset. Clone offset picks which child of the cloner gets cloned or the blending between those children. Keep in mind that offsetting clones does not change clone’s id number.

Clone offset

With the first Python Effector you can give clone id and child id to the input field and therefore you can change which child of the Cloner is chosen to that clone.

Syntax is [clone id, child id]. Clone and child indexes starts from 0 (zero). So, if you want that third clone is second child of the Cloner you would put [2,1]. You can modify as many clones as you please.

import c4d
from c4d.modules import mograph as mo

def main():
    try: # Try to execute following
        md = mo.GeGetMoData(op) # Get MoGraph data
        if md is None: return False # If there is no data, quit

        data = op[c4d.ID_USERDATA,1] # Get user data input
        c = data.replace('\n','') # Remove line breaks
        c = c.replace('\r','') # Remove carriage returns
        c = c.replace('[','') # Remove '[' characters
        c = c.split(']') # Split string to list using ']' character as a delimiter
        c.remove('') # Remove empty items from list
        clen = len(c) # Get length of the list

        gen = md.GetGenerator() # Get generator
        cnt = md.GetCount() # Get number of clones
        cln = md.GetArray(c4d.MODATA_CLONE) # Get clone array
        nchd = float(len(gen.GetChildren())) # Get number of generator's children
        fall = md.GetFalloffs() # Get falloffs

        for i in xrange(0, cnt): # Loop
            if i < clen: # If 'i' is not greater than length of the 'clen' list
                clone_id = int(c[i].split(',')[0]) # Get clone id
                child_id = int(c[i].split(',')[1]) # Get child id
                cln[clone_id] = (1/nchd) * child_id # Offset clone
    except: # If something goes wrong
        pass # Do nothing

    md.SetArray(c4d.MODATA_CLONE, cln, True) # Set clone array data
    return True

clone_offset_effector.c4d

Clone offset with weight threshold

With the second Python Effector you can change clones depending on weight transformation. You can choose number of the child and adjust the threshold. I don’t know how useful this tool is but it was fun to make.

import c4d
from c4d.modules import mograph as mo

def main():
    md = mo.GeGetMoData(op) # Get MoGraph data
    if md is None: return False # If there is no data, quit

    thd = op[c4d.ID_USERDATA,2] # Threshold
    cid = op[c4d.ID_USERDATA,3] # Chosen child id

    gen = md.GetGenerator() # Get generator
    cnt = md.GetCount() # Get number of clones
    cln = md.GetArray(c4d.MODATA_CLONE) # Get clone array
    warr = md.GetArray(c4d.MODATA_WEIGHT) # Get weight array
    nchd = float(len(gen.GetChildren())) # Get number of generator's children
    fall = md.GetFalloffs() # Get falloffs

    for i in reversed(xrange(0, cnt)): # Loop through clone count
        if warr[i] >= thd: # If clone weight is equal or greater than threshold
            cln[i] = (1/nchd)*(cid) # Offset clone

    md.SetArray(c4d.MODATA_CLONE, cln, True) # Set clone array data
    return True

clone_offset_with_weight.c4d

Cinema 4D, Effector, MoGraph, Python

N.B. This post is now obsolete because new version of Octane Render now supports X-Particles colors.

I have been wondering that is there a way to transfer color information from X-Particles to Octane? Well, today I started to messing around and I found some kind of solution or some kind of hack.

First thing to do is generate geometry to the particles. To do that I used polygon object that contains only single vertex point. Polygon object is put under the xpGenerator that generates vertex points to particles. To hook up xpGenerator into the MoGraph cloner xpGenerator need to be put under the connect object. Remember to turn welding off. Connect object is put to cloners object slot. Now we can clones to particles.

Next thing to do is the actual color data transformation.  I used python effector (MoGraph) to transfer color data from particles to clones. I added support for the particle rotation. With this python effector this setup works already perfectly in C4D’s own render engine but for some weird reason it does not work Octane Render.

import c4d, xparticles
from c4d.modules import mograph as mo
from c4d import utils as u

def main():
    md = mo.GeGetMoData(op) # Get MoData
    if md is None: return False # If there is no MoData, stop processing
    emitter = xparticles.ToEmitter(op[c4d.ID_USERDATA,1]) # Xpemitter link (user data)
    cnt = md.GetCount() # Get clone count
    carr = md.GetArray(c4d.MODATA_COLOR) # Get MoData color
    marr = md.GetArray(c4d.MODATA_MATRIX) # Get MoData matrix
    fall = md.GetFalloffs() # Get falloffs
    for i in reversed(xrange(0, cnt)): # Iterate through clones
        m = marr[i] # Get clone's matrix
        particle = emitter.GetParticle(i) # Get particle
        carr[i] = particle.GetColor() # Get particle color
        if particle.GetRotation() != None: # If particle is rotating
            hpb = particle.GetRotation() # Get particle rotation
            marr[i] = marr[i] * u.HPBToMatrix(hpb) # Set clone rotation to match particle rotation
    md.SetArray(c4d.MODATA_COLOR, carr, True) # Set MoData color
    md.SetArray(c4d.MODATA_MATRIX, marr, True) # Set MoData matrix
    return True # Everyting is fine

To get it work in Octane I had to add empty shader effector with blending mode set to multiply or divide. Empty means that there is no any shader in shader effector, you only need to chance blending mode. Last thing to do to get this setup to work is to add material with MoGraph color shader to the cloner. Now everything should be working fine.

There’s one drawback with this hack and it’s that the colors are a little bit off from the original in the render but I can live with that. Note that X-Particles own material doesn’t work since it’s calculated separately in rendering process. Another drawback is that this setup gets really slow when you have a thousands of particles. But cool thing is that you can use MoGraph effectors with particles.

xparticles_colors_to_octane.c4d

Cinema 4D, Experimental, MoGraph, Octane, Python, X-Particles

I saw a tweet from @der_flow_ where he has hooked TurbulenceFD into MoGraph weight tag. Of course, I wanted to test that too, so I built my own version and here is the result.

Xpresso setup iterates through clones and checks what is TFD container’s temperature in that specific position where the clone is. Temperature data is then range mapped to two different MoGraph weightmaps: mw-size and mw-color. Then those two weightmaps are used in effectors selection slots to scale and colorize clones.

Setup can get really slow but setup works also with render instances and multi-instances, even though only normal instance mode shows colors in view port.

 

Updated 25/03/2019

tfd_to_mograph.c4d

Cinema 4D, MoGraph, TurbulenceFD, Xpresso

I build my current desktop pc in 2012. It’s pretty old but still efficient. Only things that I have updated are graphic cards and SSDs. I mainly use my desktop computer but when I’m traveling I use 13″ MacBook Pro (mid 2014).

My computer’s specifications:
Operating System: Windows 7 Ultimate 64-bit
CPU: Intel i7 3930K @ 3.20 GHz Sandy Bridge-E 32nm
RAM: 32,0 DDR3 @ 1333 MHz
MOBO: Asus P9X79 Deluxe LGA2011
GPU: 2x Nvidia GeForce GTX 980
Storage: 2x Samsung 850 EVO 518GB SSD, 14TB Sata III HDD
PSU: Corsair AX850 – 80 Plus Gold
Case: Cooler Master Cosmos 1000
Fan: Noctua NH-D14

Other stuff on my table:
Sound Card: RME Babyface Pro
DAC: Cambridge Audio DacMagic Plus
Microphone: Shure SM7B
Headphones: Sony MDR-7506
Speakers: Genelec G Ones
Display: 2x Dell UltraSharp U2711
Pen Tablet: Wacom Intuos 3 Medium
Mouse: Logitech G900
Keyboard: Logitech K800

General Talk

This is my very first post on this my own little blog. I’m gonna post here all kind of stuff related to my interests like motion, 3D, coding, music and life. Hopefully you have a fun time with my blog and find something interesting to read. About myself, my name is Arttu Rautio. I’m a 26-year-old guy from Finland. Currently I’m working at Cocoa as post-production generalistic but my main focus is in 3D.

Everything you can find here on my blog is free to use, modify and share. You don’t have to ask any permissions and you don’t have to give a credits. It would be nice, but you don’t have to.

If you have anything to ask you can find me on Twitter (@aturtur).

Have fun!

General Talk