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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Getting material 'use' flag

    Cinema 4D SDK
    sdk c++
    2
    3
    502
    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.
    • WickedPW
      WickedP
      last edited by

      Hi folks,

      having a time trying to get simple material parameters. Would like to get the tick box next to the main options in the material window, like Color and Reflection.

      I've been around in circles with the following:

      BaseTag *tag = obj->GetFirstTag();
      BaseMaterial *texture = (BaseMaterial*)tag;
      
      if(texture->GetParameter(DescID(MATERIAL_USE_COLOR),data,DESCFLAGS_GET_0) && data == true)
      {
          // this never runs
      }
      

      A few assumptions with the above, but you get the idea. Where am I going wrong here?

      WP.

      wickedp.com

      fwilleke80F 1 Reply Last reply Reply Quote 0
      • fwilleke80F
        fwilleke80 @WickedP
        last edited by fwilleke80

        @wickedp You can't just cast a BaseTag to a BaseMaterial.

        Rather check if the tag is really a TextureTag, cast it to TextureTag, and then ask it for the material link.

        // Get the first texture tag
        BaseTag* const tagPtr = obj->GetTag(Ttexture);
        if (tagPtr)
        {
          // Cast BaseTag* to TextureTag*
          TextureTag* const textureTagPtr = static_cast<TextureTag*>(tagPtr);
        
          // Get material pointer from the texture tag
          BaseMaterial* const materialPtr = textureTagPtr->GetMaterial();
          if (materialPtr)
          {
            // Check if color channel is active
            if (materialPtr->GetChannelState(CHANNEL_COLOR))
            {
              // Change material settings here
            }
          }
        }
        

        Check out the SDK docs 😉
        https://developers.maxon.net/docs/cpp/2023_2/class_material.html

        Cheers,
        Frank

        www.frankwilleke.de
        Only asking personal code questions here.

        1 Reply Last reply Reply Quote 1
        • WickedPW
          WickedP
          last edited by

          Thanks Frank,

          @fwilleke80 said in Getting material 'use' flag:

          BaseMaterial* const materialPtr = textureTagPtr->GetMaterial();

          Yep, that's what I was missing. I was thinking the texture tag was the material, but it wasn't and I needed to get the link to the material from the texture tag.

          Cheers,

          WP.

          wickedp.com

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