Is SetChannelState() still supported?



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

    On 27/04/2011 at 08:19, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   12 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    While going through the SDK and trying out some of the shader functions. I ran into problems with the SetChannelState() function to enable shader channels:

    BaseMaterial *mat = BaseMaterial::Alloc(Mmaterial);     
    Vector colorv = Vector(1.0, 0.7, 0.3);  
    mat->SetParameter(DescID(MATERIAL_COLOR_COLOR), GeData(colorv), DESCFLAGS_SET_0);  
    BaseChannel *ch = mat->GetChannel(CHANNEL_LUMINANCE);  
    BaseContainer bc = ch->GetData();  
    bc.SetString(BASECHANNEL_TEXTURE, "C:\\Path\\To\\Image.jpg");   
    //mat->SetChannelState(ch, TRUE); //                                             <--- Throws an error:  
    mat->SetParameter(DescID(MATERIAL_USE_LUMINANCE), GeData(TRUE), DESCFLAGS_SET_0);//<---Works fine  
    ch->SetData(bc);   
    doc->InsertMaterial(mat);  
    mat->Update(TRUE, TRUE);  
    EventAdd();  
      
    void Free(BaseMaterial*& mat);
    

    Am I using it wrong?
    Or is this something left over from previous versions that is no longer supported?

    -ScottA



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

    On 27/04/2011 at 11:09, xxxxxxxx wrote:

    You send the channel type not its pointer:

    mat->SetChannelState(CHANNEL_LUMINANCE, TRUE);



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

    On 27/04/2011 at 11:29, xxxxxxxx wrote:

    I tried that way too.
    But I get the same error:  class "BaseMaterial" has no member "SetChannelState".

    I don't know if this matters.
    But I'm testing this in very simple stripped down CommandData plugin. With only this class in it:

    class SimplePlugin : public CommandData  
    {  
      public:  
    SimplePlugin(); //The Constructor        
            
    virtual LONG      GetState(BaseDocument *doc);        
    virtual Bool      Execute(BaseDocument *doc); //Where the create shader code exists  
      
    };
    

    I don't think this should make any difference.
    But since I'm fairly new to C++. I just wanted to post this information. Just in case I'm wrong.

    -ScottA



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

    On 27/04/2011 at 12:45, xxxxxxxx wrote:

    Cast it to a Material (derived from BaseMaterial).  The method is declared there.

    ((Material* )mat)->SetChannelState(...);



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

    On 27/04/2011 at 13:09, xxxxxxxx wrote:

    Umm. You want me to do what. To who?😵
    Sorry. I haven't learned about casting yet.

    Strange that it takes all of this extra work to make it work. And no mention of casting in the SDK.
    I'll just take your word for it that it works. And stick to using the SetParameter method for now.

    I'll try to find some tutorials on how to do casting. It's something I've been meaning to learn anyway.

    Thanks for the help,
    -ScottA



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

    On 28/04/2011 at 07:59, xxxxxxxx wrote:

    There is no mentioning of casting because this is a feature of the C++ language and not specific to Cinema's SDK. SetChannelState() is a method of the Material class which is derived from BaseMaterial.

    cheers,
    Matthias


Log in to reply