Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Assign Vertex Color Map to shader [SOLVED]

    SDK Help
    0
    3
    828
    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 21/05/2018 at 08:08, xxxxxxxx wrote:

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

      ---------
      Hi,

      I want to assign a vertex color tag to a vertex map shader.

      Here is the code I am using:

        
      		// allocate the Vertex Map shader
      		AutoAlloc<BaseShader> vertexMapShader(Xvertexmap);
      		if (!vertexMapShader)
      			return false;
        
      		// retrieve the BaseContainer of the Vertex Map shader
      		BaseContainer* vertexMapShaderBC = vertexMapShader->GetDataInstance();
      		if (!vertexMapShaderBC)
      			return false;
        
      		// The Vertex Color tag is vctag
      		GeData gd;
      		vertexMapShaderBC->GetParameter(GV_VERTEXCOLORMAP_INPUT_TAG, gd); // ---->this is where the crash happens
      		
      		BaseLink *myLink = gd.GetBaseLink();
      		myLink->SetLink(vctag);
        
        
      
      

      Any idea why it does not work?

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

        On 22/05/2018 at 05:32, xxxxxxxx wrote:

        Hi Salozo,

        First of all, I'm not sure to understand, from where you get the ID GV_VERTEXCOLORMAP_INPUT_TAG, to know an ID you can simply drag and drop the parameter in the console.
        Another thing is actually you should use Set/GetParameter in the C4DAtom(the shader in your case) itself and not on the BaseCcontainer.
        In other hands here an example how to set up a link.

        		// allocate the Vertex Map shader
        		AutoAlloc<BaseShader> vertexMapShader(Xvertexmap);
        		if (!vertexMapShader)
        			return false;
          
        		// allocate the Vertex Map
        		AutoAlloc<BaseTag> vertexMap(Tvertexcolor);
        		if (!vertexMap)
        			return false;
          
        		// allocate the Vertex Map
        		AutoAlloc<BaseLink> link;
        		if (!link)
        			return false;
          
        		link->SetLink(vertexMap.Release()); // I use release, since vertexMap is an AutoAlloc object, so you need to release it in order to let the ownership of the vertexMap I created to c4d.
        		vertexMapShader->SetParameter(SLA_DIRTY_VMAP_OBJECT, GeData(link), DESCFLAGS_SET_0);
        

        Hope it helps, if you have any question please do not hesitate! 🙂

        Cheers,
        Maxime

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

          On 22/05/2018 at 07:59, xxxxxxxx wrote:

          Thank you for your help Maxime. It works as it should now.

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