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

    Unable to retrieve LayerSet from Shader

    SDK Help
    0
    4
    318
    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
      Helper
      last edited by

      On 26/03/2013 at 02:29, xxxxxxxx wrote:

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

      ---------
      Hi folks,
      I'm trying to modify the LayerSet of a BitmapShader. But I always get a NULL pointer with the following code:

        
      BaseShader *tex = BaseShader::Alloc(Xbitmap);   
      if (!tex)   
      {   
          BaseMaterial::Free(mat);   
          return NULL;   
      }   
      mat->InsertShader(tex);   
      tex->SetParameter(BITMAPSHADER_FILENAME, GeData(Filename("...")), DESCFLAGS_SET_0);   
      GeData dLayerSet;   
      if (tex->GetParameter(BITMAPSHADER_LAYERSET, dLayerSet, DESCFLAGS_GET_0))   
      {   
          LayerSet *layerSet = static_cast<LayerSet*>(dLayerSet.GetCustomDataType(CUSTOMDATATYPE_LAYERSET));   
          if (layerSet)   
          {   
              layerSet->SetMode(LAYERSETMODE_LAYERALPHA);   
          }   
      }   
      

      Does anyone know what's wrong here?
      Thanks in advance!
      Satara

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

        On 26/03/2013 at 04:03, xxxxxxxx wrote:

        Ok seems that I have to allocate it by myself.
        This works fine:

          
        LayerSet *layerSet = static_cast<LayerSet*>(dLayerSet.GetCustomDataType(CUSTOMDATATYPE_LAYERSET));   
        if (!layerSet) layerSet = LayerSet::Alloc();   
        if (layerSet)   
        {   
            layerSet->SetMode(LAYERSETMODE_ALPHAS);   
            layerSet->AddLayer("Alpha");   
            dLayerSet.SetCustomDataType(CUSTOMDATATYPE_LAYERSET, *layerSet);   
            tex->SetParameter(BITMAPSHADER_LAYERSET, dLayerSet, DESCFLAGS_SET_0);   
        }   
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 26/03/2013 at 08:14, xxxxxxxx wrote:

          Hi Satara,

          Thanks for posting the code. But I'm having a hard time getting your code to work.
          And I can't find much information about the LayerSet type.

          This code produces an "unexpected type" compile error:

          LayerSet *layerSet = static_cast<LayerSet*>(dLayerSet.GetCustomDataType(CUSTOMDATATYPE_LAYERSET));
          

          Are you including this header file?: customgui_layerset.h
          Or some other header file?

          -ScottA

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

            On 26/03/2013 at 09:04, xxxxxxxx wrote:

            Never mind. I figured it out.
            This is the missing piece of code that makes the rest of your code work:GeData dLayerSet;

            -ScottA

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