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

    Chaging the LayerShader

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 333 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 02/10/2012 at 10:37, xxxxxxxx wrote:

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

      ---------
      Hello.
       I've seen tons of threads about the LayerShader and it doesn't look like you can add things to it which sucks, but that's not what I need to do.  I want to access the layers already in it and modify them.  And from what I've seen that's possible, but I'm not sure how to get access to the LayerShader, I've got code to get the BaseShader but I don't know how to get to the LayerShader.

      Here's where I'm at:

        
      shader = mat->GetFirstShader();  
      //code to loop through all the shaders in the material  
        
      if (shader->GetType() == Xlayer)  
            {  
                //do stuff to the layers here  
            }  
      

      So I know if it's a LayerShader or not, but how do I get from the BaseShader class to the LayerShader class?  I'm new to C++ plugin development so sorry if that's an obvious question.

      Thanks in advance for any help!

      Dan

      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 02/10/2012 at 11:29, xxxxxxxx wrote:

        Hi Dan,

        Here's some code that shows how to handle a LayerShader:

        BaseMaterial *mat = doc->GetFirstMaterial();
        if (!mat) return FALSE;
        BaseShader *shader = mat->GetFirstShader();
        if (!shader) return FALSE;
        if (shader->GetType()==Xlayer)
        {
            // Cast shader to LayerShader
            LayerShader *layerShader = (LayerShader* )shader;
            if (!layerShader) return FALSE;
          
            // Get first layer, then use layer->GetNext() to loop through the layers
            LayerShaderLayer *layer = layerShader->GetFirstLayer();
            Bool res;
            // Loop trough the layers in the layer shader
            while (layer)
            {
                res = layer->SetParameter(LAYER_S_PARAM_SHADER_MODE, BlendMultiply);
                res = layer->SetParameter(LAYER_S_PARAM_SHADER_BLEND, 0.5);
                layer = layer->GetNext();
            }
            // Tells CINEMA to update
            EventAdd();
        }
        

        LayerShader and LayerShaderLayer classes are defined in the lib_layershader library, don't forget to include its header:

        #include "c4d_libs\lib_layershader.h"
        
        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 02/10/2012 at 14:01, xxxxxxxx wrote:

          Thanks Yannick, that's exactly what I need.

          I currently have

            
          #include "lib_layershader.h"  
          

          included in my file and it works, but

            
          #include "c4d_libs\lib_layershader.h"  
          

          returns that there's no such file or directory, any idea why?

          Thanks a bunch!

          Dan

          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 02/10/2012 at 14:09, xxxxxxxx wrote:

            It just depends on how your compiler is set up - just use the first one if that's working.

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