Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Is SetChannelState() still supported?

    Scheduled Pinned Locked Moved SDK Help
    6 Posts 0 Posters 587 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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);

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            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(...);

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              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

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                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

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post