Getting the Editor Color for a shader [SOLVED]

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?

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

Sounds like you need BaseObject::GetColorProperties().

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

I tried the following code:

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

But it is not working 😞

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;   
the_color = prop.color;   

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

YES!!! Finally did it!

Thank you all 😄

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


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