ShaderPlugin & Objects with this Shader inside



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

    On 22/08/2010 at 08:11, xxxxxxxx wrote:

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

    ---------
    Inside a ShaderData om method InitRender.
    This shader should controlled by distance to an definied object, similar the cinema4D proximal shader.
    I try to get the global coordinates of the object, wich have an standard material with my ShaderPlugin.
    Now I try to do this
     
    LONG bwDistanceShaderClass::InitRender(PluginShader *sh, InitRenderStruct *irs)
    {
       ....
       Vector position = Vector(0,0,0);
       if(irs&&irs->vd&&irs->vd->op) {
           // get local
           position = irs->vd->op->link->GetPos();
           BaseObject* up=(BaseObject* )(irs->vd->op->link->GetUp());
           // make global
           while(up) {
              position += up->GetPos();
              up=(BaseObject* )(up->GetUp());
           }
        }
        ....
    }
     
    op is always NULL? I don't understand. Can anybody explain it?
     
    So I try it with GetObj(0) so get the right object but the local coordinates of this object are (0,0,0) on the single sphere object int the scene wich is placed in (100,200,300).
     
    Is there an other way or a better way to get the position of base object for my shader?



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

    On 22/08/2010 at 22:46, xxxxxxxx wrote:

    you can get the global position with GetMg(), no need to walk through the tree.



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

    On 24/08/2010 at 02:28, xxxxxxxx wrote:

    i think op refers to the object that was hit by the current ray during rendering.

    edit:
    Try sh->GetMain(), according to the sdk doc it should return the material. Then you probably must walk through the object hierarchy to see which objects have the material with your shader.

    perhaps it is also sufficient to do your calculation during rendering. Then vd->op is available, and you can get its position by vd->op->mg.off.



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

    On 24/08/2010 at 12:34, xxxxxxxx wrote:

    Thanks to all.
     
    I used vd->op->mg.off. It works perfect.


Log in to reply