How to copy channels with shaders?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 10/12/2004 at 02:41, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   8.5+ 
    Platform:      Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    I have a problem to get a complete copy of an material. I am using GetClone to get a material clone, but this doesn't copy the shaders used in the original material.
    Is there any example available how to browse through all channels and shaders and copy them from one material to another?
    I tried it with GetShader() and InsertShader() within each channel, but this doesn't seem to work.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 10/12/2004 at 05:06, xxxxxxxx wrote:

    I found out that I used the wrong document with AliasTrans Init command, so the first part of my question is solved now :-)

    Could someone please shed some light on how to copy individual channels (including shaders or textures) to another material?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 10/12/2004 at 07:14, xxxxxxxx wrote:

    Hi,

    channels should be cloneable too as GetClone() is in the baseclass Atom. You can use an aliastranslator also here. Even easier would even be to use CopyTo() :)

    HTH



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 10/12/2004 at 08:14, xxxxxxxx wrote:

    Hi Katachi,
    I already tried this, but it doesn't seem to work (nothing happens with CopyTo(), still have to check GetClone()).
    Here is a simplified copy of the script:

      
    AutoAlloc <AliasTrans> trans;  
    if (trans->Init(doc))  
    {  
    channel1=mat1->GetChannel(CHANNEL_COLOR);  
    channel2=mat2->GetChannel(CHANNEL_COLOR);  
    mat1->CopyTo(mat2, 0, trans);  
    trans->Translate(TRUE);       
    EventAdd();  
    }  
    

    This does nothing. Am I missing something obvious?
    GetClone works fine for the whole material though.
    Meanwhie I found a brute force way to do it with GetShader() and InsertUnder() combinations. Thought it would be easier :-)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/12/2004 at 06:41, xxxxxxxx wrote:

    Hmm, I haven´t tried it yet but maybe replace the 0 with NULL instead

    mat1->CopyTo(mat2, NULL, trans);

    You should also send a message to the material to notify it of the changes. But otherwise it looks correct to me. :\



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/12/2004 at 09:32, xxxxxxxx wrote:

    No! The second argument is 'LONG flags'. Even if NULL is defined as 0, the argument still should be 0 to avoid confusion - this is not a memory reference.

    Robert



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/12/2004 at 09:49, xxxxxxxx wrote:

    What if the Flag COPY_NO_HIERARCHY is defined as 0? And if he passes 0 then the shaders which are children of the BaseChannel might not be copied. If it isn´t defined as 0 then this makes no difference and passing 0 is ok.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/12/2004 at 10:16, xxxxxxxx wrote:

    Luckily, none of the flags are defined as 0. :)

    I'm a strong believer in defining even the 'nothing' flag such that:

    #define COPY_UNUSED 0

    would be part of my list of flag definitions, for instance.

    Robert



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/12/2004 at 10:36, xxxxxxxx wrote:

    ah ok, yes, I would add my vote for such a flag then. This would surely erase such confusions. :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/12/2004 at 06:14, xxxxxxxx wrote:

    Thank you all for your input so far. I have it working now.
    Can someone point me to the right direction where the Illumination settings of a material are stored (such as amount of generated GI, shading type, quality of loaded textures etc.)?
    I cannot find anything about this in the SDK. Only those channels are documented that can be switched on and off via SetChannelState().



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/12/2004 at 06:41, xxxxxxxx wrote:

    Ah, ok, found it in Mmaterial.h.


Log in to reply