ChannelShader acessing object attributes?



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

    On 25/09/2008 at 16:02, xxxxxxxx wrote:

    Oops, this is suddenly working now, too.

    Didn't debug it yet, but I guess when using perfect spheres the data is also contained in "link" and not in "cacheparent".

    Close this thread, I'm just mumbling to myself...

    Greetings,
    Jack



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

    On 21/05/2009 at 10:56, xxxxxxxx wrote:

    Just have to push this old thread up again...

    When the rendered object is an instance object, using the code from this thread I always get access to the container of the original instanced object. How can I detect if the rendered object is an instance object, and then access the instance object's container?

    Also, instead of the old code:

    > <code>robj = xvd->ID_to_Obj(xvd->lhit, &local;_id);</code>

    ...I now use this:

    > <code>robj = xvd->op;</code>

    Seems to be exactly the same, didn't notice any difference. So why use ID_to_Obj()?

    Anyway, the instance is the most important for me now ;-)

    Thanks in advance for information!

    Greetings,
    Jack



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

    On 22/05/2009 at 15:02, xxxxxxxx wrote:

    Does anybody have an idea?

    Let's summarize (code stripped down to the essential parts) :

    > \> Vector MyShader::Output(PluginShader \*chn, ChannelData \*cd) \> { \>      // Get volume data \>      VolumeData \*xvd = cd->vd; \> \>      // Get Ray object \>      RayObject \*robj = xvd->op; \> \>      // Get polygon cache \>      BaseObject \*pcache = robj->link; \> \>      // Container \>      BaseContainer \*dsource = NULL; \> \>      // Check if this object contains values for my shader \>      // (Check for Bool value that I write in all objects that should be shaded) \>      if (pcache->GetDataInstance()->GetBool(THIS_OBJ_IS_SHADED)) { \>           dsource = pcache->GetDataInstance(); \>      } \>      else { \>           dsource = pcache->GetCacheParent()->GetDataInstance(); \>      } \> \>      // Color calculations start here \>      // and read values from the object like this: \>      Real Value = dsource->GetReal(SOME_ID, 0.0); \> \>      // ... \>      // ... \>      // ... \>      return my_color_value; \> } \>

    That works with all kind of objects, polygon objects, generators, perfect spheres, etc. But not with Instance objects. If I have an instance of an object, pcache always represents the linked original object instead of the instance object.

    How can I detect if the rendered object is an instance object? I am sure there is a way.

    Thanks for tips!

    Cheers,
    Jack



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

    On 26/05/2009 at 03:25, xxxxxxxx wrote:

    You have to go up all the cache hierarchy not just one step. Here some working code:

    > \> Vector MandelbrotData::Output(PluginShader \*chn, ChannelData \*cd) \> { \>      if (cd->vd) \>      { \>           RayObject \*robj = NULL; \>           robj = cd->vd->op; \>           if (!robj) return 0.0; \> \>           BaseObject \*parent = NULL; \>           BaseObject \*op = NULL; \>           op = robj->link; \> \>           while (op) \>           { \>                parent = op; \>                op = op->GetCacheParent(); \>           } \> \>           if (parent && parent->GetType() == Oinstance) return Vector(1.0, 0.0, 0.0); \>      } \> \>      return 1.0; \> } \>

    cheers,
    Matthias



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

    On 26/05/2009 at 04:03, xxxxxxxx wrote:

    Ah, yes!

    Thanks Matthias. I've been searching for this soooo long. Please excuse my offensive grizzling. Things can be so frustrating when one doesn't know the answer.

    Again, thanks a thousand times! As always, you're going to be credited in my plugin's manual ;-)

    Cheers,
    Jack



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

    On 27/05/2009 at 05:16, xxxxxxxx wrote:

    Hm, sorry to bug you again with this, but it does not work.

    Instead of returning white (like in your example), I print a message to the console:

    > <code>
    > if (parent && parent->GetType() == Oinstance)
    >     GePrint("Instance!");
    > </code>

    The message IS printed.

    But the problem is, when I try to get the Instance object's Container like this:

    > BaseContainer \*data = parent->GetDataInstance();

    I always get a pointer to the same memory address, no matter which of the hundreds of instance objects is being rendered.
    Is this the container of the original object instead of the instance object's container?

    Any more ideas?

    Greetings,
    Jack



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

    On 27/05/2009 at 05:26, xxxxxxxx wrote:

    I have no idea why it is not working for you. It works perfectly fine here. Have you tried the exactly same code I posted? Maybe it's something else within your code?

    cheers,
    Matthias



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

    On 27/05/2009 at 05:30, xxxxxxxx wrote:

    Sorry, I altered my previous post.
    It works, but not as expected. Please refresh the page, and read again. Sorry ;-)

    Cheers,
    Jack



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

    On 27/05/2009 at 06:30, xxxxxxxx wrote:

    Sorry I can not confirm this. This code is working fine for me:

    > \> Vector MandelbrotData::Output(PluginShader \*chn, ChannelData \*cd) \> { \>      if (cd->vd) \>      { \>           RayObject \*robj = NULL; \>           robj = cd->vd->op; \>           if (!robj) return 0.0; \> \>           BaseObject \*parent = NULL; \>           BaseObject \*op = NULL; \>           op = robj->link; \> \>           while (op) \>           { \>                parent = op; \>                op = op->GetCacheParent(); \>           } \> \>           if (parent/\* && parent->GetType() == Oinstance\*/) \>           { \>                BaseContainer \*data = NULL; \>                data = parent->GetDataInstance(); \> \>                GePrint(LongToString((LONG)data)); //print the address of the container \>                 \>                //return Vector(1.0, 0.0, 0.0); \>           } \>      } \> \>      return 1.0; \> } \>

    cheers,
    Matthias



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

    On 27/05/2009 at 10:36, xxxxxxxx wrote:

    Ah, ok, it seems I did something wrong.
    Works not with normal objects, Ray objects (like the perfect sphere) and Instance objects. Thanks a lot!

    Cheers,
    Jack



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

    On 30/05/2009 at 14:04, xxxxxxxx wrote:

    Hi there, may I jump in here with my following question?
    I have a shader where I just use the object position to define a color. It works perfect until I use a generator plugin - than the shader just uses the position of the child object but not of the cloned objects.

    Can you give me a hint where to look?

    thanks in advance,
    cheers,
    Ello



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

    On 30/05/2009 at 14:36, xxxxxxxx wrote:

    hm.seems it just works when the child object is a polygonobject


Log in to reply