PolyFX Effector - how



  • On 26/04/2013 at 02:58, xxxxxxxx wrote:

    I've go this running as a vertex effector (seems to work ok with cloner)

    Someone asked me how to make it work with PolyFX as an effector
    it doesnt work - the effector creates what looks like a tiled image of the vertex map

    Can't seem to find any info on Polyfx
    Can anyone help - pointers, advice

    oh - and if you spot the obvious in the code below - pls feel free to amend

    tia

    Paul

    import c4d
    from c4d.modules import mograph as mo
    from c4d import utils
      
      
    def main() :
        md = mo.GeGetMoData(op)
        if md==None: return False
        
        cnt = md.GetCount()
        marr = md.GetArray(c4d.MODATA_MATRIX)
        start = marr
        fall = md.GetFalloffs()
                
        tag = op[c4d.ID_USERDATA,1]
        if tag == None: return False 
        
        posn = op[c4d.ID_USERDATA,2]
        scl = op[c4d.ID_USERDATA,4] 
        rot = op[c4d.ID_USERDATA,3]
      
        tagh = tag.GetAllHighlevelData() #get the vertex map as a list of reals matched to each vertex
          
        index = md.GetCurrentIndex()
        for i in reversed(xrange(0, cnt)) :
     
            # scale
            marr[i].v1 = marr[i].v1 * scl.x * tagh[i]
            marr[i].v2 = marr[i].v2 * scl.y * tagh[i]
            marr[i].v3 = marr[i].v3 * scl.z * tagh[i]  
            
            # position
            marr[i].off += marr[i].MulV(posn) *tagh[i]
      
            # rotation       
            marr[i] = marr[i] *utils.HPBToMatrix(rot)         
      
        md.SetArray(c4d.MODATA_MATRIX, marr, True)
        return True
    


  • On 02/05/2013 at 02:22, xxxxxxxx wrote:

    Anyone?

    Appreciate PolyFX  is a different beast to a cloner - but no idea how to access the polys that are controlled by this effector
    Tried searching teh SDK for PolyFX - nothing?



  • On 04/05/2013 at 02:39, xxxxxxxx wrote:

    last shout - help



  • On 04/05/2013 at 03:26, xxxxxxxx wrote:

    lol,

    totally overlook this thread somehow. it is very difficult to answer, as you did not really describe
    your problem. you should attach some pictures. generally speaking there are no differences in
    the MoDataData arrays returned by a PolyFx object compared to other cloners. It simply does
    index the object polygons from 0 to n (in full mode).

    the only thing which seems a bit awkward in your code is that you use the same index to 
    reference both your vertexmap and your matrix list. vertexmaps are vertex indexed, while
    the PolyFX object is polygon indexed, not sure if this connection is intended.



  • On 07/05/2013 at 04:21, xxxxxxxx wrote:

    Thanks LD

    That has helped get a better picture (I think)

    This particular effector needs its Cloner to use OBJECT - VERTEX to place clones and do its business

    If I use the cloner in OBJECT - POLYGON CENTRE mode to place clones using the vertex map I get an odd repeat/tile of the vertex map, that is exactly the same as if using PolyFx and the Vertex effector and creates the problem

    I need to find a way to test for either the USE POLYGON CENTRE mode or VERTEX mode* is running in the cloner -  - or if the Effector is being used by PolyFX*.

    Then (AFAIKS) average out the 4 vertex values if appropriate for the cloner mode, to one value.

    I think I see what you mean about the two indexes - they will be different depending on the Cloner settings or usage*
    Still need to get my head around how to do this.

    Any suggestions welcome.



  • On 07/05/2013 at 05:20, xxxxxxxx wrote:

    geez,

    i have again problems to understand what you are after. as you are a native speaker I
    suppose the problem is on my side. so i might be answering out of context.

    lets assume you have polygon object made of two polygons :

    poly0 (p0,p1,p2,p3)
    poly1 (p2,p3,p4,p5)

    using the same index as you did will result in :

    poly0value = point0
    poly1value = point1

    which is obviously wrong. you have to translate your matrix index (which is just the
    polygon index) into the the correct sum of point indices for the polygon object on 
    which the vertex map is based on. so in pseudo code it would be something like that:

    for i in xrange(matrixlist) :
    	cpoly = vmappolygonobject.GetPolygon(i)
    	weight = vmapdata[cpoly.a] + vmapdata[cpoly.b] + vmapdata[cpoly.c]
    	if cpoly.c != cpoly.d:
    		weight = (weight + vmapdata[cpoly.d]) / 4
    	else:
    		weight = weight / 3
    	matrixlist = matrixlist * doSomethingWithYourWeight
    

    _ _
    __
    your scaling code seems to be wrong to me too, now that i red your code again

    v0  (vx, 0, 0)
    v1  ( 0,vy, 0)
    v1  ( 0, 0,vz)

    vx,vy,vz define the scale of your object, the other components define the rotation. 
    multiplying the vectors of a matrix with a float will mess up the matrix unless the 
    rotation is zero.

    edit : fixed typos




  • On 07/05/2013 at 05:53, xxxxxxxx wrote:

    Hi LD

    You have understood the problem (sorry for any confusion, I wish the PluginCafe allowed attachments)

    and fixing my coding (still not sure how to correct the scaling) - off to look up

    I only come back to Python once in a while, and it always feel like I'm starting from scratch

    thank you very much - your help is appreciated 🙂


Log in to reply