Page 1 of 1

wish - setting for projection of override material

Posted: Tue Jul 28, 2015 10:09 am
by macray
it would be nice to have an option for the projection of the override material!

thereby I'd be able to f.e. use a laminate texture in cubic projection to make the whole model appear to be made of laminate.
now it works fine with simple colored materials but having the UV projection makes stuff go completely out of shape.

Re: wish - setting for projection of override material

Posted: Tue Jul 28, 2015 1:25 pm
by JDHill
The problem is that it is texture tags, not materials, which define UVs. So to make a cubic projection for the whole model, you would need to remove all texture tags, group everything under a null, and then put a single texture tag, with projection set to cubic, on that null.

Re: wish - setting for projection of override material

Posted: Tue Jul 28, 2015 2:02 pm
by macray
yeah, thought so. :?
will use your method.

thanks for the reply!

Re: wish - setting for projection of override material

Posted: Tue Jul 28, 2015 2:05 pm
by JDHill
I think it should be pretty easy (famous last words) to write a python script which would make a copy of the document, with these modifications, which you could then open and render. When I get a minute, I can check that out.

Re: wish - setting for projection of override material

Posted: Tue Jul 28, 2015 6:19 pm
by JDHill
Here is a script which:
  1. creates a copy of the current document
  2. removes all of its texture tags
  3. groups everything under a single null
  4. assigns a cubic-projection texture tag to the null
  5. saves the copy to a .c4d file
You can then open the saved copy and render. Of course, when using this method, it's not actually necessary to use the override material at all, since everything is now using a single texture tag -- just apply your desired material to that, and adjust the projection as desired.
Code: Select all
import c4d

def kill_tags(o, t):
    while o and o.GetTag(t):
        o.KillTag(t)

def remove_tags(o):
    while o:
        kill_tags(o, c4d.Ttexture)
        #kill_tags(o, c4d.Tpolygonselection)
        remove_tags(o.GetDown())
        o = o.GetNext()

def group_objects(d):
    p = None
    o = d.GetFirstObject()
    n = c4d.BaseObject(c4d.Onull)
    d.InsertObject(n)
    while o:
        t = o.GetNext()
        if p:
            o.InsertAfter(p)
        else:
            o.InsertUnder(n)
        p = o
        o = t

def apply_override(d):
    m = c4d.BaseMaterial(c4d.Mmaterial)
    m.SetName('Override')
    d.InsertMaterial(m)
    n = d.GetFirstObject()
    t = n.MakeTag(c4d.Ttexture)
    t.SetMaterial(m)
    t[c4d.TEXTURETAG_PROJECTION] = 3;

def main():
    d = c4d.documents.GetActiveDocument().GetClone()
    remove_tags(d.GetFirstObject())
    group_objects(d)
    apply_override(d)
    c4d.documents.SaveDocument(d, 'clone.c4d', saveflags=c4d.SAVEDOCUMENTFLAGS_0, format=c4d.FORMAT_C4DEXPORT)

if __name__=='__main__':
    main()
To run the script, open Script > Script Manager, make sure you have selected the Python (as opposed to C.O.F.F.E.E) tab, click File > New, and paste in the script. You can then use File > Save As to save it for later, and/or create a toolbar button for it by clicking the "Shortcut..." button near the bottom-right corner of the Script Manager.

Re: wish - setting for projection of override material

Posted: Fri Jul 31, 2015 11:34 am
by macray
thanks a lot!

I would have done that by hand, I'm not that good in programming.