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

    Selecting images in theTexture View window?

    SDK Help
    0
    7
    691
    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 04/06/2013 at 11:00, xxxxxxxx wrote:

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

      ---------
      How do we select one of the textures in the Texture View window?
      The docs say that the images are stored in a GeListHead structure. But there's nothing in the docs that shows how to select them.

        
        Filename fn = Filename("C:\\Users\\user\\Desktop\\myimage.jpg");  
          
        BaseContainer bc;  
        bc.SetFilename(LOADTEXTURE_FILENAME, fn);  
        
        //Loads the image into C4D..But doesn't display it in the texture window!!!  
        PaintTexture *tex = (PaintTexture* )SendPainterCommand(PAINTER_LOADTEXTURE, doc, NULL, &bc);   
        if (!tex) return FALSE;  
        
        //Opens a new Texture View window  
        CallCommand(170103);  
        
        GeListHead *imageList = tex->GetPaintTextureHead();  
        GeListNode *first = imageList->GetFirst();  
        first->ChangeNBit(?, NBITCONTROL_SET);   //<----- How do I select the first image in the texture view window so it shows up in it?
      

      -ScottA

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

        On 04/06/2013 at 11:14, xxxxxxxx wrote:

        I guess the correct method is BaseList2D->SetBit(BIT_ACTIVE), as GeListNode NBITS / the
        selection NBITS are usually used for deeper lying stuff. Might be wrong though, as I have 
        never fiddled with Bodypaint classes.

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

          On 04/06/2013 at 15:03, xxxxxxxx wrote:

          I don't see any way to use SetBit() with this. There's no SetBit() option for GeListNodes.

          GetPaintTextureHead() gives us the root. So we should be able use that to traverse the list of textures using things like GetFirst(), GetDown(), GetNext(), etc.
          But they don't tell us how to do anything with those children. Like how to select one of them.

          Yannick. Are you there?
          Can you please ask the developers how we're supposed to do this?
          They gave us the GetPaintTextureHead() function so we could use it enable a specific texture in the list. But it's not explained how in the docs.

          -ScottA

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

            On 04/06/2013 at 22:12, xxxxxxxx wrote:

            The GeListHead returns its children which are at least of type GeListNode, but most
            objects in c4d which have a user interaction and are of the type GeListNode are also
            a BaseList2D, the only exception from that rule i know is the Ckey. As the Bodypaint
            classes are all BaseList2D, I suppose the GeListHead will return one of these.

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

              On 05/06/2013 at 11:30, xxxxxxxx wrote:

              Yannick,

              CreateNewTexture() also does the same annoying thing. Where it does not select the the new texture in the Texture View window after it's been created:

                  Filename fn = Filename("C:\\Users\\user\\Desktop\\mytex");  
                BaseContainer bc;  
                bc.SetFilename(LOADTEXTURE_FILENAME, fn);  
                bc.SetLong(TEXTURE_FILEFORMAT, FILTER_JPG);  
                bc.SetLong(TEXTURE_WIDTH, 1024);  
                bc.SetLong(TEXTURE_HEIGHT, 1024);  
                bc.SetLong(TEXTURE_MODE, COLORMODE_RGB);  
                PaintTexture *tex = NULL;  
                tex->CreateNewTexture(fn, bc);      //<--Does the same thing...Creates a new texture. But does not select it in the Texture View window!!?
              

              It would be great if there was a way to select these textures so they show up in the texture window.

              -ScottA

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

                On 05/06/2013 at 15:19, xxxxxxxx wrote:

                Try this code. When you are in the BodyPaint layout and viewing the Texture tab it will create a texture and display it.

                BaseContainer bc;
                bc.SetLong(TEXTURE_FILEFORMAT,FILTER_TIF);
                bc.SetLong(TEXTURE_WIDTH, 1024);
                bc.SetLong(TEXTURE_HEIGHT, 1024);
                bc.SetLong(TEXTURE_MODE, COLORMODE_RGB);
                PaintTexture *pTex = PaintTexture::CreateNewTexture("C:\ emp\ extimage.tif",bc);
                if(pTex)
                {
                     PaintLayer *pLayer = pTex->GetFirstLayer();
                     if(pLayer && pLayer->IsInstanceOf(OBJECT_PAINTLAYERBMP))
                     {
                          Bool ret = PaintTexture::SetSelected_Texture((PaintLayerBmp* )pLayer,NULL);
                          if(ret)
                          {
                               //Image should now be selected
                          }
                     }
                }

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

                  On 05/06/2013 at 18:33, xxxxxxxx wrote:

                  Thanks. That did the trick.
                  I didn't realize those textures were also paint layers.

                  Here's the image loading code I posted earlier. Only now it also selects the loaded image as expected:

                      Filename fn = Filename("C:\\Users\\user\\Desktop\\myimage.jpg");      
                    BaseContainer bc;  
                    bc.SetFilename(LOADTEXTURE_FILENAME, fn);  
                    PaintTexture *pTex = (PaintTexture* )SendPainterCommand(PAINTER_LOADTEXTURE, doc, NULL, &bc);  
                    if (!pTex) return FALSE;  
                    
                    if(pTex)  
                    {  
                        PaintLayer *pLayer = pTex->GetFirstLayer();  
                        if(pLayer && pLayer->IsInstanceOf(OBJECT_PAINTLAYERBMP))  
                        {  
                            Bool ret = PaintTexture::SetSelected_Texture((PaintLayerBmp* )pLayer,NULL);  
                        }  
                    
                        //Opens a new Texture View window  
                        CallCommand(170103);  
                    }
                  

                  Thank you kbar. 🍺
                  -ScottA

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