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

    Replacing Textures

    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 22/02/2013 at 13:15, xxxxxxxx wrote:

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

      ---------
      Hi guys!

      I'm pretty new to the SDK, so if this question is really daft/simple please go easy on me 😉

      OK, is it possible to change a texture bound to a channel in a material using the C++ SDK?

      I can currently:
        - Get hold of the material I want to change
        - Check the channel is in use (channel state)
        - Get the BaseChannel pointer and use this to get the BaseContainer
        - Query the container for the BASECHANNEL_TEXTURE to see the filename (though only the name. Not that it's important, but can you actually get the full path?)

      But where do I go from here to replace the texture with another from disk?

      Any help would be greatly appreciated!

      Cheers,
      Simon.

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

        On 22/02/2013 at 14:12, xxxxxxxx wrote:

        BaseChannel*    bchan = mat->GetChannel(CHANNEL_COLOR);  
        BaseContainer    bdata;  
        // Get the full path to the image file  
        Filename        oldmap =    bchan->GetData().GetFilename(BASECHANNEL_SUGGESTEDFOLDER)+Filename(bchan->GetData().GetString(BASECHANNEL_TEXTURE));  
        GePrint("Texture file: "+oldmap.GetString());  
          
        // 'map' is a Filename that contains the full path to the image texture map on disk  
        // You can make it from a String which contains the full path like this:  
        // Filename map = Filename(strPath);  
        bdata.SetFilename(BASECHANNEL_SUGGESTEDFOLDER, map.GetDirectory());  
        bchan->SetData(bdata);  
        bdata.SetString(BASECHANNEL_TEXTURE, map.GetFileString());  
        bchan->SetData(bdata);  
          
        // Apply the changes  
        mat->Update(TRUE, TRUE);  
        EventAdd();  
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 22/02/2013 at 15:20, xxxxxxxx wrote:

          Thanks for the speedy reply Robert, that's exactly what I was looking for!

          Seems so simple (and obvious) when you see the solution 🙂

          Cheers,
          Simon

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

            On 22/02/2013 at 19:18, xxxxxxxx wrote:

            It is only simple once you have pulled out hair and slammed your head on the wall for a long time.  Then you eventually figure it out and hope to any divine being that the methodology never changes. Confused

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