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

    empty Ttexture container

    SDK Help
    0
    3
    348
    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

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 21/02/2003 at 03:45, xxxxxxxx wrote:

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

      ---------
      i don't know what i am doing wrong. maybe it's just a misunderstanding of the cinema api or even c++ ...
      the i use the following code to try to get the contents of the Ttexture container but it's aways empty...
      TextureTag* Tag = static_cast<TextureTag*>(Object->GetTag (Ttexture, 0));
       
       if (Tag)
       {
        ObjName = Tag->GetName ();
        ObjName.GetCString (string, 1024, St7bit);
        cprintf ("\ntag name: ");
        cprintf (string);
        BaseContainer* TagContainer = Tag->GetDataInstance ();
        cprintf ("\ncontainer id = %d", TagContainer->GetId ());
        dword i = 0;
        while (1)
        {
         dword id = TagContainer->GetIndexId (i);
         if (id == NOTOK) break;
         
         cprintf ("\ni = %d   id = %d", i, id);
         i ++;
        }
       }

      thanks for helping out in advance

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 22/02/2003 at 12:27, xxxxxxxx wrote:

        here's some code from my source that may help. I don't think it like static_cast.

        <CODE>
        TextureTag* theTextureTag;
             theTextureTag = ( TextureTag* )inNode->GetTag( Ttexture, 0 );
             if ( theTextureTag != NULL )
             {     
                  BaseMaterial* materialOfNode = theTextureTag->GetMaterial();
             }
        </CODE>

        inNode is a BaseObject pointer

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 22/02/2003 at 23:36, xxxxxxxx wrote:

          There are no situations in the C4D SDK where reinterpret_cast<> vs. static_cast<> makes any other difference than whether the compiler accepts the cast or not. (The former is almost like a standard C cast while the latter requires that the cast makes sense.)
          It looks like the texture tag doesn't store its data in the container. Then you have to ask for description parameters directly:

              
              
               BaseObject* Object = doc->GetFirstObject();  
               TextureTag* Tag = static_cast<TextureTag*>(Object->GetTag (Ttexture, 0));  
               if (Tag)  
               {  
                String ObjName = Tag->GetName();  
                GePrint("tag name: " + ObjName);  
                  
                BaseContainer* TagContainer = Tag->GetDataInstance ();
              
              
              
              
                AutoAlloc<Description> desc;  
                Tag->GetDescription(desc, NULL);  
                  
                GePrint("description");
              
              
              
              
                void* b = desc->BrowseInit();  
                const BaseContainer* bc = 0;  
                DescID id, groupid;  
                while (desc->GetNext(b, &bc, id, groupid))  
                {  
                 GeData data;  
                 Tag->GetParameter(id, data, NULL);
              
              
              
              
                 GePrint("id = " + DescIDToString(id) + "  data = " + GeDataToString(data));  
                }  
                desc->BrowseFree(b);  
               }
          

          This code uses a few debug output function that I will paste at the bottom of this message. Of course, to just access a know value you could do:

              
              
               GeData matlink;  
               tag->GetParameter(DescID(TEXTURETAG_MATERIAL), matlink, NULL);  
               BaseMaterial* mat = static_cast<BaseMaterial*>(matlink.GetLink(doc, Mbase));  
               GePrint(mat->GetName());
          

          Here are the debug functions:

              
              
              String VectorToString(Vector v);  
              String DescIDToString(const DescID& id);  
              String BCToString(const BaseContainer& bc);  
              String GeDataToString(const GeData& data);
              
              
              
              
              String FourToString(LONG x);  
              String LongFourToString(LONG x);
              
              
              
              
                
              String VectorToString(Vector v)  
              {  
               return "[" + RealToString(v.x) + ","  
                + RealToString(v.y) + ","  
                + RealToString(v.z) + "]";  
              }
              
              
              
              
              String DescIDToString(const DescID& id)  
              {  
                String res;  
                res += "{";  
                for (int i = 0; i < id.GetDepth(); ++i)  
                {  
                  res += "id: " + LongFourToString(id[i].id) + ", dt: " +   
                    LongToString(id[i].dtype) + ", cr: " +   
                    LongToString(id[i].creator) + ((i != id.GetDepth() - 1) ? "  -  " : "");  
                }  
                res += "}";  
                return res;  
              }
              
              
              
              
              String GeDataToString(const GeData& data)  
              {  
                switch(data.GetType())  
                {  
                  case DA_NIL: return "DA_NIL";  
                  case DA_LONG: return LongFourToString(data.GetLong());  
                  case DA_REAL: return RealToString(data.GetReal());  
                  case DA_TIME: return "T=" + RealToString(data.GetTime().Get()) + "s";  
                  case DA_VECTOR: return VectorToString(data.GetVector());  
                  case DA_MATRIX: return "DA_MATRIX";  
                  case DA_BYTEARRAY: return "DA_BYTEARRAY";  
                  case DA_STRING: return "\"" + data.GetString() + "\"";  
                  case DA_FILENAME: return "$" + data.GetFilename().GetString() + "$";  
                  case DA_CONTAINER:   
                    {  
                      BaseContainer* bc = data.GetContainer();  
                      if (bc == NULL) return "bc==0";  
                      return BCToString(*data.GetContainer());  
                    }  
                  case DA_ALIASLINK:  
                    {  
                      BaseLink* bl = data.GetBaseLink();  
                      if (bl == NULL || bl->GetLink(GetActiveDocument()) == 0) return "link==0";  
                      return bl->GetLink(GetActiveDocument())->GetName();  
                    }  
                  case DA_MARKER: return "DA_MARKER";  
                }  
                return "Unknown";  
              }
              
              
              
              
              String BCToString(const BaseContainer& bc)  
              {  
                String res;  
                res += "[" + LongFourToString(bc.GetId()) + "; ";  
                GeData* data = 0;  
                int i = 0;  
                do  
                {  
                  data = bc.GetIndexData(i);  
                  if (!data) break;
              
              
              
              
                  res += LongFourToString(bc.GetIndexId(i)) + "=";  
                  res += GeDataToString(*data);  
                  res += ", ";  
                  i += 1;  
                }  
                while (i < 50);  
                res += "]";  
                return res;  
              }
              
              
              
              
              String FourToString(LONG x)  
              {  
               String res;  
               CHAR s[4];  
               CHAR* sx = reinterpret_cast<CHAR*>(&x);  
               s[0] = sx[3];  
               s[1] = sx[2];  
               s[2] = sx[1];  
               s[3] = sx[0];  
               res.SetCString(&s[0], 4, St7bit);  
               return res;  
              }
              
              
              
              
              String LongFourToString(LONG x)  
              {  
               return "{" + LongToString(x) + "," + FourToString(x) + "}";  
              }
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post