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

    Getting the Editor Color for a shader [SOLVED]

    SDK Help
    0
    6
    578
    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/03/2015 at 14:43, xxxxxxxx wrote:

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

      ---------
      I was trying to create a shader that would return the editor display color of an object.
      My main shader code is this:

      Vector EditorColorShaderData::Output(BaseShader * chn, ChannelData * cd) {

      Vector the_color=Vector(.5,.5,.5);
         
          if (cd->vd)
              {
                  RayObject *op = NULL;

      op= cd->vd->op;
                 
                  if (op)
                  {
                     BaseObject* original=(BaseObject* ) op->link;
                    
                     BaseContainer* bc=original->GetData()
                    
                     if (bc) the_color=bc->GetVector(ID_BASEOBJECT_COLOR)
                  }

      }

      return the_color;
      }

      But it is not working. I mean, it always gets me a grey color (the default I set).
      How can I get the color of the editor of an object, at render time, in a shader?

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

        On 04/03/2015 at 23:35, xxxxxxxx wrote:

        Sounds like you need BaseObject::GetColorProperties().

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

          On 05/03/2015 at 03:12, xxxxxxxx wrote:

          I tried the following code:

            
          BaseObject* original=(BaseObject* ) op->link;   
            
          ObjectColorProperties* prop;   
          original->GetColorProperties(prop);   
            
          the_color=prop->color;   
          

          But it is not working 😞

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

            On 05/03/2015 at 04:52, xxxxxxxx wrote:

            Your are passing an uninitialized pointer to GetColorProperties() so it can't fill it with data.
            Try this instead:

              
            ObjectColorProperties colorProps;   
            original->GetColorProperties(&colorProps;);   
            the_color = prop.color;   
            
            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 05/03/2015 at 05:23, xxxxxxxx wrote:

              YES!!! Finally did it!

              Thank you all 😄

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

                On 05/03/2015 at 07:31, xxxxxxxx wrote:

                Hi,

                Thanks for helping Rui. I'll close this thread as solved.

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