Python Effector - Step Effector Spline imitate
On 19/02/2013 at 13:39, xxxxxxxx wrote:
Could any one help me with getting the spline data, from a user data on a python effector, to control the strength the effector has on the clones, similar to the spline in the Step Effector.
Im trying to make use of util.RangeMap to map the data back into the clones but can't seem to crack it. Any help would be great.
On 20/02/2013 at 10:47, xxxxxxxx wrote:
there are some examples in python sdk examples which implement effector like behaviours.
you'll have to provide some code, so that we can actually help you. the basic approach
1. get the MoData
2. get the relevant matrix lists in the MoData
3. get matrix of you effector object
4. update/calculate the updated matrix for each particle with the effector matrix, your SplineData
and the the existing MoData matrix for the particle.
5. write the data back.
On 20/02/2013 at 15:46, xxxxxxxx wrote:
I have been through the python pluginin examples and have not found a spline gui implicated example? Maybe I missed something?
As a sarting poing I would just like to be able to control the effect on clones that the regular python effector has, this is the initial code:
import c4d from c4d.modules import mograph as mo #Welcome to the world of Python def main() : md = mo.GeGetMoData(op) if md==None: return 1.0 index = md.GetCurrentIndex() mode = md.GetBlendID() if mode==c4d.ID_MG_BASEEFFECTOR_POSITION: return c4d.Vector(0.5) else: return 1.0
I would just like a user data of a spline gui to effect the strength on the clones. Like the Step Effector does. Any help?
On 20/02/2013 at 16:17, xxxxxxxx wrote:
posting the python effector default code is not your own code. you also need to set
the python effector tu full control if you want to drive the particle matrices.
create a python effector, set it to full controll, add a vector userdata and a spline
userdata (in the exact order, the code expects the vector to be the first component)
and paste the code into the node. it is a rather simple example which uses the particle
index to aply an offset vector which is being throttled by the spline (which again is
being mapped along the indices).
import c4d from c4d.modules import mograph as mo from c4d import utils as u def main() : vec = op[c4d.ID_USERDATA,1] spldata = op[c4d.ID_USERDATA,2] md = mo.GeGetMoData(op) if md == None: return False cnt = md.GetCount() marr = md.GetArray(c4d.MODATA_MATRIX) fall = md.GetFalloffs() for i in reversed(xrange(0, cnt)) : splinf = u.RangeMap(value = i, mininput = 0, maxinput = cnt, minoutput = 0, maxoutput = 1.0, clampval = False, curve = spldata) marr[i].off = marr[i].off+fall[i] + (i * vec * splinf) # o md.SetArray(c4d.MODATA_MATRIX, marr, True) return True
On 21/02/2013 at 09:51, xxxxxxxx wrote:
Thank you for your help, much appreciated, it cleared up a few sticking points I had. I know you said that it was only a simple example but its having some unexpected functionality in that the spline.y data (0-1y) seems to effect the clones as normal, but not the spline.x points. So for example having a sin wave spline in the gui of 'spldata' wouldn't be reflected in the clones. I presume it has something to do with the way the clones are indexed and the data being passed back to them?
On 21/02/2013 at 10:20, xxxxxxxx wrote:
the matrix is driven by the index and the spline. to only have the spline influence your
offset vector remove the index as a factor. my example mapped both, the indices and
the spline, which will return a kind of non linear result.
marr _.off = marr _.off+fall _\+ (vec \* splinf)___
note that the input vector will be used in an absolute manner that way, not in a stepped
fashion, like the example above.