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
    • Recent
    • Tags
    • Users
    • Register
    • Login

    Shader drived from a Tag

    Scheduled Pinned Locked Moved SDK Help
    9 Posts 0 Posters 774 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 11/05/2005 at 08:55, xxxxxxxx wrote:

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

      ---------
      Hi all,

      I need to write a shader drived by a my PluginTag.
      Maybe like a Proxymal Shader.
      Can someone help me to understand how i can pass parameter from a TAG to a shader?
      I thought to an array that contain a index for all objects that have same texture tag... but how?

      thanks all
      Renato T.

      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 11/05/2005 at 10:27, xxxxxxxx wrote:

        If no one has a better idea, you could always use messaging. I've used MSG_RETRIEVEPRIVATEDATA to pass structs and arrays (in the void* data of a RetrievePrivateData struct) to and from my own plugins with much success.

        Basically, when your shader needs information from these tags, the shader can send a message like this with a RetrievePrivateData struct, the tag fills the data (and maybe sets the flags), and the shader retrieves what is filled into it.

        If you need to look for tags, I suggest getting the BaseDocument from the node (node->GetDocument()), and then set up a recursive method in the shader to get each object and check for tags:

          
        // These will need to be defined accessible for MyShader and MyTag  
        #define RPDATA_SET     0  
        #define RPDATA_GET     1  
          
        struct MyDataStruct  
        {  
             // whatever data is to be passed  
        };  
          
        Bool MyShader::SomeMethod()  
        {  
             BaseDocument* baseDoc = node->GetDocument();  
             if (!QueryTag(baseDoc, baseDoc->GetFirstObject()) return FALSE;  
             ...  
             return TRUE;  
        }  
          
        // Recursively check Document Object's for your PluginTag  
        Bool MyShader::QueryTag(BaseDocument* baseDoc, BaseObject* obj)  
        {  
             LONG nr;  
             PluginTag* pt;  
             RetrievePrivateData rpdata;  
             MyDataStruct myDataStruct;  
          
             for (obj; obj; obj = obj->GetNext())  
             {  
                  /* Do this here to perform leaf->root traversal  
                  // Handle children  
                  if (!QueryTag(baseDoc, obj->GetDown())) return FALSE;  
                  */  
          
                  // Get each MyPlugin tag from object (if nay)  
                  for (nr = 0; pt = (PluginTag* )obj->GetTag(ID_MYTAG, nr); nr++)  
                  {  
                       // Messaging  
                       rpdata.flags = RPDATA_GET;  
                       rpdata.data = &myDataStruct;  
                       if (pt->Message(MSG_RETRIEVEPRIVATEDATA, &rpdata;))  
                       {  
                            // extract data filled by your PluginTag  
                       }  
                  }  
          
                  // Do this here to perform root->leaf traversal  
                  // Handle children  
                  if (!QueryTag(baseDoc, obj->GetDown())) return FALSE;  
             }  
             return TRUE;  
        }  
        
        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 11/05/2005 at 10:51, xxxxxxxx wrote:

          Thanks Robert,

          i'll analize your code, i hope to get the right way from this.

          Thanks
          Renato T.

          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 11/05/2005 at 15:31, xxxxxxxx wrote:

            Now i need to know the Object ID from VolumeData.
            I mean what RayObject is processing the shader.
            Maybe easy but i don't find it.

            Thanks
            Renato T.

            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 11/05/2005 at 17:13, xxxxxxxx wrote:

              you can find the object in the volumedata

              BaseObject* op = vd->op->link;

              always check if NULL

              hope this helps

              Matthias

              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 11/05/2005 at 17:22, xxxxxxxx wrote:

                Argh.. i lost it in BaseVolumeData 😞

                thanks Matthias
                Renato T.

                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 12/05/2005 at 10:12, xxxxxxxx wrote:

                  Matthias,

                  I've looked for a unique id for objects but i don't find it.

                  I have a tag (N.o.t.a.) that manage Global Matrix of all objects grouped.. so i don't have a tag for each object and i need to check for a "id" if exist so i can look on my tag (or if possible add in each object container) for some data for index that can drive my Shader.

                  I hope that you understand what i mean.

                  Cheers
                  Renato T.

                  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 13/05/2005 at 00:15, xxxxxxxx wrote:

                    Nevermind 🙂

                    it's easy to add a data to container of all objects.. if is possible to do or add invisible tag for each object.

                    Thanks
                    Renato T.

                    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 13/05/2005 at 00:47, xxxxxxxx wrote:

                      Quote: Originally posted by RenatoT on 12 May 2005
                      >
                      > * * *
                      >
                      >
                      > I've looked for a unique id for objects but i don't find it.
                      >
                      >
                      > * * *

                      you can get a unique id with GetUniqueIP()

                        
                      //source of Output of your pluginshader  
                      //cd is the ChannelData  
                        
                      BaseObject *op = NULL;  
                      op = cd- >vd->op->link;  
                      LONG id = 0;  
                      if(op) id = op->GetUniqueIP();  
                      

                      best,
                      Matthias

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