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
    • Login

    ShaderPlugin & Objects with this Shader inside

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 351 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 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?

      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 22/08/2010 at 22:46, xxxxxxxx wrote:

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

        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 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.

          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 24/08/2010 at 12:34, xxxxxxxx wrote:

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

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